import React, { useMemo } from "react"; import { Button, Flex, IImageProps, Image, Text, View, VStack, } from "native-base"; import type { AccessibilityProps, ImageSourcePropType, StyleProp, TextStyle, ViewStyle, } from "react-native"; interface IDialog { headerComponent?: React.ReactElement; title?: string; titleStyle?: StyleProp | undefined; description?: React.ReactNode; descriptionStyle?: StyleProp | undefined; buttonDirection?: "vertical" | "horizontal"; confirmLabel?: string; cancelLabel?: string; onConfirm?: () => void; onCancel?: () => void; testID?: string; style?: StyleProp | undefined; illustrationSrc?: ImageSourcePropType; illustrationProps?: IImageProps; withSwipeLine?: boolean; } export const Dialog: React.FC = (props) => { const { title, titleStyle, description, descriptionStyle, buttonDirection, confirmLabel, cancelLabel, onConfirm, onCancel, headerComponent, testID, style, illustrationSrc, illustrationProps, withSwipeLine, ...rest } = props; const testIDLabel = useMemo(() => testID ?? undefined, [testID]); const accessibilityLabel = useMemo( () => props.accessibilityLabel ?? undefined, [props.accessibilityLabel] ); return ( {withSwipeLine && ( )} {illustrationSrc && ( )} {headerComponent} {(title || description) && ( {title && ( {title} )} {description && React.isValidElement(description) ? ( description ) : ( {description} )} )} {(confirmLabel || cancelLabel) && ( {confirmLabel ? ( ) : ( <> )} {cancelLabel ? ( ) : ( <> )} )} ); }; export default Dialog;