From 93afb75619a02aa741b464634911b994620092be Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sun, 28 Jul 2024 20:03:15 -0700
Subject: feat(mobile): Add ability to manage lists

---
 apps/mobile/components/bookmarks/BookmarkCard.tsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'apps/mobile/components/bookmarks/BookmarkCard.tsx')

diff --git a/apps/mobile/components/bookmarks/BookmarkCard.tsx b/apps/mobile/components/bookmarks/BookmarkCard.tsx
index 8faa8618..3be1f9a0 100644
--- a/apps/mobile/components/bookmarks/BookmarkCard.tsx
+++ b/apps/mobile/components/bookmarks/BookmarkCard.tsx
@@ -1,3 +1,4 @@
+import { useRef } from "react";
 import {
   ActivityIndicator,
   Image,
@@ -13,6 +14,7 @@ import { Link } from "expo-router";
 import * as WebBrowser from "expo-web-browser";
 import useAppSettings from "@/lib/settings";
 import { api } from "@/lib/trpc";
+import { BottomSheetModal } from "@gorhom/bottom-sheet";
 import { MenuView } from "@react-native-menu/menu";
 import { Ellipsis, Star } from "lucide-react-native";
 
@@ -32,6 +34,7 @@ import { TailwindResolver } from "../TailwindResolver";
 import { Divider } from "../ui/Divider";
 import { Skeleton } from "../ui/Skeleton";
 import { useToast } from "../ui/Toast";
+import ListPickerModal from "./ListPickerModal";
 
 function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
   const { toast } = useToast();
@@ -70,6 +73,8 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
       onError,
     });
 
+  const manageListsSheetRef = useRef<BottomSheetModal>(null);
+
   return (
     <View className="flex flex-row gap-4">
       {(isArchivePending || isDeletionPending) && <ActivityIndicator />}
@@ -89,6 +94,12 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
         )}
       </Pressable>
 
+      <ListPickerModal
+        ref={manageListsSheetRef}
+        snapPoints={["50%", "90%"]}
+        bookmarkId={bookmark.id}
+      />
+
       <MenuView
         onPressAction={({ nativeEvent }) => {
           Haptics.selectionAsync();
@@ -101,6 +112,8 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
               bookmarkId: bookmark.id,
               archived: !bookmark.archived,
             });
+          } else if (nativeEvent.event === "manage_list") {
+            manageListsSheetRef?.current?.present();
           }
         }}
         actions={[
@@ -121,6 +134,13 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
               ios: "trash",
             }),
           },
+          {
+            id: "manage_list",
+            title: "Manage Lists",
+            image: Platform.select({
+              ios: "list",
+            }),
+          },
         ]}
         shouldOpenOnLongPress={false}
       >
-- 
cgit v1.2.3-70-g09d2

