Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
77 lines (69 loc) · 1.89 KB
/
Copy pathApp.js
File metadata and controls
77 lines (69 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import { AsyncStorage } from 'react-native';
import { createBottomTabNavigator, createStackNavigator, createSwitchNavigator } from 'react-navigation';
import Ionicons from 'react-native-vector-icons/Ionicons';
import HomeworkView from './Components/Views/HomeworkView.js'
import SettingsView from "./Components/Views/SettingsView.js"
import CalendarView from "./Components/Views/CalendarView.js"
import WelcomeScreen from './Components/Views/WelcomeScreen.js'
import Loading from "./Components/Loading.js"
import SignInScreen from './Components/SignInScreen.js'
class LoadApp extends React.Component {
constructor(props) {
super(props);
this.load();
}
load = async () => {
const token = await AsyncStorage.getItem("token");
this.props.navigation.navigate(token ? "App" : "Auth");
}
render() { return <Loading /> }
}
const AppTab = createBottomTabNavigator(
{
Homework: {
screen: HomeworkView,
},
Calendar: {
screen: CalendarView,
},
Settings: {
screen: SettingsView
}
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Homework') {
iconName = `md-home`;
} else if (routeName === 'Calendar') {
iconName = `md-calendar`;
} else if (routeName === 'Settings') {
iconName = `md-options`;
}
// You can return any component that you like here! We usually use an
// icon component from react-native-vector-icons
return <Ionicons name={iconName} size={25} color={tintColor} />;
},
}),
tabBarPosition: 'bottom',
animationEnabled: true,
swipeEnabled: false,
}
);
const AuthStack = createStackNavigator({
Welcome: WelcomeScreen,
SignIn: SignInScreen
})
export default createSwitchNavigator(
{
LoadApp: LoadApp,
App: AppTab,
Auth: AuthStack,
},
{
initialRouteName: 'LoadApp',
}
);