fix(mobile): restore native scroll-edge effects on forms and PRs (#18507)
This commit is contained in:
1 parent
d514a8c617
commit
6f6197c465
8 files changed
+47
-9
No files matched your search
@@ -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>) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user