diff --git a/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx b/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx index d75c0d3b5..be26288f1 100644 --- a/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx +++ b/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx @@ -1,22 +1,17 @@ import { useMemo } from "react" -import { useTranslation } from "react-i18next" -import { Share, View } from "react-native" -import { useColor } from "react-native-uikit-colors" +import { View } from "react-native" import { DefaultHeaderBackButton } from "@/src/components/layouts/header/NavigationHeader" import { NavigationBlurEffectHeader } from "@/src/components/layouts/views/SafeNavigationScrollView" -import { UIBarButton } from "@/src/components/ui/button/UIBarButton" import { TIMELINE_VIEW_SELECTOR_HEIGHT } from "@/src/constants/ui" -import { Share3CuteReIcon } from "@/src/icons/share_3_cute_re" -import { proxyEnv } from "@/src/lib/proxy-env" import { ActionGroup, + FeedShareActionButton, HomeLeftAction, - HomeSharedRightAction, + MarkAllAsReadActionButton, UnreadOnlyActionButton, } from "@/src/modules/screen/action" import { TimelineViewSelector } from "@/src/modules/screen/TimelineViewSelector" -import { getFeed } from "@/src/store/feed/getter" import { useEntryListContext, useFetchEntriesControls, useSelectedFeedTitle } from "./atoms" @@ -50,19 +45,18 @@ export function TimelineSelectorProvider({ )} headerRight={useMemo(() => { const Component = (() => { - const buttonVariant = isFeed ? "secondary" : "primary" - if (isTimeline) - return () => ( - - - - ) - if (isSubscriptions) return () => - if (isFeed) + if (isTimeline || isFeed) return () => ( - - + + + + + ) + if (isSubscriptions) + return () => ( + + ) })() @@ -78,26 +72,3 @@ export function TimelineSelectorProvider({ ) } - -function FeedShareAction({ feedId }: { feedId?: string }) { - const { t } = useTranslation() - const label = useColor("label") - - if (!feedId) return null - return ( - } - onPress={() => { - const feed = getFeed(feedId) - if (!feed) return - const url = `${proxyEnv.WEB_URL}/share/feeds/${feedId}` - Share.share({ - message: `Check out ${feed.title} on Folo: ${url}`, - title: feed.title!, - url, - }) - }} - /> - ) -} diff --git a/apps/mobile/src/modules/screen/action.tsx b/apps/mobile/src/modules/screen/action.tsx index 14b47a2a8..f80c18dea 100644 --- a/apps/mobile/src/modules/screen/action.tsx +++ b/apps/mobile/src/modules/screen/action.tsx @@ -3,7 +3,7 @@ import * as Haptics from "expo-haptics" import type { PropsWithChildren } from "react" import { useCallback } from "react" import { useTranslation } from "react-i18next" -import { TouchableOpacity, View } from "react-native" +import { Share, TouchableOpacity, View } from "react-native" import { setGeneralSetting, useGeneralSettingKey } from "@/src/atoms/settings/general" import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar" @@ -12,11 +12,14 @@ import { AddCuteReIcon } from "@/src/icons/add_cute_re" import { CheckCircleCuteReIcon } from "@/src/icons/check_circle_cute_re" import { RoundCuteFiIcon } from "@/src/icons/round_cute_fi" import { RoundCuteReIcon } from "@/src/icons/round_cute_re" +import { Share3CuteReIcon } from "@/src/icons/share_3_cute_re" import { Dialog } from "@/src/lib/dialog" import { useNavigation } from "@/src/lib/navigation/hooks" +import { proxyEnv } from "@/src/lib/proxy-env" import { toast } from "@/src/lib/toast" import { LoginScreen } from "@/src/screens/(modal)/login" import { ProfileScreen } from "@/src/screens/(modal)/profile" +import { getFeed } from "@/src/store/feed/getter" import { useWhoami } from "@/src/store/user/hooks" import { accentColor, useColor } from "@/src/theme/colors" @@ -54,27 +57,25 @@ export function HomeLeftAction() { ) } -export function HomeSharedRightAction(props: PropsWithChildren) { - const { t } = useTranslation() - return ( - - {props.children} - - } - onPress={() => { - Dialog.show(MarkAllAsReadDialog) - }} - /> - - ) -} - interface HeaderActionButtonProps { variant?: "primary" | "secondary" } +export const MarkAllAsReadActionButton = ({ variant = "primary" }: HeaderActionButtonProps) => { + const { t } = useTranslation() + const { size, color } = useButtonVariant({ variant }) + + return ( + } + onPress={() => { + Dialog.show(MarkAllAsReadDialog) + }} + /> + ) +} + const useButtonVariant = ({ variant = "primary" }: HeaderActionButtonProps) => { const label = useColor("label") const size = 24 @@ -121,3 +122,29 @@ export const AddFeedButton = () => { /> ) } + +export const FeedShareActionButton = ({ + feedId, + variant = "primary", +}: { feedId?: string } & HeaderActionButtonProps) => { + const { t } = useTranslation() + const { size, color } = useButtonVariant({ variant }) + + if (!feedId) return null + return ( + } + onPress={() => { + const feed = getFeed(feedId) + if (!feed) return + const url = `${proxyEnv.WEB_URL}/share/feeds/${feedId}` + Share.share({ + message: `Check out ${feed.title} on Folo: ${url}`, + title: feed.title!, + url, + }) + }} + /> + ) +}