From 5522e20104da6afe2e4667cf45dbbbbc0e838865 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 23 Nov 2024 20:59:34 +0000 Subject: ui(mobile): Replace bottom sheet with native screens (#690) * Remove bottom sheet from bookmark info page * Remove bottom sheet from manage lists page * Remove bottom sheet from new list page * Remove bottom sheet from new bookmark page * Drop bottom-sheets * Improve the look of the modals * Make the search page fade from bottom --- apps/mobile/app/_layout.tsx | 74 ++--- apps/mobile/app/dashboard/(tabs)/index.tsx | 10 +- apps/mobile/app/dashboard/(tabs)/lists.tsx | 10 +- apps/mobile/app/dashboard/_layout.tsx | 45 +++ apps/mobile/app/dashboard/add-link.tsx | 64 ----- apps/mobile/app/dashboard/bookmarks/[slug].tsx | 317 --------------------- .../app/dashboard/bookmarks/[slug]/index.tsx | 296 +++++++++++++++++++ .../mobile/app/dashboard/bookmarks/[slug]/info.tsx | 115 ++++++++ .../dashboard/bookmarks/[slug]/manage_lists.tsx | 105 +++++++ apps/mobile/app/dashboard/bookmarks/new.tsx | 76 +++++ apps/mobile/app/dashboard/lists/new.tsx | 56 ++++ apps/mobile/app/sharing.tsx | 20 +- 12 files changed, 744 insertions(+), 444 deletions(-) delete mode 100644 apps/mobile/app/dashboard/add-link.tsx delete mode 100644 apps/mobile/app/dashboard/bookmarks/[slug].tsx create mode 100644 apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx create mode 100644 apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx create mode 100644 apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx create mode 100644 apps/mobile/app/dashboard/bookmarks/new.tsx create mode 100644 apps/mobile/app/dashboard/lists/new.tsx (limited to 'apps/mobile/app') diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx index 5eadad80..62c29c27 100644 --- a/apps/mobile/app/_layout.tsx +++ b/apps/mobile/app/_layout.tsx @@ -12,7 +12,6 @@ import { StyledStack } from "@/components/navigation/stack"; import { Providers } from "@/lib/providers"; import useAppSettings from "@/lib/settings"; import { cn } from "@/lib/utils"; -import { BottomSheetModalProvider } from "@gorhom/bottom-sheet"; import { useColorScheme } from "nativewind"; export default function RootLayout() { @@ -37,44 +36,45 @@ export default function RootLayout() { - - + - + - - - - - - - - - + /> + + + + + + diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsx index b9ab7d11..f70474a9 100644 --- a/apps/mobile/app/dashboard/(tabs)/index.tsx +++ b/apps/mobile/app/dashboard/(tabs)/index.tsx @@ -1,9 +1,7 @@ -import { useRef } from "react"; import { Platform, Pressable, Text, View } from "react-native"; import * as Haptics from "expo-haptics"; import * as ImagePicker from "expo-image-picker"; import { router } from "expo-router"; -import NoteEditorModal from "@/components/bookmarks/NewBookmarkModal"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; import { TailwindResolver } from "@/components/TailwindResolver"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; @@ -11,7 +9,6 @@ import PageTitle from "@/components/ui/PageTitle"; import { useToast } from "@/components/ui/Toast"; import useAppSettings from "@/lib/settings"; import { useUploadAsset } from "@/lib/upload"; -import { BottomSheetModal } from "@gorhom/bottom-sheet"; import { MenuView } from "@react-native-menu/menu"; import { Plus, Search } from "lucide-react-native"; @@ -77,11 +74,8 @@ function HeaderRight({ } export default function Home() { - const newBookmarkModal = useRef(null); - return ( - newBookmarkModal.current?.present()} + openNewBookmarkModal={() => + router.push("/dashboard/bookmarks/new") + } /> (null); useEffect(() => { setRefreshing(isPending); @@ -117,14 +114,13 @@ export default function Lists() { return ( - newListModal.current?.present()} + openNewListModal={() => router.push("/dashboard/lists/new")} /> } diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsx index 609f06f5..bc743c7a 100644 --- a/apps/mobile/app/dashboard/_layout.tsx +++ b/apps/mobile/app/dashboard/_layout.tsx @@ -49,6 +49,49 @@ export default function Dashboard() { headerTransparent: true, }} /> + + + + + (); - const { toast } = useToast(); - const router = useRouter(); - const invalidateAllBookmarks = - api.useUtils().bookmarks.getBookmarks.invalidate; - - const { mutate } = api.bookmarks.createBookmark.useMutation({ - onSuccess: (resp) => { - if (resp.alreadyExists) { - toast({ - message: "Bookmark already exists", - }); - } - invalidateAllBookmarks(); - if (router.canGoBack()) { - router.replace("../"); - } else { - router.replace("dashboard"); - } - }, - onError: (e) => { - let message; - if (e.data?.zodError) { - const zodError = e.data.zodError; - message = JSON.stringify(zodError); - } else { - message = `Something went wrong: ${e.message}`; - } - setError(message); - }, - }); - - return ( - - {error && ( - {error} - )} - -