diff --git a/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx b/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx index 0e9fb9f56..2fe31eb4f 100644 --- a/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx +++ b/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx @@ -39,6 +39,7 @@ type SafeNavigationScrollViewProps = Omit & { contentViewClassName?: string Header?: React.ReactNode + ScrollViewBottom?: React.ReactNode } & PropsWithChildren export interface ForwardedSafeNavigationScrollView extends ScrollView { @@ -54,6 +55,7 @@ export const SafeNavigationScrollView = ({ contentViewClassName, contentViewStyle, Header, + ScrollViewBottom, ...props }: SafeNavigationScrollViewProps & { ref?: React.Ref }) => { const insets = useSafeAreaInsets() @@ -134,6 +136,7 @@ export const SafeNavigationScrollView = ({ {children} + {ScrollViewBottom} diff --git a/apps/mobile/src/modules/entry-content/use-pull-up-to-next.tsx b/apps/mobile/src/modules/entry-content/use-pull-up-to-next.tsx index 46bc73ddc..880ed7ace 100644 --- a/apps/mobile/src/modules/entry-content/use-pull-up-to-next.tsx +++ b/apps/mobile/src/modules/entry-content/use-pull-up-to-next.tsx @@ -1,10 +1,61 @@ +import { cn } from "@follow/utils" import * as Haptics from "expo-haptics" import { useCallback, useRef, useState } from "react" +import { useTranslation } from "react-i18next" import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native" +import { Text, View } from "react-native" import type { ReanimatedScrollEvent } from "react-native-reanimated/lib/typescript/hook/commonTypes" +import { useSafeAreaInsets } from "react-native-safe-area-context" +import { useColor } from "react-native-uikit-colors" + +import { ArrowLeftCuteReIcon } from "@/src/icons/arrow_left_cute_re" + +interface EntryPullUpToNextProps { + active: boolean + hide?: boolean +} + +/** + * Component that handles pulling up to navigate to the next unread entry + */ +const EntryPullUpToNext = ({ active, hide = false }: EntryPullUpToNextProps) => { + const { t } = useTranslation() + const insets = useSafeAreaInsets() + const textColor = useColor("secondaryLabel") + const iconColor = useColor("label") + + return ( + + + + + + + {active ? t("entry.release_to_next_entry") : t("entry.pull_up_to_next_entry")} + + + + ) +} export const usePullUpToNext = ({ - enabled: enabled = true, + enabled = true, onRefresh, progressViewOffset = 70, }: { @@ -14,6 +65,7 @@ export const usePullUpToNext = ({ } = {}) => { const dragging = useRef(false) const isOverThreshold = useRef(false) + const [dragState, setDragState] = useState(false) const [refreshing, setRefreshing] = useState(false) const onScroll = useCallback( @@ -50,6 +102,7 @@ export const usePullUpToNext = ({ return } dragging.current = true + setDragState(true) }, [dragging], ) @@ -57,6 +110,7 @@ export const usePullUpToNext = ({ const onScrollEndDrag = useCallback( (event: NativeSyntheticEvent) => { dragging.current = false + setDragState(false) const velocity = event.nativeEvent.velocity?.y || 0 if (isOverThreshold.current && velocity < 3) { onRefresh?.() @@ -70,7 +124,10 @@ export const usePullUpToNext = ({ if (!enabled) { return { scrollViewEventHandlers: {}, - pullUpViewProps: {}, + pullUpViewProps: { + active: false, + hide: dragState, + } satisfies EntryPullUpToNextProps, EntryPullUpToNext: () => null, } } @@ -82,7 +139,9 @@ export const usePullUpToNext = ({ onScrollEndDrag, }, pullUpViewProps: { - refreshing, - }, + active: refreshing, + hide: !dragState, + } satisfies EntryPullUpToNextProps, + EntryPullUpToNext, } } diff --git a/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx b/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx index 88cc91755..f568a871a 100644 --- a/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx +++ b/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx @@ -66,7 +66,7 @@ export const EntryDetailScreen: NavigationControllerView<{ return entryIds[currentEntryIdx + 1] }, [entryId, entryIds]) - const { scrollViewEventHandlers } = usePullUpToNext({ + const { EntryPullUpToNext, scrollViewEventHandlers, pullUpViewProps } = usePullUpToNext({ enabled: !!nextEntryId, onRefresh: useCallback(() => { if (!nextEntryId) return @@ -85,6 +85,7 @@ export const EntryDetailScreen: NavigationControllerView<{ } + ScrollViewBottom={} automaticallyAdjustContentInsets={false} contentContainerClassName="flex min-h-full pb-16" {...scrollViewEventHandlers} diff --git a/locales/mobile/default/en.json b/locales/mobile/default/en.json index d0483d855..b6c3324d2 100644 --- a/locales/mobile/default/en.json +++ b/locales/mobile/default/en.json @@ -1,4 +1,6 @@ { + "entry.pull_up_to_next_entry": "Pull up to go to the next entry", + "entry.release_to_next_entry": "Release to go to the next entry", "login.back": "Back", "login.continueWith": "Continue with {{provider}}", "login.have_account": "Already have an account? Sign in", diff --git a/locales/mobile/default/zh-CN.json b/locales/mobile/default/zh-CN.json index 2293ab150..918b44eb2 100644 --- a/locales/mobile/default/zh-CN.json +++ b/locales/mobile/default/zh-CN.json @@ -1,4 +1,6 @@ { + "entry.pull_up_to_next_entry": "继续上拉查看下一条内容", + "entry.release_to_next_entry": "松开查看下一条内容", "login.back": "返回", "login.continueWith": "使用 {{provider}} 继续", "login.have_account": "已有账户?登录",