import React, {useState} from 'react' import { ActivityIndicator, StyleSheet, TouchableOpacity, View, } from 'react-native' import {Text} from '../util/text/Text' import {useStores} from 'state/index' import {s, colors} from 'lib/styles' import {ErrorMessage} from '../util/error/ErrorMessage' import {cleanError} from 'lib/strings/errors' import {usePalette} from 'lib/hooks/usePalette' export const snapPoints = [300] export function Component({ title, message, onPressConfirm, }: { title: string message: string | (() => JSX.Element) onPressConfirm: () => void | Promise }) { const pal = usePalette('default') const store = useStores() const [isProcessing, setIsProcessing] = useState(false) const [error, setError] = useState('') const onPress = async () => { setError('') setIsProcessing(true) try { await onPressConfirm() store.shell.closeModal() return } catch (e: any) { setError(cleanError(e)) setIsProcessing(false) } } return ( {title} {typeof message === 'string' ? ( {message} ) : ( message() )} {error ? ( ) : undefined} {isProcessing ? ( ) : ( Confirm )} ) } const styles = StyleSheet.create({ container: { flex: 1, padding: 10, paddingBottom: 60, }, title: { textAlign: 'center', marginBottom: 12, }, description: { textAlign: 'center', paddingHorizontal: 22, marginBottom: 10, }, btn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 32, padding: 14, marginTop: 22, marginHorizontal: 44, backgroundColor: colors.blue3, }, })