This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathApp.tsx
More file actions
185 lines (168 loc) · 4.63 KB
/
Copy pathApp.tsx
File metadata and controls
185 lines (168 loc) · 4.63 KB
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
// 1st party libraries and dependencies: react, react native and Expo stuff
import React from "react";
import { useColorScheme, Platform, Text } from "react-native";
// 3rd party libraries
import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createStackNavigator } from "@react-navigation/stack";
import { Icon } from "react-native-elements";
import { NotifierWrapper } from "react-native-notifier";
import * as Linking from "expo-linking";
// Pages
import SendScreen from "./pages/SendScreen";
import QRScreen from "./pages/QRScreen";
import HomeScreen from "./pages/HomeScreen";
import SettingsPage, { QRSettings, FileSettings } from "./pages/SettingsPage";
import AboutPage from "./pages/settings/AboutPage";
import FilePage from "./pages/FilePage";
// Constants
import { apiEndpoint, colors } from "./lib/constants";
// App component
const Tab = createBottomTabNavigator();
const Stack = createStackNavigator();
function Settings() {
const colorScheme = useColorScheme();
return (
<Stack.Navigator
screenOptions={({ route }) => {
return {
headerShown: route.name !== "Settings",
headerMode: "float",
headerStyle: {
backgroundColor:
colorScheme === "dark" ? colors.darkHeader : colors.light,
},
headerTitleStyle: {
color: colorScheme === "dark" ? "white" : "black",
},
};
}}
>
<Stack.Screen
headerShown={false}
name="Settings"
component={SettingsPage}
/>
<Stack.Screen name="QR" component={QRSettings} />
<Stack.Screen name="Files" component={FileSettings} />
<Stack.Screen name="About" component={AboutPage} />
</Stack.Navigator>
);
}
function MyTabs() {
const colorScheme = useColorScheme();
return (
<Tab.Navigator
initialRouteName="Home"
screenOptions={{
headerShown: false,
tabBarShowLabel: false,
tabBarActiveTintColor: "#157EFB",
tabBarInactiveTintColor:
colorScheme === "dark" ? colors.light : colors.text,
tabBarStyle: {
backgroundColor:
colorScheme === "dark" ? colors.headerBg : colors.lightContent,
color: colorScheme === "dark" ? colors.light : colors.text,
},
}}
>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarLabel: "Receive",
tabBarIcon: ({ color, size }) => (
<Icon name="download" type="feather" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Scan"
component={QRScreen}
options={{
tabBarLabel: "Scan",
tabBarIcon: ({ color, size }) => (
<Icon
name="qr-code-outline"
type="ionicon"
color={color}
size={size}
/>
),
}}
/>
<Tab.Screen
name="Send"
component={SendScreen}
options={{
tabBarLabel: "Create",
tabBarIcon: ({ color, size }) => (
<Icon name="plus-circle" type="feather" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="File"
component={FilePage}
options={{
tabBarLabel: "File",
tabBarIcon: ({ color, size }) => (
<Icon
name="image-outline"
type="ionicon"
color={color}
size={size}
/>
),
}}
/>
{Platform.OS === "ios" && (
<Tab.Screen
name="SettingsPage"
component={Settings}
options={{
tabBarLabel: "Settings",
tabBarIcon: ({ color, size }) => (
<Icon
name="cog-outline"
type="ionicon"
color={color}
size={size}
/>
),
}}
/>
)}
</Tab.Navigator>
);
}
export default function App() {
const config = {
screens: {
Scan: "scan",
SettingsPage: {
path: "settings",
screens: {
About: "about",
Files: "settings/files",
QR: "settings/qr",
},
},
Send: "send",
File: "file",
},
};
const prefix = Linking.createURL("/");
const linking = {
prefixes: [apiEndpoint, prefix],
config,
};
return (
<NotifierWrapper>
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
<MyTabs />
</NavigationContainer>
</NotifierWrapper>
);
}