From e40a18132119a90d9b4bf035ecf741b930342688 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 16:03:13 +0000 Subject: mobile: Add support for manually adding bookmarks --- packages/mobile/app/dashboard/(tabs)/index.tsx | 28 ++++++++++++- packages/mobile/app/dashboard/_layout.tsx | 14 +++++++ packages/mobile/app/dashboard/add-link.tsx | 57 ++++++++++++++++++++++++++ packages/mobile/app/dashboard/add-note.tsx | 53 ++++++++++++++++++++++++ packages/mobile/package.json | 1 + 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 packages/mobile/app/dashboard/add-link.tsx create mode 100644 packages/mobile/app/dashboard/add-note.tsx (limited to 'packages') diff --git a/packages/mobile/app/dashboard/(tabs)/index.tsx b/packages/mobile/app/dashboard/(tabs)/index.tsx index 07516f3b..b2349525 100644 --- a/packages/mobile/app/dashboard/(tabs)/index.tsx +++ b/packages/mobile/app/dashboard/(tabs)/index.tsx @@ -1,5 +1,31 @@ +import { Link, Stack } from "expo-router"; +import { SquarePen, Link as LinkIcon } from "lucide-react-native"; +import { View } from "react-native"; + import BookmarkList from "@/components/bookmarks/BookmarkList"; +function HeaderRight() { + return ( + + + + + + + + + ); +} + export default function Home() { - return ; + return ( + <> + , + }} + /> + + + ); } diff --git a/packages/mobile/app/dashboard/_layout.tsx b/packages/mobile/app/dashboard/_layout.tsx index 4dd03d95..ff2384d2 100644 --- a/packages/mobile/app/dashboard/_layout.tsx +++ b/packages/mobile/app/dashboard/_layout.tsx @@ -19,6 +19,20 @@ export default function Dashboard() { title: "🗄️ Archive", }} /> + + ); } diff --git a/packages/mobile/app/dashboard/add-link.tsx b/packages/mobile/app/dashboard/add-link.tsx new file mode 100644 index 00000000..69a9c7a2 --- /dev/null +++ b/packages/mobile/app/dashboard/add-link.tsx @@ -0,0 +1,57 @@ +import { useRouter } from "expo-router"; +import { useState } from "react"; +import { View, Text } from "react-native"; + +import { Button } from "@/components/ui/Button"; +import { Input } from "@/components/ui/Input"; +import { api } from "@/lib/trpc"; + +export default function AddNote() { + const [text, setText] = useState(""); + const [error, setError] = useState(); + const router = useRouter(); + const invalidateAllBookmarks = + api.useUtils().bookmarks.getBookmarks.invalidate; + + const { mutate } = api.bookmarks.createBookmark.useMutation({ + onSuccess: () => { + invalidateAllBookmarks(); + if (router.canGoBack()) { + router.replace("../"); + } else { + router.replace("dashboard"); + } + }, + onError: (e) => { + let message; + if (e.data?.code === "BAD_REQUEST") { + const error = JSON.parse(e.message)[0]; + message = error.message; + } else { + message = `Something went wrong: ${e.message}`; + } + setError(message); + }, + }); + + return ( + + {error && ( + {error} + )} + +