-
Notifications
You must be signed in to change notification settings - Fork 59
/
App.tsx
141 lines (132 loc) · 4.3 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
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"
import { NavigationContainer } from "@react-navigation/native"
import { createStackNavigator } from "@react-navigation/stack"
import { Verifiable, W3CCredential } from "did-jwt-vc"
import React from "react"
import { Alert, Button } from "react-native"
import Ionicons from "react-native-vector-icons/Ionicons"
import CredentialDetail from "./src/components/CredentialDetail"
import CredentialPicker from "./src/components/CredentialPicker"
import CredentialsList from "./src/components/CredentialsList"
import HomePage from "./src/components/HomePage"
import Scanner from "./src/components/Scanner"
import SettingsScreen from "./src/components/SettingsScreen"
import Verification from "./src/components/Verification"
import { deleteCredential } from "./src/lib/storage"
const Stack = createStackNavigator()
const Tab = createBottomTabNavigator()
const ScannerStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="ScanScreen"
component={HomePage}
options={{ title: "Scan" }}
/>
<Stack.Screen name="Scanner" component={Scanner} />
<Stack.Screen name="CredentialPicker" component={CredentialPicker} />
<Stack.Screen name="Verification" component={Verification} />
</Stack.Navigator>
)
}
const CredentialStack = () => {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={CredentialsList} />
<Stack.Screen
name="Details"
component={CredentialDetail}
options={({ navigation, route }) => {
return {
headerRight: () => (
<Button
onPress={() => {
Alert.alert("Are you sure?", "This can not be undone.", [
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{
text: "OK",
onPress: async () => {
const params = route.params as Record<string, unknown>
if (params) {
const credential =
params.credential as Verifiable<W3CCredential>
if (credential) {
await deleteCredential(credential)
}
}
navigation.navigate("Home", { merge: true })
}
}
])
}}
title="Delete"
/>
)
}
}}
/>
</Stack.Navigator>
)
}
const SettingsStack = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="SettingsScreen"
component={SettingsScreen}
options={{ title: "Settings" }}
/>
</Stack.Navigator>
)
}
const App = (): JSX.Element => {
return (
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName
if (route.name === "Scan") {
iconName = focused ? "scan-circle" : "scan-circle-outline"
} else if (route.name === "Credentials") {
iconName = focused ? "wallet" : "wallet-outline"
} else if (route.name === "Settings") {
iconName = focused ? "settings" : "settings-outline"
}
// You can return any component that you like here!
return <Ionicons name={iconName ?? ""} size={size} color={color} />
},
tabBarActiveTintColor: "tomato",
tabBarInactiveTintColor: "gray",
tabBarStyle: [
{
display: "flex"
},
null
]
})}
>
<Tab.Screen
name="Scan"
component={ScannerStack}
options={{ headerShown: false }}
/>
<Tab.Screen
name="Credentials"
component={CredentialStack}
options={{ headerShown: false }}
/>
<Tab.Screen
name="Settings"
component={SettingsStack}
options={{ headerShown: false }}
/>
</Tab.Navigator>
</NavigationContainer>
)
}
export default App