Guest User

Untitled

a guest
Feb 4th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. class App extends Component {
  2.  
  3. render(){
  4. const MainNavigator = TabNavigator({
  5. login: { screen : LoginForm },
  6. register: { screen : RegisterForm },
  7.  
  8. },
  9. {
  10. tabBarPosition: 'bottom',
  11. animationEnabled: true,
  12. color:"#aa4a00",
  13. tabBarOptions: {
  14. labelStyle: {
  15. fontSize: 15,
  16. fontFamily: 'HelveticaNeueBd',
  17. color: '#4B4C4B',
  18. backgroundColor: '#ffffff'
  19. },
  20. indicatorStyle : {
  21. backgroundColor: '#aa4a00'
  22. },
  23. style : {
  24. borderBottomColor: '#ebcccc',
  25. // borderBottomWidth: 10,
  26. },
  27. tabStyle: {
  28. activeBackgroundColor : "#aa4a00",
  29. inactiveBackgroundColor: '#dddddd',
  30. upperCaseLabel: false
  31. }
  32. }
  33. });
  34.  
  35. return (
  36.  
  37. <View style={{flex: 1}}>
  38. <MainNavigator />
  39. </View>
  40.  
  41. );
  42. }
  43. renderContent(){
  44. if(!this.state.initialRoute){
  45. return <Splash />
  46. }
  47. return(
  48. <Navigator
  49. initialRoute={this.state.initialRoute}
  50. initialRouteStack={routeStack}
  51. configureScene={() => Navigator.SceneConfigs.HorizontalSwipeJump}
  52. onWillFocus={route => store.dispatch(routeHistoryActions.push(route))}
  53. renderScene={(route, navigator) =>
  54. <route.component route={route} navigator={navigator} {...route.passProps} />
  55. }
  56. />
  57. );
  58. }
  59.  
  60. }
  61. export default App;
  62.  
  63. class LoginForm extends Component {
  64. constructor(props) {
  65. super(props);
  66.  
  67. this.initialState = {
  68. isLoading: false,
  69. error: null,
  70. username: '',
  71. password: '',
  72. };
  73. this.state = this.initialState;
  74. }
  75. componentWillMount(){
  76. fetch('https://www.mywebsite.com',{
  77. method: 'POST',
  78. headers:{
  79. 'Content-Type' : 'application/json',
  80. },
  81. body: JSON.stringify({
  82. grant_type: 'authorization_code',
  83. username: this.state.username,
  84. password: this.state.password,
  85. client_id: 'xxxxx',
  86. client_secret: 'xxxx',
  87. callback_url: 'www.mywebsite.com'
  88. })
  89.  
  90. })
  91. .then(response => response.json())
  92. .then((responseData) => {
  93.  
  94. console.log(responseData);
  95. })
  96. .done();
  97. }
  98. render(){
  99. return(
  100.  
  101. <Container>
  102. <View style={styles.container}>
  103. <View style={styles.div}>
  104. <Image source={require('../Images/logo.png')} style={{ marginTop:30}} />
  105. </View>
  106. <View style={styles.content}>
  107. <InputGroup style={styles.input}>
  108. <Input
  109. label="Email"
  110. placeholder="email@gmail.com" />
  111. <Image source={require('../Images/envelope.png')} style={{width:30, height:30, marginRight:5}} />
  112. </InputGroup>
  113. <InputGroup style={styles.input}>
  114.  
  115. <Input
  116. label="Password"
  117. placeholder="Password"
  118. secureTextEntry />
  119. <Image source={require('../Images/lock.png')} style={{width:30, height:30, marginRight:5}} />
  120.  
  121. </InputGroup>
  122.  
  123. <Button style={styles.button} onPress={() => this.props.navigation.navigate("HomeScreen")} >
  124. <Text style={{paddingLeft:50}}>Login</Text>
  125. </Button>
  126. </View>
  127. </View>
  128. </Container>
  129.  
  130. );
  131. }
  132. }
  133.  
  134. const StackScreens = StackNavigator({
  135. LoginScreen: {screen : LoginScreen},
  136. Home: {screen: HomeScreen},
  137. CourseListing:{screen: CourseListing},
  138. CategoryDetail: {screen: CategoryDetail},
  139. DetailedView: {screen: DetailedView},
  140. IndividualSection: {screen: IndividualSection}
  141. })
  142.  
  143. export const MyDrawer = DrawerNavigator({
  144. Home: {
  145. screen: StackScreens,
  146. },
  147. Profile: {
  148. screen: Profile
  149. },
  150. FAQ: {
  151. screen: Faq
  152. }
  153.  
  154. class MyHome extends Component {
  155.  
  156.  
  157. render(){
  158. return(
  159.  
  160. <MyDrawer />
  161. );
  162. }
  163.  
  164. }
  165. export default MyHome;
Add Comment
Please, Sign In to add comment