Guest User

Untitled

a guest
Jun 20th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. 'use strict';
  2.  
  3. import moment from 'moment';
  4. import React from 'react';
  5. import { StackNavigator } from 'react-navigation';
  6. import { Text, Button, View, StatusBar, Image } from 'react-native';
  7. import { GiftedForm, GiftedFormManager } from 'react-native-gifted-form';
  8. import { Actions } from 'react-native-router-flux';
  9. import styles from './styles';
  10. const logo = require('../../../../assets/img/logo/logo.png')
  11.  
  12. class MyModal extends React.Component {
  13. static navigationOptions = ({ navigation }) => {
  14. return {
  15. title: navigation.getParam('getTitle')(),
  16. headerLeft: (
  17. <Button
  18. onPress={() => {
  19. navigation.getParam('onClose')(null, navigation);
  20. }}
  21. title='Voltar'
  22. />
  23. ),
  24. headerRight: (
  25. <Button
  26. onPress={() => {
  27. navigation.getParam('onClose')(null, navigation);
  28. }}
  29. title='Confirmar'
  30. />
  31. )
  32. };
  33. };
  34.  
  35. render() {
  36. return this.props.navigation.getParam('renderScene')();
  37. }
  38. }
  39.  
  40. class Login extends React.Component {
  41.  
  42. static navigationOptions = {
  43. // title: 'logao',
  44. headerStyle: {
  45. backgroundColor: '#e40f00',
  46. borderBottomColor: 'transparent',
  47. },
  48. headerTintColor: '#000',
  49. headerTitleStyle: {
  50. fontWeight: 'bold',
  51. },
  52. };
  53. constructor(props) {
  54. super(props);
  55. this.state = { lastSubmitValues: '' };
  56. }
  57. render() {
  58. return (
  59.  
  60. <View style={styles.bg}>
  61. <StatusBar
  62. barStyle="light-content"
  63. />
  64. <View style={styles.loginCotainer}>
  65.  
  66. <View style={styles.logo}>
  67. <Image source={logo} style={styles.logoImage} />
  68. </View>
  69.  
  70. <GiftedForm
  71. formName='signupForm' // GiftedForm instances that use the same name will also share the same states
  72. openModal={route => {
  73. this.props.navigation.push('MyModal', route); // The ModalWidget will be opened using this method. Tested with ExNavigator
  74. }}
  75. clearOnClose={false} // delete the values of the form when unmounted
  76. defaults={{
  77. username: 'Farid',
  78. 'gender{}': false,
  79. password: 'abcdefg',
  80. country: 'FR',
  81. }}
  82. style={styles.loginCotainer}>
  83. <GiftedForm.SeparatorWidget />
  84.  
  85. <GiftedForm.TextInputWidget
  86. name='fullName' // mandatory
  87. title='Usuario'
  88. placeholder='username'
  89. clearButtonMode='while-editing'
  90. image={require('../../../../assets/img/icons/user.png')}
  91.  
  92.  
  93. />
  94.  
  95. <GiftedForm.ModalWidget
  96. title='Centro de custo'
  97. displayValue='gender'
  98. image={require('../../../../assets/img/icons/cc.png')}
  99.  
  100. >
  101. <GiftedForm.SeparatorWidget />
  102.  
  103. <GiftedForm.SelectWidget
  104. name='gender'
  105. title='Centro de custo'
  106. multiple={false}
  107. >
  108. <GiftedForm.OptionWidget
  109. title='30001 - TI'
  110. value='30001 - TI'
  111. image={require('../../../../assets/img/icons/ti.png')}
  112. />
  113. <GiftedForm.OptionWidget
  114. title='30002 - TO'
  115. value='30002 - TO'
  116. image={require('../../../../assets/img/icons/rocket.png')}
  117. />
  118. <GiftedForm.OptionWidget
  119. title='30003 - TU'
  120. value='30003 - TU'
  121. image={require('../../../../assets/img/icons/rocket.png')}
  122. />
  123. </GiftedForm.SelectWidget>
  124. </GiftedForm.ModalWidget>
  125.  
  126. <GiftedForm.ErrorsWidget />
  127.  
  128. <GiftedForm.SubmitWidget
  129. title='Entrar'
  130. widgetStyles={{
  131. submitButton: {
  132. backgroundColor: '#2185D0'
  133. }
  134. }}
  135. onSubmit={
  136. (
  137. isValid,
  138. values,
  139. validationResults,
  140. postSubmit = null,
  141. modalNavigator = null
  142. ) => { Actions.main() }
  143. }
  144. />
  145. </GiftedForm>
  146. </View>
  147. </View>
  148.  
  149. );
  150. }
  151. }
  152.  
  153. const RootNavigation = StackNavigator({
  154. DemoScreen: {
  155. screen: Login
  156. },
  157. MyModal: {
  158. screen: MyModal
  159. }
  160. });
  161.  
  162. const root = () => <RootNavigation />;
  163.  
  164. export default root;
Add Comment
Please, Sign In to add comment