aboutsummaryrefslogtreecommitdiffstats
path: root/packages/mobile/app/dashboard/(tabs)
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-13 04:27:21 +0000
committerMohamedBassem <me@mbassem.com>2024-03-13 04:29:52 +0000
commit3a4b858c03bf775e63521f8f0e0a5e9e304dbceb (patch)
tree1473ade5bdec7e5036a13c0c96342020610b5abb /packages/mobile/app/dashboard/(tabs)
parent61e970bb8c75c6edb279447be3f7ca8a00bd607d (diff)
downloadkarakeep-3a4b858c03bf775e63521f8f0e0a5e9e304dbceb.tar.zst
mobile: Add support for viewing lists
Diffstat (limited to 'packages/mobile/app/dashboard/(tabs)')
-rw-r--r--packages/mobile/app/dashboard/(tabs)/_layout.tsx9
-rw-r--r--packages/mobile/app/dashboard/(tabs)/lists.tsx67
2 files changed, 75 insertions, 1 deletions
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() {
@@ -13,6 +13,13 @@ export default function TabLayout() {
}}
/>
<Tabs.Screen
+ name="lists"
+ options={{
+ title: "Lists",
+ tabBarIcon: ({ color }) => <ClipboardList color={color} />,
+ }}
+ />
+ <Tabs.Screen
name="settings"
options={{
title: "Settings",
diff --git a/packages/mobile/app/dashboard/(tabs)/lists.tsx b/packages/mobile/app/dashboard/(tabs)/lists.tsx
new file mode 100644
index 00000000..b534ddda
--- /dev/null
+++ b/packages/mobile/app/dashboard/(tabs)/lists.tsx
@@ -0,0 +1,67 @@
+import { Link } from "expo-router";
+import { useEffect, useState } from "react";
+import { FlatList, View } from "react-native";
+
+import { api } from "@/lib/trpc";
+
+export default function Lists() {
+ const [refreshing, setRefreshing] = useState(false);
+ const { data: lists, isPending } = api.lists.list.useQuery();
+ const apiUtils = api.useUtils();
+
+ useEffect(() => {
+ setRefreshing(isPending);
+ }, [isPending]);
+
+ if (!lists) {
+ // Add spinner
+ return <View />;
+ }
+
+ 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 (
+ <FlatList
+ contentContainerStyle={{
+ gap: 10,
+ marginTop: 10,
+ }}
+ renderItem={(l) => (
+ <View className="mx-2 block rounded-xl border border-gray-100 bg-white px-4 py-2">
+ <Link key={l.item.id} href={l.item.href} className="text-lg">
+ {l.item.logo} {l.item.name}
+ </Link>
+ </View>
+ )}
+ data={links}
+ refreshing={refreshing}
+ onRefresh={onRefresh}
+ />
+ );
+}