react-native-country-picker-modal-xkelxmc
Version:
react-native country picker
39 lines • 1.37 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { SafeAreaView, StyleSheet, Platform } from 'react-native';
import { AnimatedModal } from './AnimatedModal';
import { Modal } from './Modal';
import { useTheme } from './CountryTheme';
import { CountryModalContext } from './CountryModalProvider';
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export const CountryModal = ({ children, withModal, disableNativeModal, ...props }) => {
const { backgroundColor } = useTheme();
const { teleport } = React.useContext(CountryModalContext);
const content = (_jsx(SafeAreaView, { style: [styles.container, { backgroundColor }], children: children }));
React.useEffect(() => {
if (disableNativeModal) {
teleport(_jsx(AnimatedModal, { ...props, children: content }));
}
}, [disableNativeModal]);
if (withModal) {
if (Platform.OS === 'web') {
return _jsx(Modal, { ...props, children: content });
}
if (disableNativeModal) {
return null;
}
return _jsx(Modal, { ...props, children: content });
}
return content;
};
CountryModal.defaultProps = {
animationType: 'slide',
animated: true,
withModal: true,
disableNativeModal: false,
};
//# sourceMappingURL=CountryModal.js.map