Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { View, ActivityIndicator, AsyncStorage, StatusBar, ToastAndroid, Keyboard, TouchableOpacity } from 'react-native';
  3. import {
  4. Container, Header, Content, Form, Item, Input, Label, Button, Text, Title, Left, Body, Right, Icon,
  5. Card, CardItem,
  6. } from 'native-base';
  7. import { StackNavigator, NavigationActions } from "react-navigation";
  8. // import Storage from 'react-native-storage';
  9. import axios from 'axios';
  10. import styles from './styles';
  11. // import Storage from 'react-native-storage';
  12.  
  13.  
  14. export default class Login extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. email: '',
  19. password: '',
  20. hidePassword: true,
  21. errorText : '',
  22. focus : ''
  23. };
  24. this.LoginUser = this.LoginUser.bind(this);
  25.  
  26. }
  27. managePasswordVisibility = () =>
  28. {
  29. this.setState({ hidePassword: !this.state.hidePassword });
  30. }
  31.  
  32. //
  33. onChangeTextPassword = (password, hidePassword) => {
  34. if (!password) {
  35. this.setState({
  36. errorText: 'Tidak Boleh kosong',
  37. })
  38. }
  39. else if (password.length < 12 && password.length > 0) {
  40. this.setState({
  41. errorText: 'Minimal Panjang Huruf 12 karakter'
  42. })
  43. }
  44. else if (password.length > 20 && password) {
  45. this.setState({
  46. errorText: 'Maksimal Panjang Huruf 20 karakter'
  47. })
  48. } else if (hidePassword) {
  49. this.setState({
  50. hidePassword: hidePassword
  51. })
  52. } else {
  53. this.setState({
  54. errorText: ''
  55. })
  56. }
  57. }
  58.  
  59. //
  60. onFocus(){
  61. this.setState({
  62. focus: true
  63. })
  64. }
  65.  
  66. render() {
  67. let { email, password, } = this.state;
  68. let styleemail = email ? styles.a : styles.b;
  69. let iconemail = email ? styles.c : styles.d;
  70. let stylesPass = password ? styles.a : styles.b;
  71. let iconsPass = password ? styles.c : styles.d;
  72. return (
  73. <Container>
  74. <Header style={styles.header}>
  75. <StatusBar
  76. backgroundColor="#0000cc"
  77. barStyle="light-content"
  78. />
  79. <Left />
  80. {/*<Button transparent>
  81. <Icon name='menu' />
  82. </Button>
  83. </Left>*/}
  84. <Body>
  85. <Title>Header</Title>
  86. </Body>
  87. <Right />
  88. </Header>
  89. <Content style={styles.content} >
  90. <Content style={styles.login}>
  91. <Form>
  92. {/* <Item floatingLabel style={styles.Lname}>
  93. <Icon active name="ios-mail-outline" style={iconemail} />
  94. <Label style={styleemail}>User Email</Label>
  95. <Input
  96. onChangeText={(email) => this.setState({ email })}
  97. value={this.state.email}
  98. returnKeyType="next"
  99. />
  100. </Item> */}
  101. <Item floatingLabel style={styles.Lname}>
  102. <Icon active name="ios-lock-outline" style={iconsPass} />
  103. <Label style={stylesPass}>User Password</Label>
  104. <Input
  105. onChangeText={(text) => {
  106. this.onChangeTextPassword(text);
  107. this.setState({
  108. password: text
  109. })
  110. }}
  111. value={this.state.password}
  112. secureTextEntry={this.state.hidePassword}
  113. />
  114. </Item>
  115. {this.state.errorText ? this.state.hidePassword ?
  116. <Content style={{ marginRight: 15, alignSelf: 'flex-end' }} >
  117. <TouchableOpacity onPress={this.managePasswordVisibility}>
  118. <Text note style = {{color :'blue' }} >
  119. {this.state.hidePassword ? 'Lihat Password' : 'Sembunyikan Password'}
  120. </Text>
  121. </TouchableOpacity>
  122. </Content>
  123. :
  124. <Text>{this.state.errorText}</Text>
  125. }
  126. {/* <Content style={{ marginRight: 15, alignSelf: 'flex-end' }} >
  127. <TouchableOpacity onPress={this.managePasswordVisibility}>
  128. <Text note style = {{color :'blue' }} >
  129. {this.state.hidePassword ? 'Lihat Password' : 'Sembunyikan Password'}
  130. </Text>
  131. </TouchableOpacity>
  132. </Content> */}
  133.  
  134.  
  135. {/* <Content style={{ marginRight: 15, alignSelf: 'flex-end' }} >
  136. <TouchableOpacity onPress={this.managePasswordVisibility}>
  137. <Text>
  138. {this.state.hidePassword ? 'Lihat Password' : 'Tutup Password'}
  139. </Text>
  140. </TouchableOpacity>
  141. </Content> */}
  142.  
  143. {/* <Item floatingLabel style={styles.Lname}>
  144. <Icon name='ios-lock-outline' />
  145. <Label style={stylesPass}>User Password</Label>
  146. <Input
  147. onChangeText={(password) => this.setState({ password })}
  148. value={this.state.password}
  149. returnKeyType="next"
  150. autoCorrect={false}
  151. returnKeyType="go"
  152. secureTextEntry={this.state.hidePassword}
  153. />
  154.  
  155. <text>User Password</text>
  156. </Item> */}
  157.  
  158. {/* <TouchableOpacity activeOpacity = { 0.8 } onPress = { this.managePasswordVisibility }>
  159. { this.state.hidePassword ? <Icon name = 'ios-lock-outline' /> : <Icon name = 'ios-unlock-outline' /> }
  160. </TouchableOpacity> */}
  161. {/* <Item floatingLabel style={styles.Lpassword}>
  162. <Icon active name="ios-lock-outline" style={iconsPass} />
  163. <Label style={stylesPass}>User Password</Label>
  164. <Input
  165. onChangeText={(password) => this.setState({ password })}
  166. value={this.state.password}
  167. returnKeyType="next"
  168. autoCorrect={false}
  169. returnKeyType="go"
  170. // ref={(input)=> this.passwordInput = input}
  171. secureTextEntry = { this.state.hidePassword }
  172. />
  173. <TouchableOpacity >
  174. <text>asdasd</text>
  175. </It>
  176. </Item> */}
  177. </Form>
  178. <Button block style={styles.button}
  179. onPress={this.LoginUser}
  180. >
  181. <Text>Login</Text>
  182. </Button>
  183. {/*
  184. <Button style={styles.Ltext}>
  185. <Text style={{color: '#000000'}} >atau</Text>
  186. </Button>
  187. <Button iconLeft block style={styles.fb}>
  188. <Icon name='logo-facebook' />
  189. <Text>Login With Facebook</Text>
  190. </Button>
  191. <Button iconLeft block transparent danger style={styles.google}>
  192. <Icon name='logo-googleplus' />
  193. <Text>Login With Google</Text>
  194. </Button>
  195. */}
  196.  
  197. </Content>
  198. </Content>
  199. </Container>
  200. );
  201. }
  202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement