From cc84e0177753af6e0517e855187b022d80be3226 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 23 Nov 2024 19:28:55 +0000 Subject: ui(mobile): Remove the dedicated search page and add a search bar in home --- apps/mobile/app/dashboard/(tabs)/_layout.tsx | 9 +---- apps/mobile/app/dashboard/(tabs)/index.tsx | 30 +++++++++++---- apps/mobile/app/dashboard/(tabs)/search.tsx | 56 ---------------------------- apps/mobile/app/dashboard/_layout.tsx | 9 +++++ apps/mobile/app/dashboard/search.tsx | 55 +++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 71 deletions(-) delete mode 100644 apps/mobile/app/dashboard/(tabs)/search.tsx create mode 100644 apps/mobile/app/dashboard/search.tsx diff --git a/apps/mobile/app/dashboard/(tabs)/_layout.tsx b/apps/mobile/app/dashboard/(tabs)/_layout.tsx index cf7e473f..cf1eb01f 100644 --- a/apps/mobile/app/dashboard/(tabs)/_layout.tsx +++ b/apps/mobile/app/dashboard/(tabs)/_layout.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Tabs } from "expo-router"; import { StyledTabs } from "@/components/navigation/tabs"; -import { ClipboardList, Home, Search, Settings } from "lucide-react-native"; +import { ClipboardList, Home, Settings } from "lucide-react-native"; export default function TabLayout() { return ( @@ -19,13 +19,6 @@ export default function TabLayout() { tabBarIcon: ({ color }) => , }} /> - , - }} - /> - - newBookmarkModal.current?.present()} - /> + + + + newBookmarkModal.current?.present()} + /> + + router.push("/dashboard/search")} + > + ( + + )} + /> + Search + } /> diff --git a/apps/mobile/app/dashboard/(tabs)/search.tsx b/apps/mobile/app/dashboard/(tabs)/search.tsx deleted file mode 100644 index d29c3b05..00000000 --- a/apps/mobile/app/dashboard/(tabs)/search.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useState } from "react"; -import { View } from "react-native"; -import BookmarkList from "@/components/bookmarks/BookmarkList"; -import FullPageError from "@/components/FullPageError"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; -import FullPageSpinner from "@/components/ui/FullPageSpinner"; -import { Input } from "@/components/ui/Input"; -import PageTitle from "@/components/ui/PageTitle"; -import { api } from "@/lib/trpc"; -import { keepPreviousData } from "@tanstack/react-query"; -import { useDebounce } from "use-debounce"; - -export default function Search() { - const [search, setSearch] = useState(""); - - const [query] = useDebounce(search, 10); - - const onRefresh = api.useUtils().bookmarks.searchBookmarks.invalidate; - - const { data, error, refetch, isPending } = - api.bookmarks.searchBookmarks.useQuery( - { text: query }, - { placeholderData: keepPreviousData }, - ); - - if (error) { - return refetch()} />; - } - - if (!data) { - return ; - } - - return ( - - - - - - } - onRefresh={onRefresh} - isRefreshing={isPending} - /> - - ); -} diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsx index a1a25398..609f06f5 100644 --- a/apps/mobile/app/dashboard/_layout.tsx +++ b/apps/mobile/app/dashboard/_layout.tsx @@ -57,6 +57,15 @@ export default function Dashboard() { headerTransparent: true, }} /> + refetch()} />; + } + + return ( + + + + router.back()}> + Cancel + + + {!data && } + {data && ( + + )} + + ); +} -- cgit v1.2.3-70-g09d2