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
@@ -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