mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at verify-code 25 lines 770 B view raw
1import {AlertButton, AlertStatic} from 'react-native' 2 3class WebAlert implements Pick<AlertStatic, 'alert'> { 4 public alert(title: string, message?: string, buttons?: AlertButton[]): void { 5 if (buttons === undefined || buttons.length === 0) { 6 // eslint-disable-next-line no-alert 7 window.alert([title, message].filter(Boolean).join('\n')) 8 return 9 } 10 11 // eslint-disable-next-line no-alert 12 const result = window.confirm([title, message].filter(Boolean).join('\n')) 13 14 if (result === true) { 15 const confirm = buttons.find(({style}) => style !== 'cancel') 16 confirm?.onPress?.() 17 return 18 } 19 20 const cancel = buttons.find(({style}) => style === 'cancel') 21 cancel?.onPress?.() 22 } 23} 24 25export const Alert = new WebAlert()