-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
77 lines (69 loc) · 1.98 KB
/
App.jsx
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
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import useCachedResources from './hooks/useCachedResources';
import useColorScheme from './hooks/useColorScheme';
import Navigation from './navigation';
import * as WebBrowser from 'expo-web-browser';
import { Linking, Platform } from 'react-native';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
import { GlobalProvider } from './utils/context';
import GlobalModals from './components/GlobalModals';
async function urlOpener(url, redirectUrl) {
const { type, url: newUrl } = await WebBrowser.openAuthSessionAsync(
url,
redirectUrl
);
if (type === 'success' && Platform.OS === 'ios') {
WebBrowser.dismissBrowser();
return Linking.openURL(newUrl);
}
}
Amplify.configure({
...awsconfig,
oauth: {
...awsconfig.oauth,
urlOpener,
domain: 'auth.mealmatch.io',
},
API: {
endpoints: [
{
name: 'mealmatch-dev',
endpoint: 'https://dev.api.mealmatch.io',
},
{
name: 'mealmatch-staging',
endpoint: 'https://staging.api.mealmatch.io',
},
{
name: 'mealmatch-prod',
endpoint: 'https://prod.api.mealmatch.io',
},
],
},
Storage: {
AWSS3: {
bucket: 'mealmatch-assets',
region: 'us-east-1',
},
},
});
function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
if (!isLoadingComplete) {
return null;
}
return (
<SafeAreaProvider>
<GlobalProvider>
<Navigation colorScheme={colorScheme} />
<StatusBar />
<GlobalModals />
</GlobalProvider>
</SafeAreaProvider>
);
}
export default App;