-
Notifications
You must be signed in to change notification settings - Fork 5
/
App.js
55 lines (48 loc) · 1.27 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
/**
*
* @format
* @flow
*
* This Component is used to wrap your whole Application inside a Provider of any Kind
* A Provider could be:
* - Redux State Provider
* - Unstated State Provider
* - Apollo (GraphQL) Provider
* This is the highest order component
*
* In this Case we are wrapping the WHOLE Application inside a SafeAreaView which is used
* to display our apps correctly on Notch Devices ( no clipping with NOTCH)
*/
import React from 'react';
import {
SafeAreaView,
} from 'react-native';
import AppContainer from "./App/AppContainer";
import { ThemeContext, themes } from './App/Theme/themes';
class App extends React.Component {
constructor(props) {
super(props);
this.toggleTheme = () => {
this.setState(state => ({
theme:
state.theme === themes.dark
? themes.light
: themes.dark,
}));
};
// State also contains the updater function so it will
// be passed down into the context provider
this.state = {
theme: themes.light,
toggleTheme: this.toggleTheme,
};
}
render() {
return (
<ThemeContext.Provider value={this.state}>
<AppContainer screenProps={{ theme: this.state.theme }}/>
</ThemeContext.Provider>
)
}
}
export default App;