import * as React from 'react'; import { Modal, StyleSheet, SafeAreaView, View, TouchableOpacity } from 'react-native'; import Icon from 'react-native-vector-icons/Feather'; import OIcon from './OIcon'; import OText from './OText'; import OIconButton from './OIconButton'; import { useTheme } from 'styled-components/native'; import { useUtils } from 'ordering-components/native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; interface Props { open?: boolean; title?: string; children?: any; onAccept?: any; onCancel?: any; onClose?: any; style?: any; acceptText?: string; cancelText?: string; isTransparent?: boolean; hideCloseDefault?: boolean; entireModal?: boolean; customClose?: boolean; titleSectionStyle?: any; isNotDecoration?: boolean; styleCloseButton?: any; order?: any; hideIcons?: boolean } const OModal = (props: Props): React.ReactElement => { const { open, title, children, onAccept, onCancel, onClose, acceptText, cancelText, isTransparent, hideCloseDefault, entireModal, customClose, titleSectionStyle, isNotDecoration, style, styleCloseButton, order, hideIcons } = props; const theme = useTheme(); const [{ optimizeImage }] = useUtils(); const { top } = useSafeAreaInsets(); const styles = StyleSheet.create({ container: { flex: 1, }, centeredView: { justifyContent: 'center', alignItems: 'center', position: 'relative', width: '100%', }, titleSection: { marginTop: top, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 30, paddingTop: 30, paddingBottom: !hideIcons ? 25 : 15, borderBottomWidth: !hideIcons ? 2 : 0, borderBottomColor: '#e6e6e6', }, titleGroups: { alignItems: 'center', flexDirection: 'row', minHeight: 33, }, titleIcons: { height: 33, width: 33, borderRadius: 7.6, resizeMode: 'stretch', }, shadow: { height: 34, width: 34, alignItems: 'center', justifyContent: 'flex-start', marginLeft: 15, backgroundColor: theme.colors.clear, paddingHorizontal: 3, borderRadius: 7.6, shadowColor: '#000', shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 3.84, elevation: 3, }, cancelBtn: { marginRight: 5, zIndex: 10000, maxWidth: 40, height: 25, justifyContent: 'flex-end', alignItems: 'flex-start', }, modalText: { fontFamily: 'Poppins', fontStyle: 'normal', fontWeight: '600', color: theme.colors.textGray, zIndex: 10, }, wrapperIcon: { overflow: 'hidden', borderRadius: 50, backgroundColor: '#CCCCCC80', width: 35, margin: 15, }, modalView: { margin: 20, backgroundColor: 'white', borderRadius: 20, padding: 35, alignItems: 'center', shadowColor: '#000', shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 4, elevation: 5, }, button: { borderRadius: 20, padding: 10, elevation: 2, }, buttonOpen: { backgroundColor: '#F194FF', }, buttonClose: { backgroundColor: '#2196F3', }, textStyle: { color: 'white', fontWeight: '600', textAlign: 'center', }, btnBackArrow: { borderWidth: 0, width: 32, height: 32, tintColor: theme.colors.textGray, backgroundColor: theme.colors.clear, borderColor: theme.colors.clear, shadowColor: theme.colors.clear, paddingLeft: 0, paddingRight: 0, marginTop: 10 }, }); return ( { onClose && onClose(); }} style={{ height: '100%', flex: 1, position: 'absolute', ...style, zIndex: 9999, }}> {!entireModal ? ( {title} {children} ) : ( <> {!customClose && ( onClose()} style={styles.btnBackArrow}> {title} {!hideIcons && ( {order?.business?.logo ? ( ) : ( )} {order?.driver && ( )} )} )} {children} )} ); }; export default OModal;