Skip to content

Commit ede644a

Browse files
WIP: new routing
1 parent 92189ee commit ede644a

36 files changed

Lines changed: 499 additions & 216 deletions
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from "react";
2+
import { Tabs } from "expo-router";
3+
import { TextStyle, ViewStyle } from "react-native";
4+
import { useSafeAreaInsets } from "react-native-safe-area-context";
5+
import { useTheme } from "tamagui";
6+
import { useTranslation } from "react-i18next";
7+
import { useNetInfoContext } from "../../../../../contexts/net-info-banner/NetInfoContext";
8+
import { Icon } from "../../../../../components/Icon";
9+
10+
export default function TabLayout() {
11+
const insets = useSafeAreaInsets();
12+
const theme = useTheme();
13+
const { t } = useTranslation("tabs");
14+
15+
const { shouldDisplayBanner } = useNetInfoContext();
16+
17+
return (
18+
<Tabs
19+
screenOptions={{
20+
tabBarActiveTintColor: theme.purple5?.val,
21+
tabBarHideOnKeyboard: true,
22+
headerShown: false,
23+
tabBarStyle: [
24+
$tabBar,
25+
{
26+
height: insets.bottom + 60,
27+
...(shouldDisplayBanner && insets?.bottom ? { marginBottom: -insets.bottom + 10 } : {}),
28+
},
29+
],
30+
tabBarLabelStyle: $tabBarLabel,
31+
tabBarAllowFontScaling: false,
32+
}}
33+
>
34+
<Tabs.Screen
35+
name="index"
36+
options={{
37+
title: "Report",
38+
tabBarIcon: ({ color }) => <Icon icon="observation" color={color} />,
39+
}}
40+
/>
41+
<Tabs.Screen
42+
name="resources"
43+
options={{
44+
title: "Resources",
45+
tabBarIcon: ({ color }) => <Icon icon="quickReport" color={color} />,
46+
href: "/resources",
47+
}}
48+
/>
49+
<Tabs.Screen
50+
name="more"
51+
options={{
52+
title: t("more"),
53+
tabBarIcon: ({ color }) => <Icon icon="more" color={color} />,
54+
}}
55+
/>
56+
</Tabs>
57+
);
58+
}
59+
60+
const $tabBar: ViewStyle = {
61+
backgroundColor: "white",
62+
};
63+
64+
const $tabBarLabel: TextStyle = {
65+
marginBottom: 11,
66+
marginTop: -5,
67+
fontFamily: "Roboto",
68+
fontSize: 12,
69+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { Icon } from "../../../../../components/Icon";
3+
import { Screen } from "../../../../../components/Screen";
4+
import Header from "../../../../../components/Header";
5+
import { Text } from "react-native";
6+
import { useNavigation } from "expo-router";
7+
import { DrawerActions } from "@react-navigation/native";
8+
9+
export default function Report() {
10+
const navigation = useNavigation();
11+
12+
return (
13+
<Screen preset="fixed" contentContainerStyle={{ flexGrow: 1 }}>
14+
<Header
15+
title="Report"
16+
titleColor="white"
17+
barStyle="light-content"
18+
leftIcon={<Icon icon="menuAlt2" color="white" />}
19+
onLeftPress={() => navigation.dispatch(DrawerActions.openDrawer)}
20+
rightIcon={<Icon icon="dotsVertical" color="white" />}
21+
onRightPress={() => {}}
22+
/>
23+
24+
<Text>Report Index </Text>
25+
</Screen>
26+
);
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { Icon } from "../../../../../components/Icon";
3+
import { Screen } from "../../../../../components/Screen";
4+
import Header from "../../../../../components/Header";
5+
import { Text } from "react-native";
6+
import { useNavigation } from "expo-router";
7+
import { DrawerActions } from "@react-navigation/native";
8+
9+
export default function More() {
10+
const navigation = useNavigation();
11+
12+
return (
13+
<Screen preset="fixed" contentContainerStyle={{ flexGrow: 1 }}>
14+
<Header
15+
title="More"
16+
titleColor="white"
17+
barStyle="light-content"
18+
leftIcon={<Icon icon="menuAlt2" color="white" />}
19+
onLeftPress={() => navigation.dispatch(DrawerActions.openDrawer)}
20+
rightIcon={<Icon icon="dotsVertical" color="white" />}
21+
onRightPress={() => {}}
22+
/>
23+
24+
<Text>More Index </Text>
25+
</Screen>
26+
);
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { Icon } from "../../../../../components/Icon";
3+
import { Screen } from "../../../../../components/Screen";
4+
import Header from "../../../../../components/Header";
5+
import { Text } from "react-native";
6+
import { useNavigation } from "expo-router";
7+
import { DrawerActions } from "@react-navigation/native";
8+
9+
export default function Resources() {
10+
const navigation = useNavigation();
11+
12+
return (
13+
<Screen preset="fixed" contentContainerStyle={{ flexGrow: 1 }}>
14+
<Header
15+
title="Resources"
16+
titleColor="white"
17+
barStyle="light-content"
18+
leftIcon={<Icon icon="menuAlt2" color="white" />}
19+
onLeftPress={() => navigation.dispatch(DrawerActions.openDrawer)}
20+
rightIcon={<Icon icon="dotsVertical" color="white" />}
21+
onRightPress={() => {}}
22+
/>
23+
24+
<Text>Resources Index </Text>
25+
</Screen>
26+
);
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import { GestureHandlerRootView } from "react-native-gesture-handler";
3+
import { Drawer } from "expo-router/drawer";
4+
import { ScrollViewProps, Text } from "react-native";
5+
import { DrawerContentScrollView } from "@react-navigation/drawer";
6+
import { useTheme } from "tamagui";
7+
8+
type DrawerContentProps = ScrollViewProps & {
9+
children?: React.ReactNode;
10+
backgroundColor: string;
11+
};
12+
13+
export const DrawerContent = (props: DrawerContentProps) => {
14+
return (
15+
<DrawerContentScrollView {...props}>
16+
<Text>Drawer Content</Text>
17+
</DrawerContentScrollView>
18+
);
19+
};
20+
21+
export default function DrawerLayout() {
22+
const theme = useTheme();
23+
24+
console.log("DrawerLayout");
25+
26+
return (
27+
<GestureHandlerRootView style={{ flex: 1 }}>
28+
<Drawer
29+
drawerContent={() => <DrawerContent backgroundColor={theme.purple5?.val} />}
30+
screenOptions={{
31+
drawerType: "front",
32+
headerShown: false,
33+
}}
34+
>
35+
<Drawer.Screen name="(tabs)" />
36+
</Drawer>
37+
</GestureHandlerRootView>
38+
);
39+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Redirect } from "expo-router";
2+
import React from "react";
3+
4+
export default function MainLayout() {
5+
console.log("MainLayout");
6+
7+
const selectedElectionRound = false;
8+
9+
if (!selectedElectionRound) {
10+
return <Redirect href="/election-rounds" />;
11+
}
12+
13+
return <></>;
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Text } from "tamagui";
2+
import { Screen } from "../../../components/Screen";
3+
4+
const Questionnaire = () => {
5+
return (
6+
<Screen>
7+
<Text>Ha test</Text>
8+
</Screen>
9+
);
10+
};
11+
12+
export default Questionnaire;

mobile/app/(citizen)/_layout.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Slot } from "expo-router";
2+
import React from "react";
3+
4+
const CitizenLayout = () => {
5+
console.log("CitizenLayout");
6+
return <Slot />;
7+
};
8+
9+
export default CitizenLayout;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Text } from "react-native";
2+
import React from "react";
3+
import Button from "../../components/Button";
4+
import { Screen } from "../../components/Screen";
5+
import { router } from "expo-router";
6+
7+
function CitizenElectionRoundsSelector() {
8+
return (
9+
<Screen preset="fixed" contentContainerStyle={{ flexGrow: 1 }}>
10+
<Text>More Index </Text>
11+
<Button
12+
onPress={() => {
13+
router.replace("(main)");
14+
}}
15+
>
16+
Du-te-n mm
17+
</Button>
18+
</Screen>
19+
);
20+
}
21+
22+
export default CitizenElectionRoundsSelector;

mobile/app/(app)/(drawer)/(tabs)/(observation)/_layout.tsx renamed to mobile/app/(observer)/(app)/(drawer)/(tabs)/(observation)/_layout.tsx

File renamed without changes.

0 commit comments

Comments
 (0)