1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-mobile/components/Modal.tsx

37 lines
955 B
TypeScript
Raw Normal View History

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;
}
const ModalElement: React.FC<ModalElementProps> = ({
children,
containerStyle,
...modalProps
}) => {
// supportedOrientations: On iOS, this allows the dialog to be shown in non-portrait orientations.
return (
<Modal
supportedOrientations={['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']}
{...modalProps}
>
<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;