-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
203 lines (185 loc) · 6.95 KB
/
App.tsx
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import React, { Component, useCallback, useContext, useEffect, useState } from "react";
import { View, Text, StyleSheet, Image, TouchableOpacity, Alert } from "react-native";
import { global_styles } from './src/style/globalstyle';
//import DinningTable from "./screens/DinningTable";
//import Pinauthentication from "./screens/Pinauthentication";
//import AppNavigator from "./navigator/app.navigator";
import SplashScreen from 'react-native-splash-screen';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
//import TabNavigator from "./src/navigator/TabNavigator";
import DetailsScreen from './src/screens/DetailsScreen';
import TabNavigator from "./src/navigator/TabNavigator";
import MenuData from "./src/data/MenuData";
import OrderItemCard from "./src/components/OrderItemCard";
import PaymentScreen from "./src/screens/PaymentScreen";
import Passcode from "./src/screens/Passcode";
import RvcScreen from "./src/screens/RvcScreen";
import OrderHistory from "./src/screens/OrderHistoryScreen";
import ModalTester from "./src/components/ModalComponent";
import HeaderBar from "./src/components/HeaderBar";
//import ScannerScreen from "./src/screens/Scanner";
//import QRCodeScanner from "react-native-qrcode-scanner";
//import { RNCamera } from "react-native-camera";
import Scanner from "./src/screens/Scanner";
import Welcome from "./src/screens/WelcomeScreen";
import { ThemeContext } from './src/context/AuthContext';
import * as Keychain from 'react-native-keychain';
import { Provider } from "react-redux";
import { RootStackParamList } from "./../restaurantproject/types";
import LoginScreen from "./src/screens/LoginScreen";
import { COLORS } from "./src/theme/theme";
//import stores, { persistor } from "./src/redux/stores";
// { PersistGate } from "redux-persist/integration/react";
import Toast from 'react-native-toast-message';
import RestaurantScreen from "./src/screens/RestaurantScreen";
import DinningTableScreen from "./src/screens/DinningTableScreen";
import Menu from "./src/screens/Menu";
import Cart from "./src/screens/CartScreen";
import CartScreen from "./src/screens/CartScreen";
import OrderHistoryScreen from "./src/screens/OrderHistoryScreen";
import { StripeProvider } from '@stripe/stripe-react-native';
import Setting from "./src/screens/Setting";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { BlurView } from "@react-native-community/blur";
/*const Stack = createNativeStackNavigator();
export default class App extends Component {
state: {};
constructor(props: any) {
super(props);
this.state = {
};
}
render() {
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name="Tab"
component={TabNavigator}
options={{ animation: 'slide_from_bottom' }}>
</Stack.Screen>
<Stack.Screen
name="Details"
component={DetailsScreen}
options={{ animation: 'slide_from_bottom' }}>
</Stack.Screen>
</Stack.Navigator>
</NavigationContainer>
);
}
}*/
/*const App = () => {
const authContext = useContext(ThemeContext);
const [status, setStatus] = useState('loading');
const loadJWT = useCallback(async () => {
try {
const value = await Keychain.getGenericPassword();
if (value) {
const jwt = JSON.parse(value.password);
authContext?.setAuthState({
accessToken: jwt.accessToken || null,
refreshToken: jwt.refreshToken || null,
authenticated: jwt.accessToken !== null,
});
setStatus('success');
// Continue with your code using jwt
} else {
// Handle the case where no password was found
console.error("No password found");
// You can also set a default value for jwt or handle this scenario as needed
}
} catch (error) {
setStatus('error');
console.log('Keychain Error: ${error.message}');
authContext?.setAuthState({
accessToken: null,
refreshToken: null,
authenticated: false,
});
}
}, []);
useEffect(() => {
loadJWT();
}, [loadJWT]);
if (authContext?.authState?.authenticated == false) {
return <SignInScreen />
} else {
return <Passcode />
}
};
export default App;*/
// Create Tab Navigator
const Tab = createBottomTabNavigator<RootStackParamList>();
type Props = NativeStackScreenProps<RootStackParamList, "MainTab">;
const MainTabNavigator: React.FC<Props> = () => {
return (
<Tab.Navigator screenOptions={{
tabBarHideOnKeyboard: true,
headerShown: false,
tabBarShowLabel: false,
tabBarBackground: () => (
<BlurView
overlayColor=""
blurAmount={15}
/>
),
}}>
<Tab.Screen name="Order" component={OrderHistoryScreen} options={{
tabBarStyle: { display: 'none' }, // Hide this tab
}} />
<Tab.Screen name="Cart" component={CartScreen} options={{
tabBarStyle: { display: 'none' }, // Hide this tab
}} />
<Tab.Screen name="Setting" component={Setting} options={{
tabBarStyle: { display: 'none' }, // Hide this tab
}} />
</Tab.Navigator>
);
}
const Stack = createNativeStackNavigator<RootStackParamList>();
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: COLORS.primaryBlackHex,
},
};
const App = () => {
useEffect(() => {
SplashScreen.hide();
}, []);
return (
<StripeProvider publishableKey="pk_test_51Po0RjIcOPMbNsR4Y47qYO5p9ShpXgZk96K8Scbnj9YuqlFundVNtUReN8cX5NKIxXb8htmoSwIfDdRsNfHL0ac500OSQWcPt9">
<NavigationContainer theme={theme}>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name="Welcome"
component={Welcome}
options={{ animation: 'slide_from_bottom' }} >
</Stack.Screen>
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Restaurant" component={RestaurantScreen} />
<Stack.Screen name="DinningTable" component={DinningTableScreen} />
<Stack.Screen name="Menus" component={Menu} />
<Stack.Screen name="Details" component={DetailsScreen} />
<Stack.Screen name="Cart" component={CartScreen} />
<Stack.Screen name="Order" component={OrderHistoryScreen} />
<Stack.Screen
name="Payment"
component={PaymentScreen}
options={{ animation: 'slide_from_bottom' }}>
</Stack.Screen>
<Stack.Screen
name="Setting"
component={Setting}
options={{ animation: 'slide_from_bottom' }}>
</Stack.Screen>
<Stack.Screen name="MainTab" component={MainTabNavigator} />
</Stack.Navigator>
<Toast />
</NavigationContainer>
</StripeProvider>
);
};
export default App;