-
Notifications
You must be signed in to change notification settings - Fork 51
/
App.tsx
74 lines (65 loc) · 2.25 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
// Set up an PRNG for nacl with expo-crypto
import nacl from 'tweetnacl';
import { getRandomBytes } from 'expo-crypto'
nacl.setPRNG((x, n) => {
// Get n random bytes from expo-crypto
const randomBytes = getRandomBytes(n);
// Copy the random bytes into x
x.set(randomBytes);
});
// Navigation
import 'react-native-gesture-handler';
// App
import * as React from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, TextInput, Appearance, Platform } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { SafeAreaProvider, initialWindowMetrics } from 'react-native-safe-area-context';
import { Root } from './app/Root';
import * as SplashScreen from 'expo-splash-screen';
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
import { getThemeStyleState } from './app/engine/state/theme';
import { AndroidAppearance } from './app/modules/AndroidAppearance';
const style = getThemeStyleState();
const scheme = Platform.OS === 'android'? AndroidAppearance.getColorScheme() : Appearance.getColorScheme();
const isDark = style === 'dark' || (style === 'system' && scheme === 'dark');
// Note that it is a bad practice to disable font scaling globally.
// TODO: extend Text and TextInput components to support or lock font scaling.
if (!(Text as any).defaultProps) {
(Text as any).defaultProps = {};
(Text as any).defaultProps.allowFontScaling = false;
}
if (!(TextInput as any).defaultProps) {
(TextInput as any).defaultProps = {};
(TextInput as any).defaultProps.allowFontScaling = false;
}
SplashScreen.preventAutoHideAsync();
function Boot() {
return (
<>
<StatusBar style={isDark ? 'light' : 'dark'} />
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<GestureHandlerRootView style={styles.container}>
<ActionSheetProvider>
<Root />
</ActionSheetProvider>
</GestureHandlerRootView>
</SafeAreaProvider>
</>
)
}
export default function App() {
return (
<Boot />
);
}
const styles = StyleSheet.create({
container: {
flexGrow: 1,
flexShrink: 1,
flexDirection: 'column',
backgroundColor: isDark ? '#1C1C1E' : 'white',
alignItems: 'stretch',
justifyContent: 'center',
},
});