-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
166 lines (146 loc) · 4.16 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import React from 'react';
import { StyleSheet, Text, View,
StatusBar, Platform,
AsyncStorage,
} from 'react-native';
import { TabNavigator, StackNavigator } from 'react-navigation';
import { Constants } from 'expo';
import { Entypo } from '@expo/vector-icons';
// Components
import DeckList from './components/DeckList';
import Deck from './components/Deck';
import Quiz from './components/Quiz';
import NewDeck from './components/NewDeck';
import NewCard from './components/NewCard';
// Constants, Helpers, Api's
import { setLocalNotification } from './utils/helpers'
import { white, primaryColor } from './utils/colors';
// hide react-native deprecation warnings in emulator
import {YellowBox} from 'react-native';
console.disableYellowBox = true;
function AppStatusBar({ backgroundColor, ...props }){
// backgroundColor is blended with default OS statusBarColor;
// on ios (white statusBarColor): ==> background color
// android (gray statusBarColor ): ==> a Darker Shade of background color
return (
<View style={{
backgroundColor,
height: Constants.statusBarHeight,
}}
>
<StatusBar
translucent
backgroundColor={backgroundColor}
{...props}
/>
</View>
);
}
export default class App extends React.Component {
componentDidMount() {
setLocalNotification();
}
render(){
return (
<View style={{flex:1}}>
<AppStatusBar
backgroundColor={primaryColor}
barStyle="light-content"
/>
<MainNavigation />
</View>
);
}
}
const Tabs = TabNavigator(
// this first argument defines the tabs; First Tab Gets auto loaded/selected
{
DeckList: {
screen: DeckList,
navigationOptions: {
tabBarLabel: 'Deck List',
tabBarIcon: ({ tintColor }) => // icons only show in ios
<Entypo name='list' size={30} color={tintColor} />
},
},
NewDeck: {
screen: NewDeck,
navigationOptions: {
tabBarLabel: 'Create New Deck',
tabBarIcon: ({ tintColor }) => // icons only show in ios
<Entypo name='add-to-list' size={30} color={tintColor} />
},
},
},
// this second argument sets the various options
{
navigationOptions: {
// do-not-display page headers for Tab Navigation
header: null
},
tabBarOptions: {
// ios icon and text color; android text color
activeTintColor: Platform.OS === 'ios' ? primaryColor : white,
// no effect on ios; on android this color blends with tab color
pressColor: white,
// little underline thingy on selected tab in android
indicatorStyle: {
backgroundColor: white, //primaryColor,//primaryColorDark, // default is yellow
// height: 3, // defaults to 2
},
style: {
height: 56,
// color for (selected AND not selected) tabs
backgroundColor: Platform.OS === 'ios' ? white : primaryColor,
shadowColor: 'rgba(0, 0, 0, 0.24)',
shadowOffset: {
width: 0,
height: Platform.OS === 'ios' ? 3 : 0,
},
shadowRadius: Platform.OS === 'ios' ? 6 : 0,
shadowOpacity: 1,
}
}
}
);
const stackScreenNavigationOptions = {
// color of the "back" arrow
headerTintColor: white,
headerStyle: {
// background color for the header
backgroundColor: primaryColor,
}
};
// creates a component
const MainNavigation = StackNavigator(
// RouteConfigs: This is analogous to defining Routes in a web app
{
Home: {
screen: Tabs, // Which also loads the first Tab (DeckList)
},
Deck: {
screen: Deck,
navigationOptions: stackScreenNavigationOptions,
},
Quiz: {
screen: Quiz,
navigationOptions: stackScreenNavigationOptions,
},
NewDeck: {
screen: NewDeck,
navigationOptions: stackScreenNavigationOptions,
},
NewCard: {
screen: NewCard,
navigationOptions: stackScreenNavigationOptions,
},
},
);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: white,
alignItems: 'center',
justifyContent: 'center',
},
});