-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
132 lines (124 loc) · 3.5 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
import "react-native-gesture-handler";
import {
DarkTheme,
DefaultTheme,
NavigationProp,
NavigationContainer,
NavigatorScreenParams,
CompositeScreenProps,
} from "@react-navigation/native";
import { AntDesign } from "@expo/vector-icons";
import { PaperProvider } from "react-native-paper";
import { useColorScheme, StatusBar } from "react-native";
import {
StackScreenProps,
createStackNavigator,
} from "@react-navigation/stack";
import {
BottomTabScreenProps,
createBottomTabNavigator,
} from "@react-navigation/bottom-tabs";
import SignIn from "./screens/SignIn";
import Orders from "./screens/Orders";
import Verify from "./screens/Verify";
import Settings from "./screens/Settings";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import useDriverStore from "./store/Driver";
export type RootStackParamList = {
Home: NavigatorScreenParams<HomeTabParamList>;
Verify: { id: string };
SignIn: undefined;
};
export type HomeTabParamList = {
Orders: undefined;
Setting: undefined;
};
const Stack = createStackNavigator<RootStackParamList>();
const Tab = createBottomTabNavigator();
function MyTabs() {
const isDarkMode = useColorScheme() === "dark";
return (
<Tab.Navigator
screenOptions={{
tabBarActiveTintColor: "#177AD5",
headerStyle: {
backgroundColor: isDarkMode ? "black" : "white",
},
tabBarStyle: {
backgroundColor: isDarkMode ? "black" : "white",
},
}}
>
<Tab.Screen
name="Orders"
component={Orders}
options={{
tabBarIcon: ({ color, size }) => (
<AntDesign name="home" size={size} color={color} />
),
}}
/>
<Tab.Screen
name="Setting"
component={Settings}
options={{
tabBarIcon: ({ color, size }) => (
<AntDesign name="setting" size={size} color={color} />
),
}}
/>
</Tab.Navigator>
);
}
const queryClient = new QueryClient();
export default function App() {
const isDarkMode = useColorScheme() === "dark";
const driver = useDriverStore((state) => state.driver);
return (
<QueryClientProvider client={queryClient}>
<PaperProvider theme={{ colors: { primary: "#177AD5" } }}>
<StatusBar
barStyle={isDarkMode ? "light-content" : "dark-content"}
backgroundColor={isDarkMode ? "black" : "white"}
/>
<NavigationContainer
theme={
isDarkMode
? DarkTheme
: {
...DefaultTheme,
colors: { ...DefaultTheme.colors, background: "white" },
}
}
>
<Stack.Navigator>
{driver ? (
<>
<Stack.Screen
name="Home"
component={MyTabs}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Verify"
component={Verify}
options={{
headerStyle: {
backgroundColor: isDarkMode ? "black" : "white",
},
}}
/>
</>
) : (
<Stack.Screen
name="SignIn"
component={SignIn}
options={{ headerShown: false }}
/>
)}
</Stack.Navigator>
</NavigationContainer>
</PaperProvider>
</QueryClientProvider>
);
}