-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
102 lines (90 loc) · 2.8 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
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
import { Ionicons } from '@expo/vector-icons'
import AsyncStorage from '@react-native-async-storage/async-storage'
import * as Font from 'expo-font'
import { StatusBar } from 'expo-status-bar'
import { Root } from 'native-base'
import React, { useState, useLayoutEffect } from 'react'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import * as ScreenOrientation from 'expo-screen-orientation'
import * as Sentry from 'sentry-expo';
import JsonContext from './context'
import useCachedResources from './hooks/useCachedResources'
import useColorScheme from './hooks/useColorScheme'
import Navigation from './navigation'
Sentry.init({
dsn: 'https://[email protected]/5672182',
enableInExpoDevelopment: true,
debug: true, // Sentry will try to print out useful debugging information if something goes wrong with sending an event. Set this to `false` in production.
});
export default function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
const [json, setJson] = useState({});
const [selectedCellIndex, setSelectedCellIndex] = useState(0);
const updateSelectedCellIndex = (index) => {
// console.log(index)
setSelectedCellIndex(index);
};
const updateJson = async (val) => {
setJson(val);
await AsyncStorage.setItem('json', JSON.stringify(val));
// console.log(val)
};
const lockOrientation = async () => {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP);
};
useLayoutEffect(() => {
const loadFonts = async () => {
await Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
});
};
const retrieveData = async () => {
let value = await AsyncStorage.getItem('json');
if (value === null) {
value = {
info: {
firstName: '',
lastName: '',
cellPhone: '',
email: '',
job: '',
company: '',
website: '',
},
qrcode: '',
};
updateJson(value);
}
else{
updateJson(JSON.parse(value));;
}
};
lockOrientation();
loadFonts();
retrieveData();
}, []);
// console.log(json)
// if (!isLoadingComplete) {
// return null;
// } else {
return (
<SafeAreaProvider style={{ backgroundColor: '#000' }}>
<Root style={{ backgroundColor: '#000' }}>
<JsonContext.Provider
value={{
json,
updateJson,
selectedCellIndex,
setSelectedCellIndex: updateSelectedCellIndex,
}}
>
<Navigation colorScheme={colorScheme} />
</JsonContext.Provider>
</Root>
</SafeAreaProvider>
);
// }
}