2023-07-06 20:03:57 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
import { Modal, ModalProps, StyleSheet, View, ViewStyle } from 'react-native';
|
|
|
|
import { hasNotch } from 'react-native-device-info';
|
|
|
|
|
|
|
|
interface ModalElementProps extends ModalProps {
|
|
|
|
children: React.ReactNode;
|
|
|
|
containerStyle?: ViewStyle;
|
2023-07-06 21:41:03 +02:00
|
|
|
elevation?: number;
|
2023-07-06 20:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ModalElement: React.FC<ModalElementProps> = ({
|
|
|
|
children,
|
|
|
|
containerStyle,
|
|
|
|
...modalProps
|
|
|
|
}) => {
|
2024-03-25 13:39:48 +02:00
|
|
|
// supportedOrientations: On iOS, this allows the dialog to be shown in non-portrait orientations.
|
2023-07-06 20:03:57 +02:00
|
|
|
return (
|
2024-03-25 13:39:48 +02:00
|
|
|
<Modal
|
|
|
|
supportedOrientations={['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']}
|
|
|
|
{...modalProps}
|
|
|
|
>
|
2023-07-06 20:03:57 +02:00
|
|
|
<View style={[styleSheet.modalContainer, containerStyle ? containerStyle : null]}>
|
|
|
|
{children}
|
|
|
|
</View>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const styleSheet = StyleSheet.create({
|
|
|
|
modalContainer: {
|
|
|
|
marginTop: hasNotch() ? 65 : 15,
|
|
|
|
marginBottom: hasNotch() ? 35 : 15,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ModalElement;
|