import React, { useCallback } from 'react'; import { Modal as RNModal, View, type ModalProps, TouchableOpacity, ViewStyle } from 'react-native'; import useTheme from '../hooks/useTheme'; import { ThemeName } from '../constants/Colors'; import Text from './Text'; export type Props = ModalProps & { variant?: ThemeName; lightColor?: string; darkColor?: string; trigger?: React.ReactNode; children?: React.ReactNode; modalVisible: boolean; setModalVisible: (value: boolean) => void; headerTitle?: string; showHeader?: boolean; containerStyle?: ViewStyle; modalVisibleBackgroundOpcity?: number; }; const Modal = ({ children, showHeader = false, trigger, headerTitle = "Container", modalVisible, setModalVisible, containerStyle, modalVisibleBackgroundOpcity = 0.7, ...otherProps }: Props) => { const { currentTheme } = useTheme(); const clickHandler = useCallback(() => { setModalVisible(!modalVisible) }, []) if (!currentTheme) return <> return ( {trigger ? {trigger} : <>} { setModalVisible(!modalVisible); }} {...otherProps}> {/* container */} {showHeader ? {headerTitle} {/* cancel */} X : <>} {children} ); }; export default Modal;