Open History to see the last commit
1import { createContext, use, type ComponentProps } from "react";
2import { Platform } from "react-native";
3import { cn } from "../../lib/cn";
4import { NativeScrollView as ScrollView } from "../../native/NativeScrollViewMarker";
5
6export const ScreenScrollViewBottomInset = createContext(0);
7/**
8 * The screen's surface class. UIKit's scroll-edge material under the header takes the scroll
9 * view's own color; a clear scroll view gets the system's near-white bar over the screen's surface.
10 */
11export const ScreenScrollViewSurface = createContext<string | undefined>(undefined);
12
13export function ScreenScrollView(props: ComponentProps<typeof ScrollView>) {
14 const bottomInset = use(ScreenScrollViewBottomInset);
15 const surface = use(ScreenScrollViewSurface);
16 return (
17 <ScrollView
18 {...props}
19 className={Platform.OS === "ios" && surface ? cn(surface, props.className) : props.className}
20 contentInset={
21 Platform.OS === "ios" && bottomInset > 0
22 ? { ...props.contentInset, bottom: (props.contentInset?.bottom ?? 0) + bottomInset }
23 : props.contentInset
24 }
25 contentContainerStyle={[
26 props.contentContainerStyle,
27 Platform.OS === "android" && {
28 width: "100%",
29 maxWidth: 720,
30 alignSelf: "center",
31 },
32 ]}
33 />
34 );
35}