From 3a4b858c03bf775e63521f8f0e0a5e9e304dbceb Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 04:27:21 +0000 Subject: mobile: Add support for viewing lists --- packages/mobile/app/dashboard/(tabs)/_layout.tsx | 9 +++- packages/mobile/app/dashboard/(tabs)/lists.tsx | 67 ++++++++++++++++++++++++ packages/mobile/app/dashboard/_layout.tsx | 17 +++++- packages/mobile/app/dashboard/archive.tsx | 11 ++++ packages/mobile/app/dashboard/favourites.tsx | 11 ++++ packages/mobile/app/dashboard/lists/[slug].tsx | 31 +++++++++++ 6 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 packages/mobile/app/dashboard/(tabs)/lists.tsx create mode 100644 packages/mobile/app/dashboard/archive.tsx create mode 100644 packages/mobile/app/dashboard/favourites.tsx create mode 100644 packages/mobile/app/dashboard/lists/[slug].tsx (limited to 'packages/mobile/app') diff --git a/packages/mobile/app/dashboard/(tabs)/_layout.tsx b/packages/mobile/app/dashboard/(tabs)/_layout.tsx index c15f37f1..74557eda 100644 --- a/packages/mobile/app/dashboard/(tabs)/_layout.tsx +++ b/packages/mobile/app/dashboard/(tabs)/_layout.tsx @@ -1,5 +1,5 @@ import { Tabs } from "expo-router"; -import { Home, Settings } from "lucide-react-native"; +import { ClipboardList, Home, Settings } from "lucide-react-native"; import React from "react"; export default function TabLayout() { @@ -12,6 +12,13 @@ export default function TabLayout() { tabBarIcon: ({ color }) => , }} /> + , + }} + /> { + setRefreshing(isPending); + }, [isPending]); + + if (!lists) { + // Add spinner + return ; + } + + const onRefresh = () => { + apiUtils.lists.list.invalidate(); + }; + + const links = [ + { + id: "fav", + logo: "⭐️", + name: "Favourites", + href: "/dashboard/favourites", + }, + { + id: "arch", + logo: "🗄️", + name: "Archive", + href: "/dashboard/archive", + }, + ]; + + links.push( + ...lists.lists.map((l) => ({ + id: l.id, + logo: l.icon, + name: l.name, + href: `/dashboard/lists/${l.id}`, + })), + ); + + return ( + ( + + + {l.item.logo} {l.item.name} + + + )} + data={links} + refreshing={refreshing} + onRefresh={onRefresh} + /> + ); +} diff --git a/packages/mobile/app/dashboard/_layout.tsx b/packages/mobile/app/dashboard/_layout.tsx index 590c82b1..4dd03d95 100644 --- a/packages/mobile/app/dashboard/_layout.tsx +++ b/packages/mobile/app/dashboard/_layout.tsx @@ -3,7 +3,22 @@ import { Stack } from "expo-router/stack"; export default function Dashboard() { return ( - + + + ); } diff --git a/packages/mobile/app/dashboard/archive.tsx b/packages/mobile/app/dashboard/archive.tsx new file mode 100644 index 00000000..d75cfe22 --- /dev/null +++ b/packages/mobile/app/dashboard/archive.tsx @@ -0,0 +1,11 @@ +import { View } from "react-native"; + +import BookmarkList from "@/components/bookmarks/BookmarkList"; + +export default function Archive() { + return ( + + + + ); +} diff --git a/packages/mobile/app/dashboard/favourites.tsx b/packages/mobile/app/dashboard/favourites.tsx new file mode 100644 index 00000000..90374f18 --- /dev/null +++ b/packages/mobile/app/dashboard/favourites.tsx @@ -0,0 +1,11 @@ +import { View } from "react-native"; + +import BookmarkList from "@/components/bookmarks/BookmarkList"; + +export default function Favourites() { + return ( + + + + ); +} diff --git a/packages/mobile/app/dashboard/lists/[slug].tsx b/packages/mobile/app/dashboard/lists/[slug].tsx new file mode 100644 index 00000000..5ebc4446 --- /dev/null +++ b/packages/mobile/app/dashboard/lists/[slug].tsx @@ -0,0 +1,31 @@ +import { useLocalSearchParams, Stack } from "expo-router"; +import { View } from "react-native"; + +import BookmarkList from "@/components/bookmarks/BookmarkList"; +import { api } from "@/lib/trpc"; + +export default function ListView() { + const { slug } = useLocalSearchParams(); + if (typeof slug !== "string") { + throw new Error("Unexpected param type"); + } + const { data: list } = api.lists.get.useQuery({ listId: slug }); + + if (!list) { + // TODO: Spinner + return ; + } + + return ( + <> + + + + + + ); +} -- cgit v1.2.3-70-g09d2