-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
141 lines (130 loc) · 3.52 KB
/
App.js
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
|--------------------------------------------------
| Entry point for the app
| Contains routing and config for react-navigation
| Provider wraps around Navigator to enable state management by unstated
|--------------------------------------------------
*/
import React from "react";
import { Dimensions } from "react-native";
import { Provider } from "unstated";
import {
createStackNavigator,
createBottomTabNavigator
} from "react-navigation";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import PostScreen from "./src/screens/PostScreen";
import AlbumScreen from "./src/screens/AlbumScreen";
import TaskScreen from "./src/screens/TaskScreen";
import FriendScreen from "./src/screens/FriendScreen";
import ProfileScreen from "./src/screens/ProfileScreen";
import theme from "./src/styles/theme";
import FriendStore from "./src/stores/FriendStore";
import PostDetailScreen from "./src/screens/PostDetailScreen";
import AlbumDetailScreen from "./src/screens/AlbumDetailScreen";
import FriendDetailScreen from "./src/screens/FriendDetailScreen";
const { height, width } = Dimensions.get("window");
global.screenHeight = height;
global.screenWidth = width;
// Mapping for icons to use corresponding to certain routes
const bottomNavIconMap = {
Posts: "message-outline",
Albums: "image-multiple",
Tasks: "checkbox-marked-outline",
Friends: "account-multiple",
Profile: "account"
};
// Setup for bottom tab navigation
const BottomTabNav = createBottomTabNavigator(
{
Posts: {
screen: PostScreen
},
Albums: {
screen: AlbumScreen
},
Tasks: {
screen: TaskScreen
},
Friends: {
screen: FriendScreen
},
Profile: {
screen: ProfileScreen
}
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
// Determines which icon to show and what color it is
const { routeName } = navigation.state;
const iconName = bottomNavIconMap[routeName];
return (
<Icon
name={iconName}
color={tintColor}
size={25}
style={{ marginTop: 5 }}
/>
);
}
}),
tabBarOptions: {
activeTintColor: "black",
inactiveTintColor: "gray",
activeBackgroundColor: theme.SECONDARY_COLOR,
inactiveBackgroundColor: theme.SECONDARY_COLOR,
labelStyle: {
marginBottom: 5
}
}
}
);
const topNavBarStyle = {
headerTintColor: theme.PRIMARY_COLOR,
headerStyle: {
backgroundColor: theme.SECONDARY_COLOR,
borderBottomColor: theme.SECONDARY_COLOR
}
}
// Setup for App-wide top-level navigation
const AppNavigator = createStackNavigator({
Main: {
screen: BottomTabNav,
navigationOptions: ({ navigation }) => ({ header: null })
},
PostDetail: {
screen: PostDetailScreen,
navigationOptions: ({ navigation }) => ({
title: "Post Detail",
...topNavBarStyle
})
},
AlbumDetail: {
screen: AlbumDetailScreen,
navigationOptions: ({ navigation }) => ({
title: "Album Detail",
...topNavBarStyle
})
},
FriendDetail: {
screen: FriendDetailScreen,
navigationOptions: ({ navigation }) => ({
title: "Friend Detail",
...topNavBarStyle
})
}
});
export default class App extends React.Component {
componentDidMount() {
// Downloads the user list so it can be used throughout the app
FriendStore.initializeFriendList();
}
render() {
return (
<Provider>
<AppNavigator />
</Provider>
);
}
}