Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. import { StackNavigator, TabNavigator } from 'react-navigation'
  2. import React from 'react'
  3. import { FontAwesome, Octicons, Foundation, Entypo} from '@expo/vector-icons';
  4.  
  5. import HomeScreen from '../screens/HomeScreen';
  6. import CareCircleScreen from '../screens/CareCircleScreen';
  7. import RootNavigation from './RootNavigation';
  8. import MoodScreen from '../screens/MoodScreen';
  9. import LoginScreen from '../screens/LoginScreen';
  10. import SettingsScreen from '../screens/SettingsScreen';
  11. import NotificationScreen from '../screens/NotificationScreen'
  12. import RegisterScreen from '../screens/RegisterScreen'
  13. import ForgotPasswordScreen from '../screens/ForgotPasswordScreen'
  14. import TermsAndConditions from '../screens/TermsAndConditions'
  15. import BoardingScreen from '../screens/BoardingScreen'
  16.  
  17. export const Stack1 = StackNavigator({
  18. Login: {
  19. screen: LoginScreen,
  20. },
  21. Register: {
  22. screen: RegisterScreen,
  23. },
  24. ForgotPassword: {
  25. screen: ForgotPasswordScreen,
  26. },
  27. });
  28.  
  29. import Expo from 'expo';
  30. import React from 'react';
  31. import { Platform, StatusBar, StyleSheet, View, Linking, TouchableHighlight, Text, AsyncStorage } from 'react-native';
  32. import { NavigationProvider, createRouter } from '@expo/ex-navigation';
  33. import { FontAwesome } from '@expo/vector-icons';
  34. import { ActionButton } from './components/ActionButton.js'
  35. import Colors from './constants/Colors.js'
  36. import { Stack1 } from './navigation/routes'
  37.  
  38. import cacheAssetsAsync from './utilities/cacheAssetsAsync';
  39. import { AlertProvider } from './components/Alert'
  40.  
  41. const Router = createRouter(() => {})
  42.  
  43. class AppContainer extends React.Component {
  44. state = {
  45. appIsReady: false,
  46. user: null,
  47. };
  48.  
  49. componentWillMount() {
  50. AsyncStorage.getItem('user_data').then((user_data_json) => {
  51. let user_data = JSON.parse(user_data_json);
  52. this.setState({
  53. user: user_data
  54. });
  55. });
  56. AsyncStorage.getItem('boarding').then((boarding) => {
  57. this.setState({
  58. boarding: boarding
  59. });
  60. });
  61. this._loadAssetsAsync();
  62. }
  63.  
  64. async _loadAssetsAsync() {
  65. try {
  66. await cacheAssetsAsync({
  67. this.setState({ appIsReady: true });
  68. }
  69. }
  70.  
  71. render() {
  72. if (this.state.appIsReady) {
  73. return (
  74. <AlertProvider>
  75. <View style={styles.container}>
  76. <NavigationProvider router={Router}>
  77. <Stack1/>
  78. </NavigationProvider>
  79. {Platform.OS === 'ios' && <StatusBar barStyle="default" />}
  80. {Platform.OS === 'android' &&
  81. <View style={styles.statusBarUnderlay} />}
  82. </View>
  83. </AlertProvider>
  84. );
  85. } else {
  86. return <Expo.AppLoading />;
  87. }
  88. }
  89. }
  90.  
  91. const styles = StyleSheet.create({
  92. container: {
  93. flex: 1,
  94. backgroundColor: '#fff',
  95. },
  96. statusBarUnderlay: {
  97. height: 24,
  98. backgroundColor: 'rgba(0,0,0,0.2)',
  99. },
  100. actionButtonIcon: {
  101. fontSize: 20,
  102. height: 22,
  103. color: 'white',
  104. },
  105. });
  106.  
  107. class LoginScreen extends React.Component {
  108. constructor(props) {
  109. super(props)
  110.  
  111. this.state = {
  112. email: null,
  113. password: null,
  114. user: this.props.user,
  115. boarding: this.props.boarding
  116. }
  117. }
  118.  
  119. static route = {
  120. navigationBar: {
  121. visible: false,
  122. },
  123. }
  124.  
  125. render(){
  126. if (this.state.boarding != null){
  127. if (this.props.user != null){
  128. return(
  129. <RootNavigation navigator= {this.props.navigator}/>
  130. )
  131. } else {
  132. return (
  133. <KeyboardAvoidingView style={styles.container} behavior='padding'>
  134. //...
  135. </KeyboardAvoidingView>
  136. )
  137. }
  138. } else {
  139. return(
  140. <BoardingScreen onDoneBtnClick={() => this._handleDoneButton()}/> )
  141. }
  142. }
  143.  
  144. }
  145.  
  146. export default connectAlert(LoginScreen)
  147.  
  148.  
  149.  
  150. Expo.registerRootComponent(AppContainer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement