ADD: Optional haptic feedback parameter for Alerts

This commit is contained in:
Marcos Rodriguez Velez 2024-04-25 22:02:22 -04:00
parent f74e0890cc
commit ce5963b891
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
2 changed files with 30 additions and 4 deletions

View File

@ -185,7 +185,10 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode })
addWallet(w);
await saveToDisk();
A(A.ENUM.CREATED_WALLET);
presentAlert({ message: w.type === WatchOnlyWallet.type ? loc.wallets.import_success_watchonly : loc.wallets.import_success });
presentAlert({
hapticFeedback: HapticFeedbackTypes.ImpactHeavy,
message: w.type === WatchOnlyWallet.type ? loc.wallets.import_success_watchonly : loc.wallets.import_success,
});
// @ts-ignore need to type notifications first
Notifications.majorTomToGroundControl(w.getAllExternalAddresses(), [], []);
// start balance fetching at the background

View File

@ -1,6 +1,29 @@
import { Alert } from 'react-native';
import { Alert as RNAlert } from 'react-native';
import loc from '../loc';
const presentAlert = ({ title, message }: { title?: string; message: string }) => {
Alert.alert(title ?? loc.alert.default, message);
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
export enum AlertType {
Alert,
Toast,
}
const presentAlert = ({
title,
message,
type = AlertType.Alert,
hapticFeedback,
}: {
title?: string;
message: string;
type?: AlertType;
hapticFeedback?: HapticFeedbackTypes;
}) => {
if (hapticFeedback) {
triggerHapticFeedback(hapticFeedback);
}
switch (type) {
default:
RNAlert.alert(title ?? loc.alert.default, message);
break;
}
};
export default presentAlert;