Skip to content

Commit 3091143

Browse files
authored
Make the menu a menulist, remove non-mvp screens (#106)
1 parent b034f34 commit 3091143

File tree

9 files changed

+112
-79
lines changed

9 files changed

+112
-79
lines changed

packages/mobile-app/app/(tabs)/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function Layout() {
88
name="index"
99
options={{
1010
headerShown: false,
11-
title: "Home",
11+
title: "Account",
1212
tabBarIcon: ({ focused, color, size }) => (
1313
<Ionicons
1414
name={focused ? "wallet" : "wallet-outline"}

packages/mobile-app/app/_layout.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ const queryClient = new QueryClient({
3535

3636
function DatabaseLoader({ children }: { children?: React.ReactNode }) {
3737
const facade = useFacade();
38-
const [status, setStatus] = useState<string>("loading");
38+
const [status, setStatus] = useState<"loading" | "loaded">("loading");
3939
const { mutateAsync: loadDatabases } = facade.loadDatabases.useMutation();
4040

4141
useEffect(() => {
4242
const fn = async () => {
4343
const result = await loadDatabases(undefined);
44-
setStatus(result);
44+
45+
if (result !== "loaded") {
46+
throw new Error("Failed to load databases");
47+
}
48+
49+
setStatus("loaded");
4550
};
4651
fn();
4752
}, [loadDatabases]);
@@ -53,11 +58,9 @@ function DatabaseLoader({ children }: { children?: React.ReactNode }) {
5358
<Text>Loading databases...</Text>
5459
</SafeAreaView>
5560
);
56-
} else if (status === "loaded") {
57-
return children;
58-
} else {
59-
throw new Error(`Unknown status ${status}`);
6061
}
62+
63+
return children;
6164
}
6265

6366
export default function Layout() {
@@ -82,6 +85,13 @@ export default function Layout() {
8285
name="(tabs)"
8386
options={{
8487
headerShown: false,
88+
title: "Account",
89+
}}
90+
/>
91+
<Stack.Screen
92+
name="menu"
93+
options={{
94+
title: "Menu",
8595
}}
8696
/>
8797
<Stack.Screen
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Stack } from "expo-router";
2+
3+
export default function MenuLayout() {
4+
return (
5+
<Stack>
6+
<Stack.Screen
7+
name="index"
8+
options={{
9+
headerShown: false,
10+
}}
11+
/>
12+
<Stack.Screen
13+
name="security/index"
14+
options={{
15+
title: "Security",
16+
}}
17+
/>
18+
<Stack.Screen
19+
name="notifications/index"
20+
options={{
21+
title: "Notifications",
22+
}}
23+
/>
24+
<Stack.Screen
25+
name="language/index"
26+
options={{
27+
title: "Language",
28+
}}
29+
/>
30+
<Stack.Screen
31+
name="theme/index"
32+
options={{
33+
title: "Theme",
34+
}}
35+
/>
36+
<Stack.Screen
37+
name="network/index"
38+
options={{
39+
title: "Network",
40+
}}
41+
/>
42+
<Stack.Screen
43+
name="debug/index"
44+
options={{
45+
title: "Debug",
46+
}}
47+
/>
48+
<Stack.Screen
49+
name="about/index"
50+
options={{
51+
title: "About",
52+
}}
53+
/>
54+
</Stack>
55+
);
56+
}
Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
11
import { StatusBar } from "expo-status-bar";
2-
import { Button, StyleSheet, View } from "react-native";
2+
import { StyleSheet } from "react-native";
3+
import {
4+
Icon,
5+
IconElement,
6+
Layout,
7+
Menu,
8+
MenuItem,
9+
} from "@ui-kitten/components";
310
import { useRouter } from "expo-router";
4-
import { LinkButton } from "../../components/LinkButton";
511

6-
export default function Menu() {
12+
const ForwardIcon = (props: any): IconElement => (
13+
<Icon {...props} name="arrow-ios-forward" />
14+
);
15+
16+
const menuItems = [
17+
{ title: "Security", href: "menu/security" },
18+
{ title: "Notifications", href: "menu/notifications" },
19+
{ title: "Network", href: "menu/network" },
20+
{ title: "Debug", href: "menu/debug" },
21+
{ title: "About the app", href: "menu/about" },
22+
];
23+
24+
export default function MenuScreen() {
725
const router = useRouter();
826

9-
return (
10-
<View style={styles.container}>
11-
<Button title="Close" onPress={() => router.dismiss()} />
12-
<LinkButton title="Security" href="/menu/security/" />
13-
<LinkButton title="Notifications" href="/menu/notifications/" />
14-
<LinkButton title="Language" href="/menu/language/" />
15-
<LinkButton title="Theme" href="/menu/theme/" />
16-
<LinkButton title="Network" href="/menu/network" />
17-
<LinkButton title="Learn" href="/menu/learn/" />
18-
<LinkButton title="Debug" href="/menu/debug/" />
19-
<LinkButton title="About the app" href="/menu/about/" />
27+
const handleSelect = (index: number) => {
28+
router.push(menuItems[index].href);
29+
};
2030

31+
return (
32+
<Layout style={styles.container} level="1">
33+
<Menu style={styles.menu} onSelect={(index) => handleSelect(index.row)}>
34+
{menuItems.map((item, index) => (
35+
<MenuItem
36+
key={index}
37+
title={item.title}
38+
accessoryRight={ForwardIcon}
39+
/>
40+
))}
41+
</Menu>
2142
<StatusBar style="auto" />
22-
</View>
43+
</Layout>
2344
);
2445
}
2546

2647
const styles = StyleSheet.create({
2748
container: {
2849
flex: 1,
29-
backgroundColor: "#fff",
30-
alignItems: "center",
31-
justifyContent: "center",
50+
},
51+
menu: {
52+
flex: 1,
3253
},
3354
});

packages/mobile-app/app/menu/language.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/mobile-app/app/menu/theme.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)