Skip to content

Commit

Permalink
feat(search): enhance search components with new styles and functiona…
Browse files Browse the repository at this point in the history
…lity

Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Jan 10, 2025
1 parent 4bae36a commit 0227427
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
20 changes: 18 additions & 2 deletions apps/mobile/src/modules/discover/search-tabs/SearchFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FeedViewType } from "@follow/constants"
import { withOpacity } from "@follow/utils"
import { useQuery } from "@tanstack/react-query"
import { Image } from "expo-image"
import { router } from "expo-router"
Expand All @@ -11,8 +12,10 @@ import Animated, { FadeInUp } from "react-native-reanimated"
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
import { LoadingIndicator } from "@/src/components/ui/loading"
import { ItemPressable } from "@/src/components/ui/pressable/item-pressable"
import { SadCuteReIcon } from "@/src/icons/sad_cute_re"
import { apiClient } from "@/src/lib/api-fetch"
import { useSubscriptionByFeedId } from "@/src/store/subscription/hooks"
import { useColor } from "@/src/theme/colors"

import { useSearchPageContext } from "../ctx"
import { BaseSearchPageFlatList, BaseSearchPageRootView, BaseSearchPageScrollView } from "./__base"
Expand All @@ -36,10 +39,23 @@ export const SearchFeed = () => {
enabled: !!searchValue,
})

const textColor = useColor("text")

if (isLoading) {
return (
<BaseSearchPageRootView>
<LoadingIndicator color="#fff" size={32} />
<BaseSearchPageRootView className="items-center justify-center">
<View className="-mt-72" />
<LoadingIndicator color={withOpacity(textColor, 0.7)} size={32} />
</BaseSearchPageRootView>
)
}

if (data?.data.length === 0) {
return (
<BaseSearchPageRootView className="items-center justify-center">
<View className="-mt-72" />
<SadCuteReIcon height={32} width={32} color={withOpacity(textColor, 0.5)} />
<Text className="text-text/50 mt-2">No results found</Text>
</BaseSearchPageRootView>
)
}
Expand Down
15 changes: 11 additions & 4 deletions apps/mobile/src/modules/discover/search-tabs/__base.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cn } from "@follow/utils/src/utils"
import { forwardRef } from "react"
import type { ScrollViewProps } from "react-native"
import { RefreshControl, ScrollView, useWindowDimensions, View } from "react-native"
Expand Down Expand Up @@ -29,13 +30,19 @@ export const BaseSearchPageScrollView = forwardRef<ScrollView, ScrollViewProps>(
},
)

export const BaseSearchPageRootView = ({ children }: { children: React.ReactNode }) => {
export const BaseSearchPageRootView = ({
children,
className,
}: {
children: React.ReactNode
className?: string
}) => {
const windowWidth = useWindowDimensions().width
const insets = useSafeAreaInsets()

const searchBarHeight = useSearchBarHeight()
const offsetTop = searchBarHeight - insets.top
const offsetTop = searchBarHeight
return (
<View className="flex-1" style={{ paddingTop: offsetTop, width: windowWidth }}>
<View className={cn("flex-1", className)} style={{ paddingTop: offsetTop, width: windowWidth }}>
{children}
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/modules/discover/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const SearchHeader: FC<{
className="relative"
onLayout={onLayout}
>
<BlurEffect />
{/* <BlurEffect /> */}
<View style={styles.header}>
<ComposeSearchBar />
</View>
Expand Down

0 comments on commit 0227427

Please sign in to comment.