-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
86 lines (77 loc) · 2.09 KB
/
App.tsx
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
import 'react-native-gesture-handler'
import * as Font from 'expo-font'
import * as React from 'react'
import { AppContext, AppState, State } from './AppContext'
import { DefaultTheme, ThemeProvider, configureFonts } from 'react-native-paper'
import Colors from './Colors'
import { Font as FontType } from 'react-native-paper/lib/typescript/types'
import { NavigationContainer } from '@react-navigation/native'
import RootNavigator from './navigators/RootNavigator'
const defaultFont: FontType = {
fontFamily: 'OpenSans-Regular',
fontWeight: 'normal',
}
export default class App extends React.Component<{}, AppState> {
state = State
login = (email: string, password: string) => {
this.setState({
logged: true,
profile: {
email,
username: 'User',
},
})
}
register = (email: string, password: string, username: string) => {
this.setState({
logged: true,
profile: {
email,
username,
},
})
}
componentDidMount = async () => {
await Font.loadAsync({
'OpenSans-Regular': {
uri: require('./assets/fonts/OpenSans-Regular.ttf'),
display: Font.FontDisplay.FALLBACK,
},
'OpenSans-Bold': {
uri: require('./assets/fonts/OpenSans-Bold.ttf'),
display: Font.FontDisplay.FALLBACK,
},
})
this.setState({ loading: false })
}
render = () => {
if (this.state.loading) return null
return (
<AppContext.Provider value={{
...this.state,
login: this.login,
}}>
<ThemeProvider theme={{
...DefaultTheme,
roundness: 20,
colors: {
...DefaultTheme.colors,
accent: Colors.primary,
},
fonts: configureFonts({
default: {
light: defaultFont,
regular: defaultFont,
medium: defaultFont,
thin: defaultFont,
},
}),
}}>
<NavigationContainer>
<RootNavigator />
</NavigationContainer>
</ThemeProvider>
</AppContext.Provider>
)
}
}