Open History to see the last commit
1import { SheetHeader } from "../../components/ui/SheetHeader";
2import { useNavigation } from "@react-navigation/native";
3import type { ReactNode } from "react";
4import { Platform, ScrollView, useWindowDimensions, View } from "react-native";
5import { KeyboardAvoidingView } from "react-native-keyboard-controller";
6import { useSafeAreaInsets } from "react-native-safe-area-context";
7import { ScreenContent } from "../../components/ui/ScreenContent";
8
9export function PullRequestSheetContent(props: {
10 readonly title: string;
11 readonly subtitle: string;
12 readonly busy?: boolean;
13 readonly children: ReactNode;
14 readonly footer?: ReactNode;
15}) {
16 const navigation = useNavigation();
17 const insets = useSafeAreaInsets();
18 const { height: windowHeight } = useWindowDimensions();
19 const android = Platform.OS === "android";
20 const footer = props.footer ? (
21 <View
22 className={android ? "bg-sheet-solid pt-3" : "bg-sheet px-4 pt-3"}
23 style={{ paddingBottom: Math.max(insets.bottom, 16) }}
24 >
25 {android ? <View style={{ minHeight: 48 }}>{props.footer}</View> : props.footer}
26 </View>
27 ) : null;
28 return (
29 // Material sheet drags follow the first nested-scrolling native view, and the inline
30 // header's Compose button is one, so Android renders content first and reverses the column.
31 <KeyboardAvoidingView
32 automaticOffset
33 behavior="padding"
34 collapsable={false}
35 className="bg-sheet ios:flex-1 android:flex-col-reverse"
36 style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
37 >
38 <ScreenContent fitToContents={android}>
39 <ScrollView
40 nestedScrollEnabled
41 className="android:shrink android:grow-0 ios:flex-1"
42 contentInsetAdjustmentBehavior="automatic"
43 keyboardShouldPersistTaps="handled"
44 contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 16, paddingBottom: 20 }}
45 >
46 <View className="gap-4" pointerEvents={props.busy ? "none" : "auto"}>
47 {props.children}
48 {/* Android partial-height sheets keep submit actions within the scrollable form. */}
49 {android ? footer : null}
50 </View>
51 </ScrollView>
52 {android ? null : footer}
53 </ScreenContent>
54 <SheetHeader
55 title={props.title}
56 subtitle={props.subtitle}
57 onCancel={() => navigation.goBack()}
58 dismissDisabled={props.busy}
59 />
60 </KeyboardAvoidingView>
61 );
62}