-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
88 lines (70 loc) · 2.2 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
import { StripeProvider, useStripe } from '@stripe/stripe-react-native';
import { NavigationContainer, DefaultTheme } from "@react-navigation/native";
import { useFonts } from "expo-font";
import { useState, useEffect } from "react";
import { View, Text, ActivityIndicator } from 'react-native';
import axios from "axios";
import TabNavigator from './src/components/navigators/TabNavigator';
import ProductState from "./src/context/product/ProductState";
import AuthState from './src/context/auth/AuthState';
import UserState from './src/context/user/UserState';
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: "transparent",
},
};
const App = () => {
const [fontsLoaded] = useFonts({
"InterBold": require("./assets/fonts/Inter-Bold.ttf"),
"InterSemiBold": require("./assets/fonts/Inter-SemiBold.ttf"),
"InterMedium": require("./assets/fonts/Inter-Medium.ttf"),
"InterRegular": require("./assets/fonts/Inter-Regular.ttf"),
"InterLight": require("./assets/fonts/Inter-Light.ttf"),
});
const [publishableKey, setPublishableKey] = useState('')
useEffect(() => {
const getPublishabkeKey = async () => {
try {
const res = await axios.post('http://10.4.112.184:4420/api/payment/checkout/session')
const { publishableKey } = await res.data;
setPublishableKey(publishableKey)
} catch (error) {
console.log(error)
}
}
getPublishabkeKey()
console.log(publishableKey)
}, [])
if (!fontsLoaded) {
return <AppLoading />;
}
if (!publishableKey) {
return <AppLoading />;
}
return (
<StripeProvider
publishableKey={publishableKey}
>
<NavigationContainer>
<UserState>
<AuthState>
<ProductState>
<TabNavigator />
</ProductState>
</AuthState>
</UserState>
</NavigationContainer>
</StripeProvider>
);
}
const AppLoading = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" color="#0000ff" />
<Text style={{ marginTop: 10, fontSize: 18 }}>Loading...</Text>
</View>
);
};
export default App