-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.js
78 lines (65 loc) · 2.12 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { NavigationContainer } from '@react-navigation/native';
import { useEffect, useState } from 'react';
import RNBootSplash from "react-native-bootsplash";
import ReactNativeBiometrics from 'react-native-biometrics'
import storage from './src/ngu_modules/storage';
import Constants from './src/config/Constants';
import AppContextProvider from './src/ngu_modules/appContext';
import appLaunch from './src/class/appLaunch';
import FeedNavigator from './src/navigation/FeedNavigator';
import NavigationTheme from './src/navigation/NavigationTheme';
import OfflineNotice from './src/components/OfflineNotice';
import Localize from './src/config/Localize';
import AppAlert from './src/components/AppAlert';
export default function App() {
const [showAlert, setShowAlert] = useState(false);
const authenticateBiometricsIfAvailable = () => {
ReactNativeBiometrics.simplePrompt({ promptMessage: Localize.getLabel('confirmIdentityMessage') })
.then((resultObject) => {
const { success } = resultObject
if (success) {
// successful biometrics provided
RNBootSplash.hide();
} else {
// user cancelled biometric prompt
}
})
.catch(() => {
// biometrics failed
})
}
const validateBiometricsIfEnabled = async () => {
const status = await storage.getItem(Constants.BIOMETRICS_DISPLAY_STATUS);
if (!status) {
RNBootSplash.hide();
return;
}
if (status) {
authenticateBiometricsIfAvailable();
}
}
const onReady = () => {
if (global.useTestnet === true) {
setShowAlert(true);
}
}
useEffect(() => {
validateBiometricsIfEnabled();
appLaunch.setup();
}, [])
return (
<AppContextProvider>
<AppAlert
visible={showAlert}
isAlert={true}
title={Localize.getLabel('warning')}
message={Localize.getLabel('warningTestnetText')}
onCancel={() => setShowAlert(false)}
/>
<OfflineNotice />
<NavigationContainer onReady={onReady} theme={NavigationTheme}>
<FeedNavigator />
</NavigationContainer>
</AppContextProvider>
);
}