From 0584ad2bd8f486a0aaff7d8c96007d05c88a9a5e Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 24 Aug 2024 18:13:02 +0300 Subject: fix(mobile): Allow expanding the text by clicking on bookmark card --- apps/mobile/app/dashboard/bookmarks/[slug].tsx | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 apps/mobile/app/dashboard/bookmarks/[slug].tsx (limited to 'apps/mobile/app/dashboard/bookmarks') diff --git a/apps/mobile/app/dashboard/bookmarks/[slug].tsx b/apps/mobile/app/dashboard/bookmarks/[slug].tsx new file mode 100644 index 00000000..c7b0cead --- /dev/null +++ b/apps/mobile/app/dashboard/bookmarks/[slug].tsx @@ -0,0 +1,82 @@ +import { View } from "react-native"; +import { Stack, useLocalSearchParams } from "expo-router"; +import BookmarkAssetImage from "@/components/bookmarks/BookmarkAssetImage"; +import BookmarkTextMarkdown from "@/components/bookmarks/BookmarkTextMarkdown"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import FullPageSpinner from "@/components/ui/FullPageSpinner"; +import PageTitle from "@/components/ui/PageTitle"; +import { api } from "@/lib/trpc"; + +import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; + +function BookmarkTextView({ bookmark }: { bookmark: ZBookmark }) { + if (bookmark.content.type !== BookmarkTypes.TEXT) { + throw new Error("Wrong content type rendered"); + } + const content = bookmark.content.text; + + return ( + + + + ); +} + +function BookmarkAssetView({ bookmark }: { bookmark: ZBookmark }) { + if (bookmark.content.type !== BookmarkTypes.ASSET) { + throw new Error("Wrong content type rendered"); + } + return ( + + + + ); +} + +export default function BookmarkView() { + const { slug } = useLocalSearchParams(); + if (typeof slug !== "string") { + throw new Error("Unexpected param type"); + } + + const { data: bookmark } = api.bookmarks.getBookmark.useQuery({ + bookmarkId: slug, + }); + + let comp; + let title = null; + if (bookmark) { + switch (bookmark.content.type) { + case BookmarkTypes.LINK: + comp = null; + break; + case BookmarkTypes.TEXT: + title = bookmark.title; + comp = ; + break; + case BookmarkTypes.ASSET: + title = bookmark.title ?? bookmark.content.fileName; + comp = ; + break; + } + } else { + comp = ; + } + + return ( + + + + {comp} + + ); +} -- cgit v1.2.3-70-g09d2