Open History to see the last commit
1import { createContext, use, type ComponentProps } from "react";
2import { Platform, ScrollView } from "react-native";
3import { ScrollViewMarker } from "react-native-screens";
4import { nativeHeaderScrollEdgeEffects } from "./scrollEdgeEffects";
5
6type ScrollEdgeEffects = ComponentProps<typeof ScrollViewMarker>["scrollEdgeEffects"];
7
8const DEFAULT_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
9
10export const NativeScrollEdgeEffectsContext = createContext<ScrollEdgeEffects>(undefined);
11
12export function NativeScrollViewMarker(props: ComponentProps<typeof ScrollViewMarker>) {
13 const effects = use(NativeScrollEdgeEffectsContext);
14 return (
15 <ScrollViewMarker
16 {...props}
17 scrollEdgeEffects={props.scrollEdgeEffects ?? effects ?? DEFAULT_SCROLL_EDGE_EFFECTS}
18 />
19 );
20}
21
22export function NativeScrollView(props: ComponentProps<typeof ScrollView>) {
23 const scrollView = <ScrollView {...props} />;
24 return Platform.OS === "ios" ? (
25 <NativeScrollViewMarker style={{ flex: 1 }}>{scrollView}</NativeScrollViewMarker>
26 ) : (
27 scrollView
28 );
29}