-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.tsx
132 lines (105 loc) · 3.86 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
import {StatusBar} from 'expo-status-bar';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import useCachedResources from './hooks/useCachedResources';
import Navigation from './navigation';
import {Inter_300Light, useFonts} from "@expo-google-fonts/inter";
import CoolStorage from "./util/CoolStorage";
import EasterEggScreen from "./screens/EasterEggScreen";
import {useState} from "react";
import {Ubuntu_300Light} from "@expo-google-fonts/ubuntu";
import {Roboto_400Regular} from "@expo-google-fonts/roboto";
import {Alert, Platform, View} from "react-native";
//import * as LocalAuthentication from "expo-local-authentication";
import AsyncStorage from "@react-native-async-storage/async-storage";
// noinspection JSUnusedGlobalSymbols
export default function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = "dark";
const [easterEgg, setEasterEgg] = useState(false);
const [biometricsScoutComplete, setBiometricsScoutComplete] = useState(false);
const [scouting, setScouting] = useState(false);
let [fontsLoaded] = useFonts({
Inter_300Light,
Ubuntu_300Light,
Roboto_400Regular,
});
//biometrics
(async () => {
try {
if(scouting || biometricsScoutComplete) return;
//TODO if you know how to fix this, please do
//for some reason, android does not work with fingerprint scanners.
if(Platform.OS === "android") {
setScouting(false);
setBiometricsScoutComplete(true);
return;
}
const LocalAuthentication = require("expo-local-authentication");
setScouting(true);
const a = await AsyncStorage.getItem("@biometrics");
if(!a || a === "false") {
setBiometricsScoutComplete(true);
setScouting(false);
return;
}
if(!(await LocalAuthentication.hasHardwareAsync())) {
setBiometricsScoutComplete(true);
setScouting(false);
return;
}
if(!(await LocalAuthentication.isEnrolledAsync())) {
setBiometricsScoutComplete(true);
setScouting(false);
return;
}
const auth = await LocalAuthentication.authenticateAsync();
if(auth.success) {
setBiometricsScoutComplete(true);
} else {
Alert.alert("AnonyMail", "Please try again.", [
{
style: "default",
text: "Ok",
onPress() {
return setScouting(false);
}
}
]);
}
} catch(e) {
setScouting(false);
}
})();
setInterval(() => {
if(CoolStorage.easter_egg_time) {
setEasterEgg(true);
} else {
setEasterEgg(false);
}
}, 100);
const norm = (
<SafeAreaProvider>
<Navigation colorScheme={colorScheme}/>
<StatusBar/>
</SafeAreaProvider>
);
const egg = (
<SafeAreaProvider>
<EasterEggScreen/>
<StatusBar/>
</SafeAreaProvider>
);
if(!isLoadingComplete || !fontsLoaded || !biometricsScoutComplete) {
return (
<View style={{
backgroundColor: "#000000",
width: "100%",
height: "100%",
}}></View>
);
} else {
return (
easterEgg ? egg : norm
);
}
}