43 lines
993 B
TypeScript
43 lines
993 B
TypeScript
import type { PropsWithChildren } from "react"
|
|
import {
|
|
KeyboardAvoidingView,
|
|
Platform,
|
|
ScrollView,
|
|
StyleSheet,
|
|
type StyleProp,
|
|
type ViewStyle,
|
|
} from "react-native"
|
|
|
|
/** Center account forms on wide windows; scroll when the keyboard reduces height. */
|
|
export function KeyboardForm({
|
|
children,
|
|
style,
|
|
}: PropsWithChildren<{ style?: StyleProp<ViewStyle> }>) {
|
|
return (
|
|
<KeyboardAvoidingView
|
|
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
style={styles.fill}
|
|
>
|
|
<ScrollView
|
|
style={styles.fill}
|
|
contentContainerStyle={[style, styles.content]}
|
|
keyboardShouldPersistTaps="handled"
|
|
keyboardDismissMode={Platform.OS === "ios" ? "interactive" : "on-drag"}
|
|
>
|
|
{children}
|
|
</ScrollView>
|
|
</KeyboardAvoidingView>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
fill: { flex: 1 },
|
|
content: {
|
|
flex: undefined,
|
|
flexGrow: 1,
|
|
width: "100%",
|
|
maxWidth: 528,
|
|
alignSelf: "center",
|
|
},
|
|
})
|