From 5522e20104da6afe2e4667cf45dbbbbc0e838865 Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
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
---
 .../components/bookmarks/NewBookmarkModal.tsx      | 98 ----------------------
 1 file changed, 98 deletions(-)
 delete mode 100644 apps/mobile/components/bookmarks/NewBookmarkModal.tsx

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

diff --git a/apps/mobile/components/bookmarks/NewBookmarkModal.tsx b/apps/mobile/components/bookmarks/NewBookmarkModal.tsx
deleted file mode 100644
index 218c54b8..00000000
--- a/apps/mobile/components/bookmarks/NewBookmarkModal.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import React, { useState } from "react";
-import { Text, View } from "react-native";
-import {
-  BottomSheetBackdrop,
-  BottomSheetModal,
-  BottomSheetModalProps,
-  BottomSheetView,
-  useBottomSheetModal,
-} from "@gorhom/bottom-sheet";
-
-import { useCreateBookmark } from "@hoarder/shared-react/hooks/bookmarks";
-import { BookmarkTypes } from "@hoarder/shared/types/bookmarks";
-
-import { Button } from "../ui/Button";
-import { Input } from "../ui/Input";
-import PageTitle from "../ui/PageTitle";
-import { useToast } from "../ui/Toast";
-
-const NoteEditorModal = React.forwardRef<
-  BottomSheetModal,
-  Omit<BottomSheetModalProps, "children" | "backdropComponent" | "onDismiss">
->(({ ...props }, ref) => {
-  const { dismiss } = useBottomSheetModal();
-
-  const [text, setText] = useState("");
-  const [error, setError] = useState<string | undefined>();
-  const { toast } = useToast();
-
-  const { mutate: createBookmark } = useCreateBookmark({
-    onSuccess: (resp) => {
-      if (resp.alreadyExists) {
-        toast({
-          message: "Bookmark already exists",
-        });
-      }
-      setText("");
-      dismiss();
-    },
-    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);
-    },
-  });
-
-  const onSubmit = () => {
-    const data = text.trim();
-    try {
-      const url = new URL(data);
-      if (url.protocol != "http:" && url.protocol != "https:") {
-        throw new Error(`Unsupported URL protocol: ${url.protocol}`);
-      }
-      createBookmark({ type: BookmarkTypes.LINK, url: data });
-    } catch (e: unknown) {
-      createBookmark({ type: BookmarkTypes.TEXT, text: data });
-    }
-  };
-
-  return (
-    <View>
-      <BottomSheetModal
-        ref={ref}
-        backdropComponent={(props) => (
-          <BottomSheetBackdrop
-            appearsOnIndex={0}
-            disappearsOnIndex={-1}
-            {...props}
-          />
-        )}
-        {...props}
-      >
-        <PageTitle title="New Bookmark" />
-        <BottomSheetView className="gap-2 p-4">
-          {error && (
-            <Text className="w-full text-center text-red-500">{error}</Text>
-          )}
-          <Input
-            onChangeText={setText}
-            multiline
-            placeholder="What's on your mind?"
-            autoFocus
-            autoCapitalize={"none"}
-            textAlignVertical="top"
-          />
-          <Button onPress={onSubmit} label="Save" />
-        </BottomSheetView>
-      </BottomSheetModal>
-    </View>
-  );
-});
-NoteEditorModal.displayName = "NewBookmarkModal";
-
-export default NoteEditorModal;
-- 
cgit v1.2.3-70-g09d2

