aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/components
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-08-26 18:00:00 +0300
committerMohamedBassem <me@mbassem.com>2024-08-26 18:00:42 +0300
commit140554021e83ca375845584f8d7e5e476434f1c0 (patch)
tree2dfd49ebd1718e2508b50a4c6828c5d8dce72a23 /apps/mobile/components
parent410b0e78962566d9eb97710e834bf0a477b8cef2 (diff)
downloadkarakeep-140554021e83ca375845584f8d7e5e476434f1c0.tar.zst
feature(mobile): Add ability to create basic lists from the app
Diffstat (limited to 'apps/mobile/components')
-rw-r--r--apps/mobile/components/lists/NewListModal.tsx80
1 files changed, 80 insertions, 0 deletions
diff --git a/apps/mobile/components/lists/NewListModal.tsx b/apps/mobile/components/lists/NewListModal.tsx
new file mode 100644
index 00000000..d31ac362
--- /dev/null
+++ b/apps/mobile/components/lists/NewListModal.tsx
@@ -0,0 +1,80 @@
+import React, { useState } from "react";
+import { Text, View } from "react-native";
+import {
+ BottomSheetBackdrop,
+ BottomSheetModal,
+ BottomSheetModalProps,
+ BottomSheetView,
+ useBottomSheetModal,
+} from "@gorhom/bottom-sheet";
+
+import { useCreateBookmarkList } from "@hoarder/shared-react/hooks/lists";
+
+import { Button } from "../ui/Button";
+import { Input } from "../ui/Input";
+import PageTitle from "../ui/PageTitle";
+import { useToast } from "../ui/Toast";
+
+const NewListModal = React.forwardRef<
+ BottomSheetModal,
+ Omit<BottomSheetModalProps, "children" | "backdropComponent" | "onDismiss">
+>(({ ...props }, ref) => {
+ const { dismiss } = useBottomSheetModal();
+ const { toast } = useToast();
+ const [text, setText] = useState("");
+
+ const { mutate, isPending } = useCreateBookmarkList({
+ onSuccess: () => {
+ dismiss();
+ },
+ onError: () => {
+ toast({
+ message: "Something went wrong",
+ variant: "destructive",
+ });
+ },
+ });
+
+ const onSubmit = () => {
+ mutate({
+ name: text,
+ icon: "🚀",
+ });
+ };
+
+ return (
+ <View>
+ <BottomSheetModal
+ ref={ref}
+ onDismiss={() => setText("")}
+ backdropComponent={(props) => (
+ <BottomSheetBackdrop
+ appearsOnIndex={0}
+ disappearsOnIndex={-1}
+ {...props}
+ />
+ )}
+ {...props}
+ >
+ <PageTitle title="New List" />
+ <BottomSheetView className="gap-2 px-4">
+ <BottomSheetView className="flex flex-row items-center gap-1">
+ <Text className="shrink p-2">🚀</Text>
+ <Input
+ className="flex-1"
+ onChangeText={setText}
+ placeholder="List Name"
+ autoFocus
+ autoCapitalize={"none"}
+ />
+ </BottomSheetView>
+ <Button disabled={isPending} onPress={onSubmit} label="Save" />
+ </BottomSheetView>
+ </BottomSheetModal>
+ </View>
+ );
+});
+
+NewListModal.displayName = "NewListModal";
+
+export default NewListModal;