-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
112 lines (99 loc) · 2.68 KB
/
Copy pathApp.js
File metadata and controls
112 lines (99 loc) · 2.68 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
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
import React from 'react';
import { StyleSheet, Text, View,Platform,StatusBar } from 'react-native';
import {createBottomTabNavigator, createStackNavigator} from 'react-navigation'
import {FontAwesome, Ionicons} from '@expo/vector-icons'
import {Constants} from 'expo'
import {NewDeck} from './components/NewDeck'
import {DeckList} from './components/DeckList'
import {DeckView} from './components/DeckView'
import {AddCard} from './components/AddCard'
import {Quiz} from './components/Quiz'
import {blue,white} from './utils/colors'
import {FlashcardStatusBar } from './components/FlashcardStatusBar'
import {initDataStore} from './utils/storage'
import { setLocalNotification } from './utils/helpers'
const MainNavigator = createStackNavigator({
Home : {
screen: DeckList,
},
NewDeck: {
screen: NewDeck,
navigationOptions: {
headerTintColor: white,
headerStyle: {
backgroundColor: blue
}
}
},
DeckView: {
screen: DeckView,
navigationOptions: {
headerTintColor: white,
headerStyle: {
backgroundColor: blue
}
}
},
AddCard: {
screen: AddCard,
navigationOptions: {
headerTintColor: white,
headerStyle: {
backgroundColor: blue
}
}
},
Quiz: {
screen: Quiz,
navigationOptions: {
headerTintColor: white,
headerStyle: {
backgroundColor: blue
}
}
}},
{
//headerMode: 'none',
navigationOptions: {
headerStyle: {height: 0}
},
})
//https://medium.com/handlebar-labs/replace-a-screen-using-react-navigation-a503eab207eb
const prevGetStateForActionHomeStack = MainNavigator.router.getStateForAction;
MainNavigator.router.getStateForAction = (action, state) => {
if (state && action.type === 'ReplaceCurrentScreen') {
const routes = state.routes.slice(0, state.routes.length - 1);
routes.push(action);
return {
...state,
routes,
index: routes.length - 1,
};
}
return prevGetStateForActionHomeStack(action, state);
}
export default class App extends React.Component {
state = {
data : null
}
dataChanged = (data)=>{
console.log("dataChanged")
console.log(data)
this.setState({data:data})
}
componentDidMount(){
initDataStore(this.dataChanged)
setLocalNotification()
}
render() {
console.log("render called in App")
//https://github.com/react-navigation/react-navigation/issues/577
const stateClone = Object.assign({}, this.state.data);
return (
<View style={{flex:1}}>
<FlashcardStatusBar backgroundColor={blue} barStyle='light-content' />
<MainNavigator screenProps={stateClone}/>
</View>
)
}
}