import * as React from 'react'; import { AlertButton, View } from 'react-native'; import { useGetStyleProps } from '../../hook'; import { useI18nContext } from '../../i18n'; import { usePaletteContext, useThemeContext } from '../../theme'; import { BorderButton, CmnButton } from '../Button'; import type { AlertProps } from './types'; export function useAlert(props: AlertProps) { const { containerStyle, supportInput = false } = props; const [value, _onChangeText] = React.useState(''); const [textCount, setTextCount] = React.useState(0); const [_props, setProps] = React.useState(props); const { tr } = useI18nContext(); const { cornerRadius: corner } = useThemeContext(); const { input } = corner; const { cornerRadius } = usePaletteContext(); const { getBorderRadius } = useGetStyleProps(); const [disabled, setDisabled] = React.useState( supportInput === false ? false : true ); const onChangeText = React.useCallback((v: string) => { _onChangeText(v); if (v.length > 0) { setDisabled(false); } else { setDisabled(true); } }, []); const getButton = ( buttons: AlertButton[] | undefined, onRequestModalClose: () => void ) => { const count = buttons?.length ?? 1; const _getButton = ( Button: typeof BorderButton | typeof CmnButton, v: AlertButton, i: number ) => { const lastIndex = count - 1; return (