BlueWallet/screen/ActionSheet.ts
2026-03-16 21:13:23 +00:00

26 lines
824 B
TypeScript

// ActionSheet.ts
import { Alert } from 'react-native';
import { ActionSheetOptions, CompletionCallback } from './ActionSheet.common';
export default class ActionSheet {
static showActionSheetWithOptions(options: ActionSheetOptions, completion: CompletionCallback): void {
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 });
}
}