diff --git a/apps/mobile/src/components/ui/datetime/RelativeDateTime.tsx b/apps/mobile/src/components/ui/datetime/RelativeDateTime.tsx index 7ba0e153e..36d65ea3e 100644 --- a/apps/mobile/src/components/ui/datetime/RelativeDateTime.tsx +++ b/apps/mobile/src/components/ui/datetime/RelativeDateTime.tsx @@ -4,8 +4,7 @@ import { useTranslation } from "react-i18next" import type { TextProps } from "react-native" import Animated, { FadeOut } from "react-native-reanimated" -import { ItemPressableStyle } from "../pressable/enum" -import { ItemPressable } from "../pressable/ItemPressable" +import { NativePressable } from "../pressable/NativePressable" const formatTemplateString = "lll" @@ -78,9 +77,7 @@ export const RelativeDateTime = ({ }, [date, displayAbsoluteTimeAfterDay, dateFormatTemplate, mode]) return ( - { setMode((mode) => (mode === "relative" ? "absolute" : "relative")) @@ -91,6 +88,6 @@ export const RelativeDateTime = ({ ? `${relative}${t("space")}${postfixText ?? t("words.ago")}` : memoizedFormatTime} - + ) } diff --git a/apps/mobile/src/components/ui/pressable/IosItemPressable.ios.tsx b/apps/mobile/src/components/ui/pressable/IosItemPressable.ios.tsx new file mode 100644 index 000000000..afa8f1bf1 --- /dev/null +++ b/apps/mobile/src/components/ui/pressable/IosItemPressable.ios.tsx @@ -0,0 +1,14 @@ +import { requireNativeView } from "expo" +import { cssInterop } from "nativewind" +import type { ViewProps } from "react-native" + +const NativeItemPressable = requireNativeView< + ViewProps & { + onItemPress: () => any + touchHighlight?: boolean + } +>("ItemPressable") +cssInterop(NativeItemPressable, { + className: "style", +}) +export { NativeItemPressable } diff --git a/apps/mobile/src/components/ui/pressable/IosItemPressable.tsx b/apps/mobile/src/components/ui/pressable/IosItemPressable.tsx new file mode 100644 index 000000000..27da52fc6 --- /dev/null +++ b/apps/mobile/src/components/ui/pressable/IosItemPressable.tsx @@ -0,0 +1,12 @@ +import type { FC } from "react" +import type { ViewProps } from "react-native" + +const NativeItemPressable: FC< + ViewProps & { + onItemPress?: () => any + touchHighlight?: boolean + } +> = () => { + throw new Error("NativeItemPressable is not supported on iOS") +} +export { NativeItemPressable } diff --git a/apps/mobile/src/components/ui/pressable/ItemPressable.ios.tsx b/apps/mobile/src/components/ui/pressable/ItemPressable.ios.tsx index 9db563a58..24aee7a2f 100644 --- a/apps/mobile/src/components/ui/pressable/ItemPressable.ios.tsx +++ b/apps/mobile/src/components/ui/pressable/ItemPressable.ios.tsx @@ -1,26 +1,16 @@ import { cn } from "@follow/utils" -import { requireNativeView } from "expo" -import { cssInterop } from "nativewind" import type { FC } from "react" import { memo } from "react" import type { ViewProps } from "react-native" import { ItemPressableStyle } from "./enum" +import { NativeItemPressable } from "./IosItemPressable" export interface ItemPressableProps extends ViewProps { itemStyle?: ItemPressableStyle touchHighlight?: boolean onPress?: () => any } -const NativeItemPressable = requireNativeView< - ViewProps & { - onItemPress: () => any - touchHighlight?: boolean - } ->("ItemPressable") -cssInterop(NativeItemPressable, { - className: "style", -}) export const ItemPressable: FC = memo( ({ children, itemStyle = ItemPressableStyle.Grouped, className, ...props }) => { diff --git a/apps/mobile/src/components/ui/pressable/NativePressable.ios.tsx b/apps/mobile/src/components/ui/pressable/NativePressable.ios.tsx new file mode 100644 index 000000000..2771a9df7 --- /dev/null +++ b/apps/mobile/src/components/ui/pressable/NativePressable.ios.tsx @@ -0,0 +1,10 @@ +import { NativeItemPressable } from "./IosItemPressable" +import type { NativePressableProps } from "./NativePressable.types" + +export const NativePressable = ({ children, onPress, ...props }: NativePressableProps) => { + return ( + + {children} + + ) +} diff --git a/apps/mobile/src/components/ui/pressable/NativePressable.tsx b/apps/mobile/src/components/ui/pressable/NativePressable.tsx new file mode 100644 index 000000000..233e91634 --- /dev/null +++ b/apps/mobile/src/components/ui/pressable/NativePressable.tsx @@ -0,0 +1,11 @@ +import { Pressable } from "react-native" + +import type { NativePressableProps } from "./NativePressable.types" + +/** + * In order to resolve the conflict between the gesture handling of the native view and the RCTSurfaceGestureHandler in React Native. + * + */ +export const NativePressable = ({ children, ...props }: NativePressableProps) => { + return {children} +} diff --git a/apps/mobile/src/components/ui/pressable/NativePressable.types.tsx b/apps/mobile/src/components/ui/pressable/NativePressable.types.tsx new file mode 100644 index 000000000..ac0533fa5 --- /dev/null +++ b/apps/mobile/src/components/ui/pressable/NativePressable.types.tsx @@ -0,0 +1,5 @@ +import type { ViewProps } from "react-native" + +export interface NativePressableProps extends ViewProps { + onPress?: () => any +} diff --git a/apps/mobile/src/modules/entry-list/templates/EntryNormalItem.tsx b/apps/mobile/src/modules/entry-list/templates/EntryNormalItem.tsx index 55036ee71..8e7f3f134 100644 --- a/apps/mobile/src/modules/entry-list/templates/EntryNormalItem.tsx +++ b/apps/mobile/src/modules/entry-list/templates/EntryNormalItem.tsx @@ -13,6 +13,7 @@ import { Image } from "@/src/components/ui/image/Image" import { PlatformActivityIndicator } from "@/src/components/ui/loading/PlatformActivityIndicator" import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { NativePressable } from "@/src/components/ui/pressable/NativePressable" import { PauseCuteFiIcon } from "@/src/icons/pause_cute_fi" import { PlayCuteFiIcon } from "@/src/icons/play_cute_fi" import { useNavigation } from "@/src/lib/navigation/hooks" @@ -146,9 +147,7 @@ export const EntryNormalItem = memo( ))} {audio && ( - { if (isLoading) return @@ -174,7 +173,7 @@ export const EntryNormalItem = memo( )} - + )} )} diff --git a/apps/mobile/src/modules/subscription/CategoryGrouped.tsx b/apps/mobile/src/modules/subscription/CategoryGrouped.tsx index c0cc065e3..1fad0bbad 100644 --- a/apps/mobile/src/modules/subscription/CategoryGrouped.tsx +++ b/apps/mobile/src/modules/subscription/CategoryGrouped.tsx @@ -6,6 +6,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withSpring } from "react-na import { GROUPED_LIST_MARGIN } from "@/src/components/ui/grouped/constants" import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { NativePressable } from "@/src/components/ui/pressable/NativePressable" import { RightCuteFiIcon } from "@/src/icons/right_cute_fi" import { useNavigation } from "@/src/lib/navigation/hooks" import { closeDrawer, selectFeed } from "@/src/modules/screen/atoms" @@ -64,9 +65,7 @@ export const CategoryGrouped = memo( "rounded-b-[10px]": isLast && !expanded, })} > - { rotateSharedValue.value = withSpring(expanded ? 0 : 90, {}) @@ -77,7 +76,7 @@ export const CategoryGrouped = memo( - + {category}