@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 68 lines 1.85 KB
Raw
1 import type { ReactNode } from "react";
2 import { ScrollView, View } from "react-native";
3 import { KeyboardAvoidingView } from "react-native-keyboard-controller";
4 import { useSafeAreaInsets } from "react-native-safe-area-context";
5
6 import { fitSheetBottomInset, type FitSheetProps } from "./FitSheet.types";
7 import { ScreenContent } from "./ScreenContent";
8 export type { FitSheetProps } from "./FitSheet.types";
9
10 export function FitSheet({
11 header,
12 footer,
13 avoidsKeyboard,
14 children,
15 contentContainerClassName = "gap-4 px-5 pt-2",
16 contentContainerStyle,
17 ...scrollProps
18 }: FitSheetProps) {
19 const insets = useSafeAreaInsets();
20 return (
21 <SheetContainer avoidsKeyboard={avoidsKeyboard}>
22 {header}
23 <ScreenContent>
24 <ScrollView
25 {...scrollProps}
26 nestedScrollEnabled
27 contentContainerClassName={contentContainerClassName}
28 contentInsetAdjustmentBehavior="automatic"
29 className="flex-1"
30 contentContainerStyle={[
31 footer ? undefined : { paddingBottom: fitSheetBottomInset(insets.bottom) },
32 contentContainerStyle,
33 ]}
34 >
35 {children}
36 </ScrollView>
37 {footer ? (
38 <View
39 className="bg-sheet px-4 pt-3"
40 style={{ paddingBottom: Math.max(insets.bottom, 16) }}
41 >
42 {footer}
43 </View>
44 ) : null}
45 </ScreenContent>
46 </SheetContainer>
47 );
48 }
49
50 function SheetContainer(props: {
51 readonly avoidsKeyboard?: boolean;
52 readonly children: ReactNode;
53 }) {
54 return props.avoidsKeyboard ? (
55 <KeyboardAvoidingView
56 automaticOffset
57 behavior="padding"
58 collapsable={false}
59 className="flex-1 bg-sheet"
60 >
61 {props.children}
62 </KeyboardAvoidingView>
63 ) : (
64 <View collapsable={false} className="flex-1 bg-sheet">
65 {props.children}
66 </View>
67 );
68 }