2020-11-17 09:43:38 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-05-18 04:17:00 +02:00
|
|
|
import { StyleSheet, Platform, useWindowDimensions, View } from 'react-native';
|
2020-11-17 09:43:38 +01:00
|
|
|
import Modal from 'react-native-modal';
|
2021-05-18 04:17:00 +02:00
|
|
|
import { BlueButton, BlueSpacing40 } from '../BlueComponents';
|
|
|
|
import loc from '../loc';
|
|
|
|
import { useTheme } from '@react-navigation/native';
|
2020-11-17 09:43:38 +01:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
root: {
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
margin: 0,
|
|
|
|
},
|
2021-05-18 04:17:00 +02:00
|
|
|
hasDoneButton: {
|
|
|
|
padding: 16,
|
|
|
|
paddingBottom: 24,
|
|
|
|
},
|
2020-11-17 09:43:38 +01:00
|
|
|
});
|
|
|
|
|
2021-05-18 04:17:00 +02:00
|
|
|
const BottomModal = ({ onBackButtonPress, onBackdropPress, onClose, windowHeight, windowWidth, doneButton, ...props }) => {
|
2020-11-17 09:43:38 +01:00
|
|
|
const valueWindowHeight = useWindowDimensions().height;
|
|
|
|
const valueWindowWidth = useWindowDimensions().width;
|
|
|
|
const handleBackButtonPress = onBackButtonPress ?? onClose;
|
|
|
|
const handleBackdropPress = onBackdropPress ?? onClose;
|
2021-05-18 04:17:00 +02:00
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesHook = StyleSheet.create({
|
|
|
|
hasDoneButton: {
|
|
|
|
backgroundColor: colors.elevated,
|
|
|
|
},
|
|
|
|
});
|
2020-11-17 09:43:38 +01:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
style={styles.root}
|
|
|
|
deviceHeight={windowHeight ?? valueWindowHeight}
|
|
|
|
deviceWidth={windowWidth ?? valueWindowWidth}
|
|
|
|
onBackButtonPress={handleBackButtonPress}
|
|
|
|
onBackdropPress={handleBackdropPress}
|
|
|
|
{...props}
|
2021-03-16 03:07:52 +01:00
|
|
|
accessibilityViewIsModal
|
|
|
|
useNativeDriver
|
2021-05-18 04:17:00 +02:00
|
|
|
useNativeDriverForBackdrop={Platform.OS === 'android'}
|
|
|
|
>
|
|
|
|
{props.children}
|
|
|
|
{doneButton && (
|
|
|
|
<View style={[styles.hasDoneButton, stylesHook.hasDoneButton]}>
|
|
|
|
<BlueButton title={loc.send.input_done} onPress={onClose} />
|
|
|
|
<BlueSpacing40 />
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</Modal>
|
2020-11-17 09:43:38 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
BottomModal.propTypes = {
|
|
|
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
|
|
onBackButtonPress: PropTypes.func,
|
|
|
|
onBackdropPress: PropTypes.func,
|
|
|
|
onClose: PropTypes.func,
|
2021-05-18 04:17:00 +02:00
|
|
|
doneButton: PropTypes.func,
|
2020-11-17 09:43:38 +01:00
|
|
|
windowHeight: PropTypes.number,
|
|
|
|
windowWidth: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BottomModal;
|