From b094b2cecb0da1bcdf4c63dd081638d87793c53c Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 26 Aug 2024 13:41:13 +0300 Subject: feature(mobile): Change the view bookmark page to be a modal and add tags and notes --- apps/mobile/components/bookmarks/BookmarkCard.tsx | 100 +++++++++++----------- 1 file changed, 52 insertions(+), 48 deletions(-) (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 8c582d59..0b787372 100644 --- a/apps/mobile/components/bookmarks/BookmarkCard.tsx +++ b/apps/mobile/components/bookmarks/BookmarkCard.tsx @@ -9,7 +9,6 @@ import { View, } from "react-native"; import * as Haptics from "expo-haptics"; -import { Link, router } from "expo-router"; import * as WebBrowser from "expo-web-browser"; import useAppSettings from "@/lib/settings"; import { api } from "@/lib/trpc"; @@ -35,7 +34,8 @@ import { useToast } from "../ui/Toast"; import BookmarkAssetImage from "./BookmarkAssetImage"; import BookmarkTextMarkdown from "./BookmarkTextMarkdown"; import ListPickerModal from "./ListPickerModal"; -import NoteEditorModal from "./NewBookmarkModal"; +import TagPill from "./TagPill"; +import ViewBookmarkModal from "./ViewBookmarkModal"; function ActionBar({ bookmark }: { bookmark: ZBookmark }) { const { toast } = useToast(); @@ -75,7 +75,6 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) { }); const manageListsSheetRef = useRef(null); - const editBookmarkModal = useRef(null); return ( @@ -101,13 +100,6 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) { snapPoints={["50%", "90%"]} bookmarkId={bookmark.id} /> - {bookmark.content.type === BookmarkTypes.TEXT && ( - - )} { @@ -123,21 +115,9 @@ function ActionBar({ bookmark }: { bookmark: ZBookmark }) { }); } else if (nativeEvent.event === "manage_list") { manageListsSheetRef?.current?.present(); - } else if (nativeEvent.event === "edit") { - editBookmarkModal.current?.present(); } }} actions={[ - { - id: "edit", - title: "Edit", - image: Platform.select({ - ios: "edit", - }), - attributes: { - hidden: bookmark.content.type !== BookmarkTypes.TEXT, - }, - }, { id: "archive", title: bookmark.archived ? "Un-archive" : "Archive", @@ -187,21 +167,19 @@ function TagList({ bookmark }: { bookmark: ZBookmark }) { {tags.map((t) => ( - - - {t.name} - - + ))} ); } -function LinkCard({ bookmark }: { bookmark: ZBookmark }) { +function LinkCard({ + bookmark, +}: { + bookmark: ZBookmark; + onOpenBookmark: () => void; +}) { const { settings } = useAppSettings(); if (bookmark.content.type !== BookmarkTypes.LINK) { throw new Error("Wrong content type rendered"); @@ -264,16 +242,20 @@ function LinkCard({ bookmark }: { bookmark: ZBookmark }) { ); } -function TextCard({ bookmark }: { bookmark: ZBookmark }) { +function TextCard({ + bookmark, + onOpenBookmark, +}: { + bookmark: ZBookmark; + onOpenBookmark: () => void; +}) { if (bookmark.content.type !== BookmarkTypes.TEXT) { throw new Error("Wrong content type rendered"); } const content = bookmark.content.text; return ( - router.push(`/dashboard/bookmarks/${bookmark.id}`)} - > + {bookmark.title && ( {bookmark.title} @@ -281,9 +263,7 @@ function TextCard({ bookmark }: { bookmark: ZBookmark }) { )} - router.push(`/dashboard/bookmarks/${bookmark.id}`)} - > + @@ -297,7 +277,13 @@ function TextCard({ bookmark }: { bookmark: ZBookmark }) { ); } -function AssetCard({ bookmark }: { bookmark: ZBookmark }) { +function AssetCard({ + bookmark, + onOpenBookmark, +}: { + bookmark: ZBookmark; + onOpenBookmark: () => void; +}) { if (bookmark.content.type !== BookmarkTypes.ASSET) { throw new Error("Wrong content type rendered"); } @@ -305,18 +291,14 @@ function AssetCard({ bookmark }: { bookmark: ZBookmark }) { return ( - router.push(`/dashboard/bookmarks/${bookmark.id}`)} - > + - router.push(`/dashboard/bookmarks/${bookmark.id}`)} - > + {title && ( {title} @@ -359,21 +341,43 @@ export default function BookmarkCard({ }, ); + const viewBookmarkModal = useRef(null); + let comp; switch (bookmark.content.type) { case BookmarkTypes.LINK: - comp = ; + comp = ( + viewBookmarkModal.current?.present()} + /> + ); break; case BookmarkTypes.TEXT: - comp = ; + comp = ( + viewBookmarkModal.current?.present()} + /> + ); break; case BookmarkTypes.ASSET: - comp = ; + comp = ( + viewBookmarkModal.current?.present()} + /> + ); break; } return ( + {comp} ); -- cgit v1.2.3-70-g09d2