mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
28 lines
932 B
TypeScript
28 lines
932 B
TypeScript
// ActionSheet.ts
|
|
import { Alert, InteractionManager } from 'react-native';
|
|
|
|
import { ActionSheetOptions, CompletionCallback } from './ActionSheet.common';
|
|
|
|
export default class ActionSheet {
|
|
static showActionSheetWithOptions(options: ActionSheetOptions, completion: CompletionCallback): void {
|
|
InteractionManager.runAfterInteractions(() => {
|
|
const alertOptions = options.options.map((option, index) => {
|
|
let style: 'default' | 'cancel' | 'destructive' = 'default';
|
|
if (index === options.destructiveButtonIndex) {
|
|
style = 'destructive';
|
|
} else if (index === options.cancelButtonIndex) {
|
|
style = 'cancel';
|
|
}
|
|
|
|
return {
|
|
text: option,
|
|
onPress: () => completion(index),
|
|
style,
|
|
};
|
|
});
|
|
|
|
Alert.alert(options.title || '', options.message || '', alertOptions, { cancelable: !!options.cancelButtonIndex });
|
|
});
|
|
}
|
|
}
|