From f1d86812e9a045b474f4a1c8cd3621fe17b8b806 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 00:58:37 +0000 Subject: mobile: Introduce a tab layout and move the sharing page into a modal --- packages/mobile/app/dashboard/(tabs)/_layout.tsx | 24 ++++++++++++++ packages/mobile/app/dashboard/(tabs)/index.tsx | 8 +++++ packages/mobile/app/dashboard/(tabs)/settings.tsx | 38 +++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 packages/mobile/app/dashboard/(tabs)/_layout.tsx create mode 100644 packages/mobile/app/dashboard/(tabs)/index.tsx create mode 100644 packages/mobile/app/dashboard/(tabs)/settings.tsx (limited to 'packages/mobile/app/dashboard/(tabs)') diff --git a/packages/mobile/app/dashboard/(tabs)/_layout.tsx b/packages/mobile/app/dashboard/(tabs)/_layout.tsx new file mode 100644 index 00000000..49d95b35 --- /dev/null +++ b/packages/mobile/app/dashboard/(tabs)/_layout.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import { Tabs } from "expo-router"; +import { Home, Settings } from "lucide-react-native"; + +export default function TabLayout() { + return ( + + , + }} + /> + , + }} + /> + + ); +} diff --git a/packages/mobile/app/dashboard/(tabs)/index.tsx b/packages/mobile/app/dashboard/(tabs)/index.tsx new file mode 100644 index 00000000..d043a9c4 --- /dev/null +++ b/packages/mobile/app/dashboard/(tabs)/index.tsx @@ -0,0 +1,8 @@ +import { View } from "react-native"; + +export default function Home() { + return ( + + + ); +} diff --git a/packages/mobile/app/dashboard/(tabs)/settings.tsx b/packages/mobile/app/dashboard/(tabs)/settings.tsx new file mode 100644 index 00000000..b4f535c5 --- /dev/null +++ b/packages/mobile/app/dashboard/(tabs)/settings.tsx @@ -0,0 +1,38 @@ +import { useRouter } from "expo-router"; +import { useEffect } from "react"; +import { Text, View } from "react-native"; + +import Logo from "@/components/Logo"; +import { Button } from "@/components/ui/Button"; +import { useSession } from "@/lib/session"; +import { api } from "@/lib/trpc"; + +export default function Dashboard() { + const router = useRouter(); + + const { isLoggedIn, logout } = useSession(); + + useEffect(() => { + if (isLoggedIn !== undefined && !isLoggedIn) { + router.replace("signin"); + } + }, [isLoggedIn]); + + const { data, error, isLoading } = api.users.whoami.useQuery(); + + useEffect(() => { + if (error?.data?.code === "UNAUTHORIZED") { + logout(); + } + }, [error]); + + return ( + + + + Logged in as: {isLoading ? "Loading ..." : data?.email} + +