-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
74 lines (67 loc) · 1.97 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
import * as React from "react";
import { useEffect } from "react";
import { View, BackHandler, Alert } from "react-native";
import "react-native-gesture-handler";
import SplashScreen from "react-native-splash-screen";
import Countries from './src/screens/countries';
import CountryLanguages from "./src/screens/country_languages";
import Home from "./src/screens/home";
import { createDrawerNavigator } from "@react-navigation/drawer";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
function HomeScreen({ navigation }) {
return (
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Countries" component={Countries} />
<Stack.Screen name="CountryLanguages" component={CountryLanguages} />
</Stack.Navigator>
);
}
function NotificationsScreen({ navigation }) {
return <View />;
}
function handleBackButton() {
Alert.alert(
"Exit App",
"Exiting the application?",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel",
},
{
text: "OK",
onPress: () => BackHandler.exitApp(),
},
],
{
cancelable: false,
}
);
BackHandler.removeEventListener("hardwareBackPress", handleBackButton);
return true;
}
const Drawer = createDrawerNavigator();
function App() {
React.useEffect(() => {
SplashScreen.hide();
BackHandler.addEventListener("hardwareBackPress", handleBackButton);
});
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="HomeScreen">
<Drawer.Screen name="HomeScreen" component={HomeScreen} />
<Drawer.Screen name="Exit" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
export default App;