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/[bookmark]/[slug].tsx | 9 --- packages/mobile/app/_layout.tsx | 17 +++++- packages/mobile/app/dashboard.tsx | 38 ------------- packages/mobile/app/dashboard/(tabs)/_layout.tsx | 24 ++++++++ packages/mobile/app/dashboard/(tabs)/index.tsx | 8 +++ packages/mobile/app/dashboard/(tabs)/settings.tsx | 38 +++++++++++++ packages/mobile/app/dashboard/_layout.tsx | 9 +++ packages/mobile/app/error.tsx | 2 +- packages/mobile/app/sharing.tsx | 69 ++++++++++++++++++----- pnpm-lock.yaml | 3 + 10 files changed, 153 insertions(+), 64 deletions(-) delete mode 100644 packages/mobile/app/[bookmark]/[slug].tsx delete mode 100644 packages/mobile/app/dashboard.tsx 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 create mode 100644 packages/mobile/app/dashboard/_layout.tsx diff --git a/packages/mobile/app/[bookmark]/[slug].tsx b/packages/mobile/app/[bookmark]/[slug].tsx deleted file mode 100644 index 2ca88701..00000000 --- a/packages/mobile/app/[bookmark]/[slug].tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { View, Text } from "react-native"; - -export default function Bookmark() { - return ( - - Hoarded! - - ); -} diff --git a/packages/mobile/app/_layout.tsx b/packages/mobile/app/_layout.tsx index bd269060..e8244867 100644 --- a/packages/mobile/app/_layout.tsx +++ b/packages/mobile/app/_layout.tsx @@ -1,11 +1,12 @@ import "@/globals.css"; import "expo-dev-client"; -import { Slot, useRouter } from "expo-router"; +import { useRouter } from "expo-router"; import { useShareIntent } from "expo-share-intent"; import { StatusBar } from "expo-status-bar"; import { useEffect } from "react"; import { View } from "react-native"; +import { Stack } from "expo-router/stack"; import { Providers } from "@/lib/providers"; @@ -22,10 +23,22 @@ export default function RootLayout() { resetShareIntent(); } }, [hasShareIntent]); + return ( - + + + diff --git a/packages/mobile/app/dashboard.tsx b/packages/mobile/app/dashboard.tsx deleted file mode 100644 index b4f535c5..00000000 --- a/packages/mobile/app/dashboard.tsx +++ /dev/null @@ -1,38 +0,0 @@ -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} - -