Skip to content

Commit bca4987

Browse files
committed
refactor: extract PullUpIndicatorIos component
1 parent 6730e09 commit bca4987

2 files changed

Lines changed: 53 additions & 55 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { cn } from "@follow/utils"
2+
import { useTranslation } from "react-i18next"
3+
import { Text, View } from "react-native"
4+
import { useSafeAreaInsets } from "react-native-safe-area-context"
5+
import { useColor } from "react-native-uikit-colors"
6+
7+
import { ArrowLeftCuteReIcon } from "@/src/icons/arrow_left_cute_re"
8+
9+
import type { UsePullUpToNextReturn } from "./types"
10+
11+
/**
12+
* Component that handles pulling up to navigate to the next unread entry
13+
*/
14+
export const PullUpIndicatorIos: UsePullUpToNextReturn["EntryPullUpToNext"] = ({
15+
active,
16+
hide = false,
17+
}) => {
18+
const { t } = useTranslation()
19+
const insets = useSafeAreaInsets()
20+
const textColor = useColor("secondaryLabel")
21+
const iconColor = useColor("label")
22+
23+
return (
24+
<View
25+
className={cn(
26+
"absolute bottom-0 flex w-full translate-y-full flex-row items-center justify-center gap-2 pt-4 transition-all duration-200",
27+
hide ? "opacity-0" : "opacity-100",
28+
)}
29+
style={{ paddingBottom: insets.bottom + 20 }}
30+
>
31+
<View
32+
className={cn(
33+
"flex flex-row items-center gap-2 transition-all duration-200",
34+
active ? "opacity-50" : "opacity-80",
35+
)}
36+
>
37+
<View
38+
className={cn(
39+
"rotate-90 transition-all duration-200",
40+
active ? "opacity-0" : "opacity-100",
41+
)}
42+
>
43+
<ArrowLeftCuteReIcon width={16} height={16} color={iconColor} />
44+
</View>
45+
<Text style={{ color: textColor }}>
46+
{active ? t("entry.release_to_next_entry") : t("entry.pull_up_to_next_entry")}
47+
</Text>
48+
</View>
49+
</View>
50+
)
51+
}

apps/mobile/src/modules/entry-content/pull-up-navigation/use-pull-up-navigation.tsx

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import { cn } from "@follow/utils"
21
import * as Haptics from "expo-haptics"
32
import { useCallback, useRef, useState } from "react"
4-
import { useTranslation } from "react-i18next"
53
import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native"
6-
import { View } from "react-native"
74
import { useSharedValue } from "react-native-reanimated"
85
import type { ReanimatedScrollEvent } from "react-native-reanimated/lib/typescript/hook/commonTypes"
9-
import { useSafeAreaInsets } from "react-native-safe-area-context"
10-
import { useColor } from "react-native-uikit-colors"
11-
12-
import { Text } from "@/src/components/ui/typography/Text"
13-
import { ArrowLeftCuteReIcon } from "@/src/icons/arrow_left_cute_re"
146

7+
import { PullUpIndicatorIos } from "./PullUpIndicatorIos"
158
import type { UsePullUpToNextProps, UsePullUpToNextReturn } from "./types"
169

1710
// eslint-disable-next-line react-refresh/only-export-components
@@ -21,52 +14,6 @@ const EmptyGestureWrapper: UsePullUpToNextReturn["GestureWrapper"] = ({
2114
children?: React.ReactNode
2215
}) => children
2316

24-
/**
25-
* Component that handles pulling up to navigate to the next unread entry
26-
*/
27-
const EntryPullUpToNext: UsePullUpToNextReturn["EntryPullUpToNext"] = ({
28-
active,
29-
hide = false,
30-
}) => {
31-
const { t } = useTranslation()
32-
const insets = useSafeAreaInsets()
33-
const textColor = useColor("secondaryLabel")
34-
const iconColor = useColor("label")
35-
return (
36-
<View
37-
className={cn(
38-
"absolute bottom-0 flex w-full translate-y-full flex-row items-center justify-center gap-2 pt-4 transition-all duration-200",
39-
hide ? "opacity-0" : "opacity-100",
40-
)}
41-
style={{
42-
paddingBottom: insets.bottom + 20,
43-
}}
44-
>
45-
<View
46-
className={cn(
47-
"flex flex-row items-center gap-2 transition-all duration-200",
48-
active ? "opacity-50" : "opacity-80",
49-
)}
50-
>
51-
<View
52-
className={cn(
53-
"rotate-90 transition-all duration-200",
54-
active ? "opacity-0" : "opacity-100",
55-
)}
56-
>
57-
<ArrowLeftCuteReIcon width={16} height={16} color={iconColor} />
58-
</View>
59-
<Text
60-
style={{
61-
color: textColor,
62-
}}
63-
>
64-
{active ? t("entry.release_to_next_entry") : t("entry.pull_up_to_next_entry")}
65-
</Text>
66-
</View>
67-
</View>
68-
)
69-
}
7017
export const usePullUpToNext = ({
7118
enabled = true,
7219
onRefresh,
@@ -155,7 +102,7 @@ export const usePullUpToNext = ({
155102
hide: !dragState,
156103
translateY,
157104
} satisfies UsePullUpToNextReturn["pullUpViewProps"],
158-
EntryPullUpToNext,
105+
EntryPullUpToNext: PullUpIndicatorIos,
159106
GestureWrapper: EmptyGestureWrapper,
160107
gestureWrapperProps: {
161108
enabled: false,

0 commit comments

Comments
 (0)