Skip to content
TypeScript

fix(mobile): restore native scroll-edge effects on forms and PRs (#18507)

Julius Marminge6f6197c4657f
diff --git a/apps/mobile/src/components/ScreenScrollView.tsx b/apps/mobile/src/components/ScreenScrollView.tsx
index 509feeb3972..c41524e3b91 100644
--- a/apps/mobile/src/components/ScreenScrollView.tsx
+++ b/apps/mobile/src/components/ScreenScrollView.tsx
@@ -1,5 +1,6 @@
import type { ComponentProps } from "react";
-import { Platform, ScrollView } from "react-native";
+import { Platform } from "react-native";
+import { NativeScrollView as ScrollView } from "../native/NativeScrollViewMarker";
/** Keeps forms and settings readable inside a wide pane while its surface fills the screen. */
export function ScreenScrollView(props: ComponentProps<typeof ScrollView>) {
diff --git a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
index 795f72bcd48..45bd8de8d08 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
@@ -5,7 +5,7 @@ import type { PullRequestThreadComment } from "@t3tools/contracts";
import { useRef, useState } from "react";
import { ActivityIndicator, Platform, ScrollView, View } from "react-native";
import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
-import { ScrollViewMarker } from "react-native-screens";
+import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
@@ -153,7 +153,7 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
/>
</NativeHeaderToolbar>
) : null}
- <ScrollViewMarker style={{ flex: 1 }} scrollEdgeEffects={{ top: "soft", bottom: "soft" }}>
+ <ScrollViewMarker style={{ flex: 1 }}>
<ScrollView
className="flex-1"
contentInsetAdjustmentBehavior="automatic"
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 6e3328d915f..4f47ee169d4 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -52,7 +52,7 @@ import {
StyleSheet,
View,
} from "react-native";
-import { ScrollViewMarker } from "react-native-screens";
+import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/AppText";
@@ -115,7 +115,7 @@ const EMPTY_IDS: readonly string[] = [];
function PullRequestTabScrollView(props: ScrollViewProps) {
const insets = useSafeAreaInsets();
return (
- <ScrollViewMarker style={{ flex: 1 }} scrollEdgeEffects={{ top: "soft", bottom: "soft" }}>
+ <ScrollViewMarker style={{ flex: 1 }}>
<ScrollView
{...props}
automaticallyAdjustContentInsets={false}
diff --git a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
index 253c64c0465..1ea683695c4 100644
--- a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
@@ -1,7 +1,8 @@
+import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { useNavigation } from "@react-navigation/native";
import { AsyncResult } from "effect/reactivity";
-import { Platform, ScrollView, View } from "react-native";
+import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
diff --git a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
index 5226f8a0ed1..56cb9574977 100644
--- a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
@@ -1,7 +1,8 @@
+import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { useNavigation } from "@react-navigation/native";
import { AsyncResult } from "effect/reactivity";
-import { Platform, ScrollView, View } from "react-native";
+import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
diff --git a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
index 9013258f328..f4303a659cc 100644
--- a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
@@ -1,8 +1,9 @@
+import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
import { getRecordingPermissionsAsync, requestRecordingPermissionsAsync } from "expo-audio";
import { useCallback, useEffect, useState } from "react";
-import { AppState, Linking, Pressable, ScrollView, View } from "react-native";
+import { AppState, Linking, Pressable, View } from "react-native";
import Reanimated, { ReduceMotion, useAnimatedStyle, withTiming } from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
diff --git a/apps/mobile/src/native/NativeScrollViewMarker.tsx b/apps/mobile/src/native/NativeScrollViewMarker.tsx
new file mode 100644
index 00000000000..865b301535a
--- /dev/null
+++ b/apps/mobile/src/native/NativeScrollViewMarker.tsx
@@ -0,0 +1,31 @@
+import { createContext, use, type ComponentProps } from "react";
+import { Platform, ScrollView } from "react-native";
+import { ScrollViewMarker } from "react-native-screens";
+import { nativeHeaderScrollEdgeEffects } from "./scrollEdgeEffects";
+
+type ScrollEdgeEffects = ComponentProps<typeof ScrollViewMarker>["scrollEdgeEffects"];
+
+const DEFAULT_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
+
+export const NativeScrollEdgeEffectsContext = createContext<ScrollEdgeEffects>(undefined);
+
+/** Register the content scroll view and apply its route's native edge settings. */
+export function NativeScrollViewMarker(props: ComponentProps<typeof ScrollViewMarker>) {
+ const effects = use(NativeScrollEdgeEffectsContext);
+ return (
+ <ScrollViewMarker
+ {...props}
+ scrollEdgeEffects={props.scrollEdgeEffects ?? effects ?? DEFAULT_SCROLL_EDGE_EFFECTS}
+ />
+ );
+}
+
+/** Primary screen scrolling; Android keeps its existing native view hierarchy. */
+export function NativeScrollView(props: ComponentProps<typeof ScrollView>) {
+ const scrollView = <ScrollView {...props} />;
+ return Platform.OS === "ios" ? (
+ <NativeScrollViewMarker style={{ flex: 1 }}>{scrollView}</NativeScrollViewMarker>
+ ) : (
+ scrollView
+ );
+}
diff --git a/apps/mobile/src/native/createV5StackNavigator.ios.tsx b/apps/mobile/src/native/createV5StackNavigator.ios.tsx
index d6e0dca54b3..408ddc9e0ff 100644
--- a/apps/mobile/src/native/createV5StackNavigator.ios.tsx
+++ b/apps/mobile/src/native/createV5StackNavigator.ios.tsx
@@ -23,6 +23,7 @@ import {
import { useCallback, useRef, useState, type ComponentProps } from "react";
import { StyleSheet, View } from "react-native";
import { FormSheet, Stack } from "react-native-screens";
+import { NativeScrollEdgeEffectsContext } from "./NativeScrollViewMarker";
import { V5StackHeader } from "./V5StackHeader.ios";
import type { AppNativeStackNavigationOptions } from "./StackHeader";
import { NativeColumnContent } from "./NativeColumnContent.ios";
@@ -243,7 +244,9 @@ export function V5CardStackView(
.nativeContentInsetHorizontally
}
>
- {descriptor.render()}
+ <NativeScrollEdgeEffectsContext value={descriptor.options.scrollEdgeEffects}>
+ {descriptor.render()}
+ </NativeScrollEdgeEffectsContext>
</NativeColumnContent>
</NavigationRouteContext>
</NavigationContext>