mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
34 lines
752 B
TypeScript
34 lines
752 B
TypeScript
import { Alert } from 'react-native';
|
|
import loc from '../loc';
|
|
|
|
/**
|
|
* Helper function that throws un-cancellable dialog to confirm user's action.
|
|
* Promise resolves to TRUE if user confirms, FALSE otherwise
|
|
*
|
|
* @param title {string}
|
|
* @param text {string}
|
|
*
|
|
* @return {Promise<boolean>}
|
|
*/
|
|
export default function (title = 'Are you sure?', text = ''): Promise<boolean> {
|
|
return new Promise(resolve => {
|
|
Alert.alert(
|
|
title,
|
|
text,
|
|
[
|
|
{
|
|
text: loc._.yes,
|
|
onPress: () => resolve(true),
|
|
style: 'default',
|
|
},
|
|
{
|
|
text: loc._.cancel,
|
|
onPress: () => resolve(false),
|
|
style: 'cancel',
|
|
},
|
|
],
|
|
{ cancelable: false },
|
|
);
|
|
});
|
|
}
|