forked from Wallet3/Wallet3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
159 lines (141 loc) · 6.29 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// @ts-nocheck
import * as SplashScreen from 'expo-splash-screen';
import AppViewModel, { AppVM } from './viewmodels/core/App';
import AuthViewModel, { Authentication } from './viewmodels/auth/Authentication';
import Modals, { FullScreenQRScanner, LockScreen } from './screens/Modalize';
import { TouchableOpacity, UIManager } from 'react-native';
import { About } from './screens/settings/About';
import AddToken from './screens/tokens/AddToken';
import Backup from './screens/settings/Backup';
import ChangePasscode from './screens/settings/ChangePasscode';
import Currencies from './screens/settings/Currencies';
import FlashMessage from 'react-native-flash-message';
import { Host } from 'react-native-portalize';
import { Ionicons } from '@expo/vector-icons';
import LandScreen from './screens/land';
import Languages from './screens/settings/Languages';
import NFTDetails from './screens/nfts/Details';
import { NavigationContainer } from '@react-navigation/native';
import ProfileScreen from './screens/profile';
import React from 'react';
import Root from './screens/Root';
import { StatusBar } from 'expo-status-bar';
import Theme from './viewmodels/settings/Theme';
import Themes from './screens/settings/Themes';
import Tokens from './screens/tokens/SortTokens';
import VerifySecret from './screens/settings/VerifySecret';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import i18n from './i18n';
import { logScreenView } from './viewmodels/services/Analytics';
import { observer } from 'mobx-react-lite';
import { useFonts } from 'expo-font';
SplashScreen.hideAsync();
AppViewModel.init();
UIManager.setLayoutAnimationEnabledExperimental?.(true);
const StackRoot = createNativeStackNavigator();
const App = observer(({ app, appAuth }: { app: AppVM; appAuth: Authentication }) => {
const { Navigator, Screen } = StackRoot;
const { t } = i18n;
const { backgroundColor, foregroundColor, statusBarStyle } = Theme;
const routeNameRef = React.useRef();
const navigationRef = React.useRef();
const [loaded] = useFonts({
Questrial: require('./assets/fonts/Questrial.ttf'),
});
if (!loaded) {
return null;
}
return (
<NavigationContainer
ref={navigationRef}
onReady={() => (routeNameRef.current = navigationRef.current?.getCurrentRoute()?.name)}
onStateChange={async () => {
if (__DEV__) return;
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.current.getCurrentRoute()?.name;
if (previousRouteName && previousRouteName !== currentRouteName) {
await logScreenView(currentRouteName);
}
routeNameRef.current = currentRouteName;
}}
>
<Host style={{ backgroundColor: backgroundColor }}>
{app.initialized ? (
app.hasWallet ? (
<Navigator
initialRouteName="Root"
screenOptions={({ navigation }) => {
return {
headerTransparent: true,
headerTintColor: foregroundColor,
contentStyle: { backgroundColor },
headerLeft: () => (
<TouchableOpacity onPress={() => navigation.pop()} style={{ margin: -12, padding: 12, zIndex: 99 }}>
<Ionicons name="arrow-back-outline" size={20} color={foregroundColor} />
</TouchableOpacity>
),
};
}}
>
<Screen name="Root" component={Root} options={{ headerShown: false }} />
<Screen name="Languages" component={Languages} options={{ title: t('settings-languages') }} />
<Screen name="Currencies" component={Currencies} options={{ title: t('settings-currencies') }} />
<Screen name="Themes" component={Themes} options={{ title: t('settings-themes') }} />
<Screen name="ChangePasscode" component={ChangePasscode} options={{ title: t('settings-security-passcode') }} />
<Screen name="Backup" component={Backup} options={{ title: t('settings-security-backup') }} />
<Screen name="VerifySecret" component={VerifySecret} options={{ title: t('settings-security-backup-verify') }} />
<Screen name="AddToken" component={AddToken} options={{ title: t('home-add-token-title') }} />
<Screen name="About" component={About} options={{ title: t('about-title') }} />
<Screen
name="Profile"
component={ProfileScreen}
options={({ navigation }) => {
return {
headerTransparent: true,
title: '',
headerLeft: () => (
<TouchableOpacity onPress={() => navigation.pop()} style={{ margin: -12, padding: 12, zIndex: 99 }}>
<Ionicons name="arrow-back-outline" size={20} color="#fff" />
</TouchableOpacity>
),
};
}}
/>
<Screen
name="Tokens"
component={Tokens}
options={({ navigation }) => {
return {
title: t('home-tokens-title'),
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('AddToken')} style={{ margin: -8, padding: 8 }}>
<Ionicons name="add-circle-outline" size={25} color={foregroundColor} />
</TouchableOpacity>
),
};
}}
/>
<Screen
name="NFTDetails"
component={NFTDetails}
options={() => {
return { headerShown: false };
}}
/>
</Navigator>
) : (
<Navigator>
<Screen name="Land" component={LandScreen} options={{ headerShown: false }} />
</Navigator>
)
) : undefined}
</Host>
{Modals({ app, appAuth })}
<FlashMessage position="top" />
<StatusBar style={statusBarStyle} />
<FullScreenQRScanner />
<LockScreen app={app} appAuth={appAuth} />
</NavigationContainer>
);
});
export default () => <App app={AppViewModel} appAuth={AuthViewModel} />;