-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.tsx
118 lines (107 loc) · 2.95 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
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
import React, {useCallback, useEffect, useMemo} from 'react';
import {NavigationContainer, DefaultTheme} from '@react-navigation/native';
import {Alert, Platform, StatusBar, StyleSheet, View} from 'react-native';
import {Provider, useSelector} from 'react-redux';
import RNBootSplash from 'react-native-bootsplash';
import {PactProvider} from './src/contexts/Pact';
import AppStack from './src/navigation/AppStack';
import {makeSelectIsAuthorized} from './src/store/auth/selectors';
import {persistor, store} from './src/store/store';
import {PersistGate} from 'redux-persist/integration/react';
import Toast from 'react-native-toast-message';
import LogoSvg from './src/assets/images/logo.svg';
import JailMonkey from 'jail-monkey';
import {WalletConnectProvider} from './src/contexts/WalletConnect';
import {useWalletConnect} from './src/utils/walletConnect';
const App = () => {
const isAuthorized = useSelector(makeSelectIsAuthorized);
const onReady = useCallback(() => {
RNBootSplash.hide({fade: true});
}, []);
const statusBarStyle = useMemo(
() =>
Platform.OS === 'ios'
? !isAuthorized
? 'light-content'
: 'dark-content'
: 'light-content',
[isAuthorized],
);
const statusBarColor = useMemo(
() => (Platform.OS === 'ios' ? 'transparent' : 'black'),
[],
);
const appTheme = useMemo(
() => ({
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: isAuthorized ? '#f9f9fe' : 'black',
},
}),
[isAuthorized],
);
useEffect(() => {
if (JailMonkey.isJailBroken()) {
RNBootSplash.hide({fade: true});
Alert.alert(
'Device is rooted',
'Jail-broken or rooted devices can not use eckoWALLET',
undefined,
{cancelable: false},
);
}
}, []);
const walletConnectModal = useWalletConnect();
if (JailMonkey.isJailBroken()) {
return (
<>
<StatusBar
barStyle={statusBarStyle}
backgroundColor={statusBarColor}
translucent={true}
/>
<View style={styles.screen}>
<LogoSvg />
</View>
</>
);
}
return (
<>
<StatusBar
barStyle={statusBarStyle}
backgroundColor={statusBarColor}
translucent={true}
/>
<NavigationContainer onReady={onReady} theme={appTheme}>
<AppStack />
</NavigationContainer>
{walletConnectModal}
<Toast />
</>
);
};
const AppContainer = () => {
return (
<Provider store={store}>
<PactProvider>
<WalletConnectProvider>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</WalletConnectProvider>
</PactProvider>
</Provider>
);
};
const styles = StyleSheet.create({
screen: {
flex: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#000000',
},
});
export default AppContainer;