import { KeyboardAvoidingView, Modal, Platform, Pressable, StyleSheet, Text, TextInput, View, } from 'react-native'; import {Button, Icon} from './components'; import {useAlertContainer} from './hooks/useAlertContainer'; import {useTheme} from './hooks/useTheme'; import type {AlertData, PersonalTheme} from './types/alertTypes'; export type AlertContainerProps = { animationType?: 'none' | 'fade' | 'slide'; appearance?: 'light' | 'dark'; personalTheme?: PersonalTheme; theme?: 'ios' | 'android'; /** * Tapping the dimmed background cancels the alert or prompt. * Off by default, like the native dialogs. */ dismissOnBackdropPress?: boolean; }; export function AlertContainer({ theme, appearance, personalTheme, animationType, dismissOnBackdropPress = false, }: AlertContainerProps) { const {prompt, isAlert, inputRef, setTextInput, handlePress, textInput} = useAlertContainer(); const {styles, textButtonColor, cancelWeight, ios} = useTheme({ appearance, buttons: (prompt as AlertData)?.buttons?.length, personalTheme, theme, icon: !!(prompt as AlertData)?.icon, }); if (!prompt) { return null; } const {placeholderColor, backgroundColor} = personalTheme ?? {}; const { title, icon, iconColor, buttons, cancelColorText, cancelText, confirmColorText, confirmText, description, label, placeholder, keyboardType, secureTextEntry, autoCapitalize, maxLength, inputProps, } = prompt as AlertData; return ( handlePress(true)}> handlePress(true)} style={StyleSheet.absoluteFill} /> {!!icon && } {title} {description && ( {description} )} {!ios && !!label && {label}} {!isAlert && ( handlePress()} placeholderTextColor={ placeholderColor ? placeholderColor : appearance === 'dark' ? '#666' : '#C3C3C3' } ref={inputRef} style={[styles.textInput, inputProps?.style]} /> )} {buttons ? ( buttons.map((button, index) => (