-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
156 lines (144 loc) · 3.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
TouchableOpacity,
StyleSheet,
Text,
Button,
View,
onPress,
Image,
ScrollView,
BackHandler,
Alert,
DrawerLayoutAndroid
} from 'react-native';
import Component1 from './Component1';
import { useEffect, useRef, useState } from 'react';
import BasicComponent from './BasicComponent';
import Flatlistcomponent from './Flatlistcomponent';
import Datepicker from './Datepicker';
import Drawablelayout from './Drawablelayout';
import Progessbar from './Progressbar';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Homescreen from './Homescreen';
import Components from './Components';
import Progressbar from './Progressbar';
import Bottomsection from './Bottomsection';
import Othercomponents from './Othercomponents';
import BottomTabNavigator from './BottomTabNavigator';
import { Provider } from 'react-redux';
import { store } from './store';
// import Stackcomponent from './Stackcomponent';
const Stack = createNativeStackNavigator();
function App(navigation) {
useEffect(() => {
console.log("initial rendering")
}, [])
const drawer = useRef(null);
const [drawerPosition, setDrawerPosition] = useState("left");
const changeDrawerPosition = () => {
if (drawerPosition === "left") {
setDrawerPosition("right");
} else {
setDrawerPosition("left");
}
};
// useEffect(() => {
// const backAction = () => {
// Alert.alert("Hold on!", "Are you sure you want to go back?", [
// {
// text: "Cancel",
// onPress: () => null,
// style: "cancel"
// },
// { text: "YES", onPress: () => BackHandler.exitApp() }
// ]);
// return true;
// };
// const backHandler = BackHandler.addEventListener(
// "hardwareBackPress",
// backAction
// );
// return () => backHandler.remove();
// }, []);
// ------------------------------
const backActionHandler = () => {
Alert.alert("Alert!", "Are you sure you want to go back?", [
{
text: "Cancel",
onPress: () => null,
style: "cancel"
},
{
text: "YES", onPress: () => BackHandler.exitApp()
()
}
]);
return true;
};
useEffect(() => {
console.log("rendered")
// Add event listener for hardware back button press on Android
BackHandler.addEventListener("hardwareBackPress", backActionHandler);
return () =>
// clear/remove event listener
BackHandler.removeEventListener("hardwareBackPress", backActionHandler);
}, []);
// -----------------------------
const navigationView = () => (
<View style={[styles.container, styles.navigationContainer]}>
<Text style={styles.paragraph}>I'm in the Drawer!</Text>
<Button
title="Close drawer"
onPress={() => drawer.current.closeDrawer()}
/>
</View>
);
return (
<>
<Provider store={store}>
<NavigationContainer>
<BottomTabNavigator/>
</NavigationContainer>
</Provider>
</>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
padding: 16
},
navigationContainer: {
backgroundColor: "#ecf0f1"
},
paragraph: {
padding: 16,
fontSize: 15,
textAlign: "center"
}
});
export default App;
{/* <DrawerLayoutAndroid
ref={drawer}
drawerWidth={300}
drawerPosition={drawerPosition}
renderNavigationView={navigationView}
>
<View style={styles.temp}></View>
<ScrollView onResponderMove={() => { console.log('release') }}>
<Component1 name={"nikhitha"} />
// <BasicComponent/>
<Drawablelayout drawerPosition={drawerPosition} drawer={drawer} changeDrawerPosition={changeDrawerPosition}/>
</ScrollView>
</DrawerLayoutAndroid> */}