import * as React from "react" ; import { KeyboardAvoidingView , ScrollView , StatusBar , View , SafeAreaView , } from "react-native" ; import { ScreenProps } from "./screen.props" ; import { isNonScrolling , offsets , presets } from "./screen.presets" ; import { ModalClipboard } from "../modal-clipboard" ; import { isIos } from "../../utils/helper" ; function ScreenWithoutScrolling ( props ) { const preset = presets . fixed ; const style = props . style || { } ; const backgroundStyle = props . backgroundColor ? { backgroundColor : props . backgroundColor } : { } ; const Wrapper = props . unsafe ? View : SafeAreaView ; return ( < KeyboardAvoidingView style = { [ preset . outer , backgroundStyle ] } behavior = { isIos ? "padding" : null } keyboardVerticalOffset = { offsets [ props . keyboardOffset || "none" ] } > < StatusBar barStyle = { props . statusBar || "dark-content" } backgroundColor = { props . backgroundColor } / > { } < ModalClipboard / > < Wrapper style = { [ preset . inner , style ] } > { props . children } < /Wrapper> < /KeyboardAvoidingView>); } function ScreenWithScrolling ( props ) { const preset = presets . scroll ; const style = props . style || { } ; const backgroundStyle = props . backgroundColor ? { backgroundColor : props . backgroundColor } : { } ; const Wrapper = props . unsafe ? View : SafeAreaView ; return ( < KeyboardAvoidingView style = { [ preset . outer , backgroundStyle ] } behavior = { isIos ? "padding" : null } keyboardVerticalOffset = { offsets [ props . keyboardOffset || "none" ] } > < StatusBar barStyle = { props . statusBar || "dark-content" } backgroundColor = { props . backgroundColor } / > < ModalClipboard /> < Wrapper style = { [ preset . outer , backgroundStyle ] } > < ScrollView style = { [ preset . outer , backgroundStyle ] } contentContainerStyle = { [ preset . inner , style ] } > { props . children } < /ScrollView> < /Wrapper> < /KeyboardAvoidingView>); } param props export function Screen ( props ) { if ( isNonScrolling ( props . preset ) ) { return < ScreenWithoutScrolling { ... props } / > ; } return < ScreenWithScrolling { ... props } / > ; }