From 01b80373364228593b0eb7a9470fbdaf3dfd752a Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 23 Apr 2025 19:40:11 +0800 Subject: [PATCH] feat(mobile): optimize list search result list --- apps/mobile/src/lib/url-builder.ts | 5 + .../discover/search-tabs/SearchFeed.tsx | 187 +++++++++--------- .../discover/search-tabs/SearchList.tsx | 32 ++- 3 files changed, 128 insertions(+), 96 deletions(-) create mode 100644 apps/mobile/src/lib/url-builder.ts diff --git a/apps/mobile/src/lib/url-builder.ts b/apps/mobile/src/lib/url-builder.ts new file mode 100644 index 000000000..7128f3e39 --- /dev/null +++ b/apps/mobile/src/lib/url-builder.ts @@ -0,0 +1,5 @@ +import { UrlBuilder as UrlBuilderClass } from "@follow/utils/src/url-builder" + +import { proxyEnv } from "./proxy-env" + +export const UrlBuilder = new UrlBuilderClass(proxyEnv.WEB_URL) diff --git a/apps/mobile/src/modules/discover/search-tabs/SearchFeed.tsx b/apps/mobile/src/modules/discover/search-tabs/SearchFeed.tsx index 211e72334..f470239ca 100644 --- a/apps/mobile/src/modules/discover/search-tabs/SearchFeed.tsx +++ b/apps/mobile/src/modules/discover/search-tabs/SearchFeed.tsx @@ -5,7 +5,6 @@ import { LinearGradient } from "expo-linear-gradient" import { useAtomValue } from "jotai" import { Text, useWindowDimensions, View } from "react-native" import { ScrollView } from "react-native-gesture-handler" -import Animated, { FadeInUp } from "react-native-reanimated" import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime" import { FeedIcon } from "@/src/components/ui/icon/feed-icon" @@ -72,103 +71,107 @@ const SearchFeedItem = ({ item }: { item: SearchResultItem }) => { const iconColor = useColor("text") return ( - - { - if (item.feed?.id) { - navigation.presentControllerView(FollowScreen, { - id: item.feed.id, - type: "feed", - }) - } - }} - > - {/* Headline */} - - - - - - - {item.feed?.title} + { + if (item.feed?.id) { + navigation.presentControllerView(FollowScreen, { + id: item.feed.id, + type: "feed", + }) + } + }} + > + {/* Headline */} + + + + + + + {item.feed?.title} + + {!!item.feed?.description && ( + + {item.feed?.description} - {!!item.feed?.description && ( - - {item.feed?.description} - - )} - - {/* Subscribe */} - {isSubscribed && ( - - - Followed - - )} - - - - {item.feed?.url} - - - {/* Preview */} - - - {item.entries?.map((entry) => )} - - - - - - {item.subscriptionCount} followers + {/* Subscribe */} + {isSubscribed ? ( + + + Followed + - - {item.updatesPerWeek ? ( - <> - - {item.updatesPerWeek} entries/week - - ) : item.entries?.[0]?.publishedAt ? ( - <> - - Updated - - - ) : null} + ) : ( + + + Follow + + )} + + + + + {item.feed?.url} + + + {/* Preview */} + + + {item.entries?.map((entry) => )} + + + + + + {item.subscriptionCount} followers - - + + {item.updatesPerWeek ? ( + <> + + {item.updatesPerWeek} entries/week + + ) : item.entries?.[0]?.publishedAt ? ( + <> + + Updated + + + ) : null} + + + ) } diff --git a/apps/mobile/src/modules/discover/search-tabs/SearchList.tsx b/apps/mobile/src/modules/discover/search-tabs/SearchList.tsx index 72e298a93..15174345d 100644 --- a/apps/mobile/src/modules/discover/search-tabs/SearchList.tsx +++ b/apps/mobile/src/modules/discover/search-tabs/SearchList.tsx @@ -7,10 +7,14 @@ import { FallbackIcon } from "@/src/components/ui/icon/fallback-icon" import { Image } from "@/src/components/ui/image/Image" import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { RightCuteReIcon } from "@/src/icons/right_cute_re" +import { User3CuteReIcon } from "@/src/icons/user_3_cute_re" import { apiClient } from "@/src/lib/api-fetch" import { useNavigation } from "@/src/lib/navigation/hooks" +import { UrlBuilder } from "@/src/lib/url-builder" import { FollowScreen } from "@/src/screens/(modal)/FollowScreen" import { useSubscriptionByListId } from "@/src/store/subscription/hooks" +import { useColor } from "@/src/theme/colors" import { useSearchPageContext } from "../ctx" import { ItemSeparator } from "./__base" @@ -58,10 +62,12 @@ export const SearchList = () => { const SearchListCard = memo(({ item }: { item: SearchResultItem }) => { const isSubscribed = useSubscriptionByListId(item.list?.id ?? "") const navigation = useNavigation() + const iconColor = useColor("text") + return ( { if (item.list?.id) { navigation.presentControllerView(FollowScreen, { @@ -95,14 +101,32 @@ const SearchListCard = memo(({ item }: { item: SearchResultItem }) => { )} {/* Subscribe */} - {isSubscribed && ( + {isSubscribed ? ( - - Subscribed + + Followed + + + ) : ( + + + Follow )} + + + + {UrlBuilder.shareList(item.list?.id ?? "")} + + + + + + {item.subscriptionCount} followers + + ) })