|
1 | 1 | import { FeedViewType } from "@follow/constants" |
2 | 2 | import { useFeedById } from "@follow/store/feed/hooks" |
| 3 | +import { useIsSubscribed } from "@follow/store/subscription/hooks" |
| 4 | +import { isBizId } from "@follow/utils" |
3 | 5 | import { useMemo } from "react" |
| 6 | +import { useTranslation } from "react-i18next" |
| 7 | +import { Pressable } from "react-native" |
4 | 8 | import { RootSiblingParent } from "react-native-root-siblings" |
5 | 9 | import { useSafeAreaInsets } from "react-native-safe-area-context" |
6 | 10 |
|
7 | 11 | import { BottomTabBarHeightContext } from "@/src/components/layouts/tabbar/contexts/BottomTabBarHeightContext" |
| 12 | +import { Text } from "@/src/components/ui/typography/Text" |
| 13 | +import { useNavigation } from "@/src/lib/navigation/hooks" |
8 | 14 | import type { NavigationControllerView } from "@/src/lib/navigation/types" |
9 | 15 | import { EntryListSelector } from "@/src/modules/entry-list/EntryListSelector" |
10 | 16 | import { EntryListContext, useEntries, useSelectedView } from "@/src/modules/screen/atoms" |
11 | 17 | import { TimelineHeader } from "@/src/modules/screen/TimelineSelectorProvider" |
| 18 | +import { FollowScreen } from "@/src/screens/(modal)/FollowScreen" |
12 | 19 |
|
13 | 20 | export const FeedScreen: NavigationControllerView<{ |
14 | 21 | feedId: string |
15 | 22 | }> = ({ feedId: feedIdentifier }) => { |
16 | 23 | const insets = useSafeAreaInsets() |
17 | 24 | const feed = useFeedById(feedIdentifier) |
| 25 | + const navigation = useNavigation() |
| 26 | + const isSubscribed = useIsSubscribed(feedIdentifier) |
| 27 | + const { t } = useTranslation("common") |
18 | 28 |
|
19 | 29 | return ( |
20 | 30 | <EntryListContext value={useMemo(() => ({ type: "feed" }), [])}> |
21 | 31 | <RootSiblingParent> |
22 | 32 | <BottomTabBarHeightContext value={insets.bottom}> |
23 | 33 | <TimelineHeader feedId={feed?.id} /> |
24 | 34 | <FeedScreenEntryList /> |
| 35 | + {!isSubscribed && isBizId(feedIdentifier) && ( |
| 36 | + <Pressable |
| 37 | + className="bg-accent absolute bottom-10 left-1/2 z-10 m-2 mx-auto -translate-x-1/2 rounded-full px-4 py-2" |
| 38 | + onPress={() => { |
| 39 | + navigation.presentControllerView(FollowScreen, { |
| 40 | + id: feedIdentifier, |
| 41 | + type: "feed", |
| 42 | + }) |
| 43 | + }} |
| 44 | + > |
| 45 | + <Text className="font-bold text-white">{t("words.follow")}</Text> |
| 46 | + </Pressable> |
| 47 | + )} |
25 | 48 | </BottomTabBarHeightContext> |
26 | 49 | </RootSiblingParent> |
27 | 50 | </EntryListContext> |
|
0 commit comments