mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
26 lines
907 B
TypeScript
26 lines
907 B
TypeScript
import DeviceInfo, { PowerState } from 'react-native-device-info';
|
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
|
|
|
// Define a const enum for HapticFeedbackTypes
|
|
export const enum HapticFeedbackTypes {
|
|
ImpactLight = 'impactLight',
|
|
ImpactMedium = 'impactMedium',
|
|
ImpactHeavy = 'impactHeavy',
|
|
Selection = 'selection',
|
|
NotificationSuccess = 'notificationSuccess',
|
|
NotificationWarning = 'notificationWarning',
|
|
NotificationError = 'notificationError',
|
|
}
|
|
|
|
const triggerHapticFeedback = (type: HapticFeedbackTypes) => {
|
|
DeviceInfo.getPowerState().then((state: Partial<PowerState>) => {
|
|
if (!state.lowPowerMode) {
|
|
ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true });
|
|
} else {
|
|
console.log('Haptic feedback not triggered due to low power mode.');
|
|
}
|
|
});
|
|
};
|
|
|
|
export default triggerHapticFeedback;
|