Created
January 9, 2019 19:08
-
-
Save youneshenniwrites/fdc25cf264f7d798b9822527ceb2a76c to your computer and use it in GitHub Desktop.
root component for the RNAuthAWS app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native' | |
import { | |
createSwitchNavigator, | |
createStackNavigator , | |
createDrawerNavigator, | |
createBottomTabNavigator | |
} from 'react-navigation' | |
import { Icon } from 'native-base' | |
// Auth stack screen imports | |
import AuthLoadingScreen from './src/components/screens/AuthLoadingScreen' | |
import WelcomeScreen from './src/components/screens/WelcomeScreen' | |
import SignUpScreen from './src/components/screens/SignUpScreen' | |
import SignInScreen from './src/components/screens/SignInScreen' | |
import ForgetPasswordScreen from './src/components/screens/ForgetPasswordScreen' | |
// App stack screen imports | |
import HomeScreen from './src/components/screens/HomeScreen' | |
import SettingsScreen from './src/components/screens/SettingsScreen' | |
import ProfileScreen from './src/components/screens/ProfileScreen' | |
// Bottom Auth tabs | |
const AppTabNavigator = createBottomTabNavigator({ | |
Home: { | |
screen: HomeScreen | |
}, | |
Profile: { | |
screen: ProfileScreen | |
}, | |
Settings: { | |
screen: SettingsScreen | |
} | |
}) | |
const AppStackNavigator = createStackNavigator({ | |
AppTabNavigator: { | |
screen: AppTabNavigator, | |
// Set the header icon | |
navigationOptions: ({navigation}) => ({ | |
headerLeft: ( | |
<TouchableOpacity onPress={() => navigation.toggleDrawer()}> | |
<View style={{paddingHorizontal: 10}}> | |
<Icon name='md-menu' size={24}/> | |
</View> | |
</TouchableOpacity> | |
) | |
}) | |
} | |
}) | |
// App stack for the drawer | |
const AppDrawerNavigator = createDrawerNavigator({ | |
Tabs: AppStackNavigator, // defined above | |
Home: HomeScreen, | |
Profile: ProfileScreen, | |
Settings: SettingsScreen | |
}) | |
// Auth stack | |
const AuthStackNavigator = createStackNavigator({ | |
Welcome: { | |
screen: WelcomeScreen, | |
navigationOptions: () => ({ | |
title: `Welcome to this App`, // for the header screen | |
headerBackTitle: 'Back' | |
}), | |
}, | |
SignUp: { | |
screen: SignUpScreen, | |
navigationOptions: () => ({ | |
title: `Create a new account`, | |
}), | |
}, | |
SignIn: { | |
screen: SignInScreen, | |
navigationOptions: () => ({ | |
title: `Log in to your account`, | |
}), | |
}, | |
ForgetPassword: { | |
screen: ForgetPasswordScreen, | |
navigationOptions: () => ({ | |
title: `Create a new password`, | |
}), | |
}, | |
}) | |
export default createSwitchNavigator({ | |
Authloading: AuthLoadingScreen, | |
Auth: AuthStackNavigator, // the Auth stack | |
App: AppDrawerNavigator, // the App stack | |
}) | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment