Guest User

Untitled

a guest
Feb 4th, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. import React from 'react';
  2. import { StyleSheet, Text, View, Image, Button } from 'react-native';
  3. import {Input} from 'nachos-ui'
  4.  
  5. import MainMenu from './mainMenu'
  6.  
  7. var logo = require('./assets/download.jpg')
  8. var APP_VERSION = 4
  9.  
  10.  
  11.  
  12. export default class LoginPage extends React.Component {
  13. state = {
  14. username: '',
  15. password: '',
  16. usernameError: false,
  17. passwordError: false
  18. //value: null
  19.  
  20. }
  21. loginPressed = () =>{
  22. this.setState({usernameError:false,passwordError:false})
  23. if(!this.state.username){
  24. this.setState({usernameError: true})
  25. }
  26. if(!this.state.password){
  27. this.setState({passwordError: true})
  28. }
  29. if(this.state.password && this.state.username)
  30. {
  31. alert(this.state.username + " " + this.state.password )
  32. {()=> this.setState({currentPage: 'mainMenu'})}
  33.  
  34. }
  35. }
  36.  
  37.  
  38.  
  39. render() {
  40. switch(this.state.currentPage){
  41. case 'mainMenu':
  42. return<MainMenu/>
  43. break;
  44. case 'loginPage':
  45. return<App/>
  46. break;
  47. }
  48.  
  49.  
  50. if(this.state.currentPage==='mainMenu'){
  51. return(<MainMenu/>)
  52. }
  53.  
  54. return (
  55. <View
  56. style={styles.container}
  57. >
  58. <View
  59. style={styles.logoStyle}
  60.  
  61. >
  62. <Image
  63. source={logo}
  64. />
  65. </View>
  66. <View >
  67. <Input
  68. //inputStyle={styles.textInputBox}
  69. status={this.state.usernameError ? "warn" : null}
  70. value= {this.state.username}
  71. placeholder='username'
  72. onChangeText={(username) => this.setState({username})}
  73. />
  74. <Input
  75. status={this.state.passwordError ? "warn" : null}
  76. //inputStyle={styles.textInputBox}
  77. value= {this.state.password}
  78. placeholder='password' secureTextEntry ={true}
  79. onChangeText={(password) => this.setState({password})}
  80. />
  81. </View>
  82. <View>
  83. <Button
  84. title='LOGIN'
  85. onPress={this.loginPressed}
  86. style={{margin: 50}}
  87. />
  88. </View>
  89. <View style={styles.versionCd}>
  90. <Text>versi {APP_VERSION}</Text>
  91. </View>
  92. </View>
  93. );
  94. }
  95. }
  96.  
  97.  
  98. const styles = StyleSheet.create({
  99. container: {
  100. flex: 1,
  101. backgroundColor: '#fff',
  102. justifyContent: 'center',
  103. },
  104. textInputBox:{
  105. // backgroundColor:'grey',
  106. // borderColor:'black',
  107. // color: 'black',
  108. height: 40,
  109. paddingTop: 5
  110. //width:150
  111. //flex:2
  112. },
  113. logoStyle:{
  114. width: 75,
  115. height:75,
  116. //flex:1,
  117. margin:50,
  118. //alignItems:'center',
  119. justifyContent:'center',
  120. paddingHorizontal: 25,
  121. paddingTop: 10
  122. },
  123. versionCd: {
  124. //justifyContent:'center',
  125. //alignItem:'center',
  126. paddingHorizontal: 155,
  127. //paddingEnd: 75,
  128. paddingTop: 100
  129. }
  130.  
  131. });
Add Comment
Please, Sign In to add comment