Commit c3b238f

mo khan <mo@mokhan.ca>
2016-12-24 22:18:56
remove tcomb-form-native
1 parent 3cbfcc7
app/domain/account.js
@@ -1,6 +0,0 @@
-import t from 'tcomb-form-native';
-
-export default Account = t.struct({
-  username: t.String,
-  password: t.String
-});
app/screens/login-screen.js
@@ -1,16 +1,12 @@
 import React from 'react';
-import { View, Button, Text } from 'react-native';
-import { Container, Header, Title, Content, Spinner } from 'native-base';
-import Account from '../domain/account'
+import { View } from 'react-native';
+import { Container, Header, Title, Content, Spinner, List, ListItem, InputGroup, Input, Icon, Button, Text } from 'native-base';
 import Api from '../infrastructure/api'
 import DashboardScreen from './dashboard-screen'
 import ApplicationComponent from '../components/application-component'
 import Configuration from '../infrastructure/configuration'
 import * as events from '../services/events';
 
-var t = require('tcomb-form-native');
-var Form = t.form.Form;
-
 export default class LoginScreen extends ApplicationComponent {
   constructor(props) {
     super(props)
@@ -48,14 +44,31 @@ export default class LoginScreen extends ApplicationComponent {
     else {
       return (
         <Content>
-          <Form ref="form"
-            type={Account}
-            onChange={this.onChange.bind(this)}
-            value={this.state.account}
-            options={this.formOptions()}
-          />
-          <Button onPress={this.onLogin.bind(this)} title="Login" />
-          <Text>{this.configuration.value_for('API_HOST')}</Text>
+          <List>
+            <ListItem>
+              <InputGroup>
+              <Input inlineLabel 
+                label="Username" 
+                value={this.state.account.username}
+                onChangeText={(text) => this.setState({account: {username: text }})}
+                />
+              </InputGroup>
+            </ListItem>
+            <ListItem>
+              <InputGroup>
+                <Icon name="ios-unlock" />
+                <Input secureTextEntry
+                  label="Password"
+                  value={this.state.account.password}
+                  onChangeText={(text) => this.setState({account: {password: text }})}
+                />
+              </InputGroup>
+            </ListItem>
+          </List>
+          <Button style={{alignSelf: 'center' }} onPress={this.onLogin.bind(this)}>
+            Log In
+          </Button>
+          <Text note>{this.configuration.value_for('API_HOST')}</Text>
         </Content>
       );
     }
@@ -69,7 +82,9 @@ export default class LoginScreen extends ApplicationComponent {
   }
 
   onLogin() {
-    let account = this.refs.form.getValue();
+    let account = this.state.account;
+    console.log("LOGGING IN");
+    console.log(account);
     this.publish({
       event: events.LOGIN,
       username: account.username,
package.json
@@ -11,8 +11,7 @@
     "native-base": "^0.5.18",
     "react": "15.4.1",
     "react-native": "0.39.2",
-    "react-native-svg": "^4.4.1",
-    "tcomb-form-native": "^0.6.3"
+    "react-native-svg": "^4.4.1"
   },
   "devDependencies": {
     "babel-jest": "18.0.0",
yarn.lock
@@ -3624,22 +3624,6 @@ supports-color@^3.1.2:
   version "3.2.1"
   resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.1.tgz#8549dd1d01fa9f893c18cc9ab0b106b4d9b168cb"
 
-tcomb-form-native@^0.6.3:
-  version "0.6.3"
-  resolved "https://registry.yarnpkg.com/tcomb-form-native/-/tcomb-form-native-0.6.3.tgz#fe4673aaaa99c70d5ad1d60371622940f60ead05"
-  dependencies:
-    tcomb-validation "^3.0.0"
-
-tcomb-validation@^3.0.0:
-  version "3.3.0"
-  resolved "https://registry.yarnpkg.com/tcomb-validation/-/tcomb-validation-3.3.0.tgz#29ada8534203500e90b245eedd0e1a80f1909ba2"
-  dependencies:
-    tcomb "^3.0.0"
-
-tcomb@^3.0.0:
-  version "3.2.15"
-  resolved "https://registry.yarnpkg.com/tcomb/-/tcomb-3.2.15.tgz#09e40f447976d1d9c07ff465b8377342a8fe67e1"
-
 temp@0.8.3:
   version "0.8.3"
   resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59"