This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
58 lines (50 loc) · 1.61 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
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import NetworkHandler from "./components/clientcalls";
import Login from "./Screens/Login";
import GenerateImg from "./Screens/GenerateImg";
import React, { useState, useRef, useContext } from "react";
export const NetworkHandlerContext = React.createContext();
export function NetworkHandlerProvider({ children }) {
const networkHandlerRef = useRef(null);
if (!networkHandlerRef.current) {
networkHandlerRef.current = new NetworkHandler();
}
return (
<NetworkHandlerContext.Provider value={networkHandlerRef}>
{children}
</NetworkHandlerContext.Provider>
);
}
function LoginScreen({ navigation }) {
const networkHandlerRef = useContext(NetworkHandlerContext);
return (
<Login networkHandlerRef1={networkHandlerRef} navigators={navigation} />
);
}
function GeneratePage({ navigation }) {
const networkHandlerRef = useContext(NetworkHandlerContext);
return (
<GenerateImg
networkHandlerRef1={networkHandlerRef}
navigators={navigation}
/>
);
}
const Stack = createNativeStackNavigator();
function App() {
return (
<NavigationContainer>
<NetworkHandlerProvider>
<Stack.Navigator
initialRouteName="Home"
screenOptions={{ headerShown: false }}
>
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Generate" component={GeneratePage} />
</Stack.Navigator>
</NetworkHandlerProvider>
</NavigationContainer>
);
}
export default App;