2020-03-30 19:20:50 +00:00
|
|
|
import React from 'react';
|
2021-10-20 18:04:15 +00:00
|
|
|
import { ScrollView, ScrollViewProps, StyleSheet, View } from 'react-native';
|
2020-03-30 19:20:50 +00:00
|
|
|
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2020-03-30 19:20:50 +00:00
|
|
|
import sharedStyles from '../views/Styles';
|
|
|
|
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
|
|
|
import KeyboardView from '../presentation/KeyboardView';
|
2022-03-25 17:55:20 +00:00
|
|
|
import { useTheme } from '../theme';
|
2020-03-30 19:20:50 +00:00
|
|
|
import StatusBar from './StatusBar';
|
|
|
|
import AppVersion from './AppVersion';
|
|
|
|
import { isTablet } from '../utils/deviceInfo';
|
2020-06-15 14:00:46 +00:00
|
|
|
import SafeAreaView from './SafeAreaView';
|
2020-03-30 19:20:50 +00:00
|
|
|
|
2021-10-20 18:04:15 +00:00
|
|
|
interface IFormContainer extends ScrollViewProps {
|
2021-09-13 20:41:05 +00:00
|
|
|
testID: string;
|
2022-03-25 17:55:20 +00:00
|
|
|
children: React.ReactElement | React.ReactElement[] | null;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 19:20:50 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
scrollView: {
|
|
|
|
minHeight: '100%'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-25 17:55:20 +00:00
|
|
|
export const FormContainerInner = ({ children }: { children: (React.ReactElement | null)[] }) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<View style={[sharedStyles.container, isTablet && sharedStyles.tabletScreenContent]}>{children}</View>
|
2020-03-30 19:20:50 +00:00
|
|
|
);
|
|
|
|
|
2022-03-25 17:55:20 +00:00
|
|
|
const FormContainer = ({ children, testID, ...props }: IFormContainer) => {
|
|
|
|
const { theme } = useTheme();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<KeyboardView
|
|
|
|
style={{ backgroundColor: themes[theme].backgroundColor }}
|
|
|
|
contentContainerStyle={sharedStyles.container}
|
|
|
|
keyboardVerticalOffset={128}>
|
|
|
|
<StatusBar />
|
|
|
|
<ScrollView
|
|
|
|
style={sharedStyles.container}
|
|
|
|
contentContainerStyle={[sharedStyles.containerScrollView, styles.scrollView]}
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
{...props}>
|
|
|
|
<SafeAreaView testID={testID} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
|
|
|
{children}
|
|
|
|
<AppVersion theme={theme} />
|
|
|
|
</SafeAreaView>
|
|
|
|
</ScrollView>
|
|
|
|
</KeyboardView>
|
|
|
|
);
|
|
|
|
};
|
2020-03-30 19:20:50 +00:00
|
|
|
|
|
|
|
export default FormContainer;
|