From cddae8ffd2a966d938f56bb387a32f103f8a2888 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 8 Sep 2024 19:01:04 +0100 Subject: feature(mobile): Show the view bookmark modal for links as well --- .../components/bookmarks/ViewBookmarkModal.tsx | 55 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'apps/mobile/components/bookmarks/ViewBookmarkModal.tsx') diff --git a/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx b/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx index 6bec88af..059b990e 100644 --- a/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx +++ b/apps/mobile/components/bookmarks/ViewBookmarkModal.tsx @@ -1,7 +1,9 @@ import React, { useState } from "react"; import { Keyboard, Pressable, Text } from "react-native"; import ImageView from "react-native-image-viewing"; +import * as WebBrowser from "expo-web-browser"; import { useAssetUrl } from "@/lib/hooks"; +import { cn } from "@/lib/utils"; import { BottomSheetBackdrop, BottomSheetModal, @@ -10,6 +12,7 @@ import { BottomSheetView, TouchableWithoutFeedback, } from "@gorhom/bottom-sheet"; +import { ExternalLink } from "lucide-react-native"; import { useUpdateBookmark, @@ -18,6 +21,8 @@ import { import { isBookmarkStillTagging } from "@hoarder/shared-react/utils/bookmarkUtils"; import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; +import { TailwindResolver } from "../TailwindResolver"; +import { buttonVariants } from "../ui/Button"; import { Input } from "../ui/Input"; import PageTitle from "../ui/PageTitle"; import { Skeleton } from "../ui/Skeleton"; @@ -74,6 +79,51 @@ function NotesEditor({ bookmark }: { bookmark: ZBookmark }) { ); } +function BookmarkLinkView({ bookmark }: { bookmark: ZBookmark }) { + const [imageZoom, setImageZoom] = useState(false); + if (bookmark.content.type !== BookmarkTypes.LINK) { + throw new Error("Wrong content type rendered"); + } + const url = new URL(bookmark.content.url); + + const imageAssetId = + bookmark.content.imageAssetId ?? bookmark.content.screenshotAssetId ?? ""; + const assetSource = useAssetUrl(imageAssetId); + return ( + + WebBrowser.openBrowserAsync(url.toString())} + > + {url.host} + ( + + )} + /> + + setImageZoom(false)} + doubleTapToZoomEnabled={true} + images={[assetSource]} + /> + + setImageZoom(true)}> + + + + ); +} + function BookmarkTextView({ bookmark }: { bookmark: ZBookmark }) { if (bookmark.content.type !== BookmarkTypes.TEXT) { throw new Error("Wrong content type rendered"); @@ -162,7 +212,8 @@ const ViewBookmarkModal = React.forwardRef< let title = null; switch (bookmark.content.type) { case BookmarkTypes.LINK: - comp = null; + title = bookmark.title ?? bookmark.content.title; + comp = ; break; case BookmarkTypes.TEXT: title = bookmark.title; @@ -188,7 +239,7 @@ const ViewBookmarkModal = React.forwardRef< - + {comp} -- cgit v1.2.3-70-g09d2