Guest User

Untitled

a guest
Jul 16th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import styles from '../style';
  3. import { Text, View, StyleSheet, Image,Button,TextInput,TouchableHighlight, Alert,
  4. DatePickerAndroid, TouchableWithoutFeedback, Keyboard, ScrollView, DatePickerIOS} from 'react-native';
  5. import Icon from 'react-native-vector-icons/SimpleLineIcons';
  6. import {Platform} from 'react-native';
  7. import { createStackNavigator } from 'react-navigation';
  8.  
  9. export default class Signup extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. titleText: "Date of Bird",
  14. firstName: '',
  15. lastName: '',
  16. email: '',
  17. phoneNumber:'',
  18. spinnerText: '',
  19. data: null,
  20. chosenDate: new Date()
  21. };
  22. this.setDate = this.setDate.bind(this);
  23. }
  24.  
  25. state = {
  26. spinnerDate: new Date(),
  27. spinnerText: 'Date of Bird',
  28. };
  29.  
  30. setDate(newDate) {
  31. this.setState({chosenDate: newDate})
  32. }
  33.  
  34. showPicker = async (stateKey, options) => {
  35. try {
  36. var newState = {};
  37. const {action, year, month, day} = await DatePickerAndroid.open(options);
  38. if (action === DatePickerAndroid.dismissedAction) {
  39. newState[stateKey + 'Text'] = 'dismissed';
  40. } else {
  41. var date = new Date(year, month, day);
  42. newState[stateKey + 'Text'] = date.toLocaleDateString();
  43. newState[stateKey + 'Date'] = date;
  44. }
  45. this.setState(newState);
  46. } catch ({code, message}) {
  47. console.warn(`Error in example '${stateKey}': `, message);
  48. }
  49. };
  50.  
  51.  
  52. changeFirst(firstName){
  53. this.setState({firstName})
  54. }
  55.  
  56. changeLast(lastName){
  57. this.setState({lastName})
  58. }
  59.  
  60. changeEmail(email){
  61. this.setState({email})
  62. }
  63.  
  64. changePhone(phoneNumber){
  65. this.setState({phoneNumber})
  66. }
  67.  
  68. changeDate(spinnerText){
  69. this.setState({spinnerText})
  70. }
  71.  
  72. render() {
  73. return (
  74. <ScrollView>
  75. <View style={styles.container}>
  76. <Image
  77. source={require('../assets/background5.png')}
  78. style={styles.bgapp}
  79. />
  80. <Image
  81. source={require('../assets/icon.png')}
  82. style={styles.logosign}
  83. />
  84. <Text style={{fontSize:15, color:'white',marginBottom: 30,}}>A C K N O W L O G Y</Text>
  85. <View style={styles.timeline}>
  86. <View style={styles.block}>
  87. <Text style={styles.active}>1</Text>
  88. <Text style={styles.personal}>Personal Info</Text>
  89. </View>
  90. <View style={styles.block}>
  91. <Text style={styles.inactive}>2</Text>
  92. <Text style={styles.personal}>Company Info</Text>
  93. </View>
  94. <View style={styles.block}>
  95. <Text style={styles.inactive}>3</Text>
  96. <Text style={styles.personal}>Upload Photo</Text>
  97. </View>
  98. </View>
  99.  
  100. <View style={styles.form}>
  101. <Text style={styles.tittleSignUp}>SIGN UP</Text>
  102. <View style={styles.inputSignup}>
  103. <TextInput
  104. placeholder="First Name"
  105. placeholderTextColor= "#9fafb7"
  106. style={styles.input}
  107. value={this.state.firstName}
  108. onChangeText={(firstName) => this.changeFirst(firstName)}
  109. />
  110. <Icon name="people" size={20} color="#9fafb7"/>
  111. </View>
  112. <View style={styles.inputSignup}>
  113. <TextInput
  114. placeholder="Last Name"
  115. placeholderTextColor= "#9fafb7"
  116. style={styles.input}
  117. value={this.state.lastName}
  118. onChangeText={(lastName) => this.changeLast(lastName)}
  119. />
  120. <Icon name="people" size={20} color="#9fafb7"/>
  121. </View>
  122. <View style={styles.inputSignup}>
  123. <TextInput
  124. placeholder="E-mail"
  125. keyboardType="email-address"
  126. placeholderTextColor= "#9fafb7"
  127. style={styles.input}
  128. value={this.state.email}
  129. onChangeText={(email) => this.changeEmail(email)}
  130. />
  131. <Icon name="envelope" size={20} color="#9fafb7"/>
  132. </View>
  133. <View style={styles.inputSignup}>
  134. <TextInput
  135. placeholder="Phone"
  136. keyboardType="numeric"
  137. placeholderTextColor= "#9fafb7"
  138. style={styles.input}
  139. value={this.state.phoneNumber}
  140. onChangeText={(phoneNumber) => this.changePhone(phoneNumber)}
  141. />
  142. <Icon name="phone" size={20} color="#9fafb7"/>
  143. </View>
  144. { (Platform.OS === 'android') ? <View style={styles.inputSignup}>
  145. <TouchableHighlight
  146. style={styles.input}
  147. onPress={this.showPicker.bind(this, 'spinner',
  148. {date: this.state.spinnerDate, mode: 'spinner'})}
  149. underlayColor={'transparent'}>
  150. <TextInput
  151. placeholder="Date of Bird"
  152. editable={false}
  153. placeholderTextColor= "#9fafb7"
  154. textStyle={{color: '#9fafb7'}}
  155. style={{color: '#9fafb7',flex: 1,}}
  156. value={this.state.spinnerText}
  157. onChangeText={(spinnerText) => this.changeDate(spinnerText)}
  158.  
  159. />
  160. </TouchableHighlight>
  161. </View> : //Inicia el Datepick para ios
  162. <View style={{marginBottom:1, marginTop:1}}>
  163. <Text style={{color: '#9fafb7',textAlign:'center'}}>Date Of Bird</Text>
  164. <TouchableHighlight
  165. style={styles.input}>
  166. <DatePickerIOS
  167. date={this.state.chosenDate}
  168. onDateChange={this.setDate}
  169. mode='date'
  170. />
  171. </TouchableHighlight>
  172. </View>
  173. }
  174. <View style = {{justifyContent: "center",
  175. alignItems: "center",}}>
  176. <TouchableHighlight
  177. style = {styles.buttonContinue}
  178. onPress={() => {this.props.navigation.navigate('signuptwo', {
  179. firstName: this.state.firstName,
  180. lastName: this.state.lastName,
  181. email: this.state.email,
  182. phoneNumber: this.state.phoneNumber,
  183. spinnerText: this.state.spinnerText,})}}
  184. underlayColor={'#9fafb7'}
  185. >
  186. <Text style ={{color:'white',
  187. fontSize: 19,
  188. }}>CONTINUE</Text>
  189. </TouchableHighlight>
  190. </View>
  191. </View>
  192. </View>
  193. </ScrollView>
  194. );
  195. }
  196. }
Add Comment
Please, Sign In to add comment