-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
60 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
import { NativeModules } from 'react-native'; | ||
|
||
class HapticService { | ||
public isHapticFeedbackEnabled: boolean = false; | ||
public useExpoHaptics: boolean = false; | ||
|
||
constructor() { | ||
const expoConstants = | ||
NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants; | ||
this.useExpoHaptics = !!expoConstants; | ||
} | ||
|
||
public setEnabled(isEnabled: boolean) { | ||
this.isHapticFeedbackEnabled = isEnabled; | ||
} | ||
|
||
public impact() { | ||
if (!this.isHapticFeedbackEnabled) { | ||
return; | ||
} | ||
|
||
if (this.useExpoHaptics) { | ||
const ExpoHaptics = require('expo-haptics'); | ||
return ExpoHaptics.impactAsync(ExpoHaptics.ImpactFeedbackStyle.Medium); | ||
} | ||
|
||
const ReactNativeHapticFeedback = | ||
require('react-native-haptic-feedback').default; | ||
return ReactNativeHapticFeedback.trigger('impactMedium', { | ||
enableVibrateFallback: true, | ||
ignoreAndroidSystemSettings: true, | ||
}); | ||
} | ||
|
||
public selection() { | ||
if (!this.isHapticFeedbackEnabled) { | ||
return; | ||
} | ||
if (this.useExpoHaptics) { | ||
const ExpoHaptics = require('expo-haptics'); | ||
return ExpoHaptics.selectionAsync(); | ||
} | ||
|
||
const ReactNativeHapticFeedback = | ||
require('react-native-haptic-feedback').default; | ||
return ReactNativeHapticFeedback.trigger('selection', { | ||
enableVibrateFallback: true, | ||
ignoreAndroidSystemSettings: true, | ||
}); | ||
} | ||
} | ||
|
||
const Haptic = new HapticService(); | ||
|
||
export default Haptic; | ||
// import { NativeModules } from 'react-native'; | ||
|
||
// class HapticService { | ||
// public isHapticFeedbackEnabled: boolean = false; | ||
// public useExpoHaptics: boolean = false; | ||
|
||
// constructor() { | ||
// const expoConstants = | ||
// NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants; | ||
// this.useExpoHaptics = !!expoConstants; | ||
// } | ||
|
||
// public setEnabled(isEnabled: boolean) { | ||
// this.isHapticFeedbackEnabled = isEnabled; | ||
// } | ||
|
||
// public impact() { | ||
// if (!this.isHapticFeedbackEnabled) { | ||
// return; | ||
// } | ||
|
||
// if (this.useExpoHaptics) { | ||
// const ExpoHaptics = require('expo-haptics'); | ||
// return ExpoHaptics.impactAsync(ExpoHaptics.ImpactFeedbackStyle.Medium); | ||
// } | ||
|
||
// const ReactNativeHapticFeedback = | ||
// require('react-native-haptic-feedback').default; | ||
// return ReactNativeHapticFeedback.trigger('impactMedium', { | ||
// enableVibrateFallback: true, | ||
// ignoreAndroidSystemSettings: true, | ||
// }); | ||
// } | ||
|
||
// public selection() { | ||
// if (!this.isHapticFeedbackEnabled) { | ||
// return; | ||
// } | ||
// if (this.useExpoHaptics) { | ||
// const ExpoHaptics = require('expo-haptics'); | ||
// return ExpoHaptics.selectionAsync(); | ||
// } | ||
|
||
// const ReactNativeHapticFeedback = | ||
// require('react-native-haptic-feedback').default; | ||
// return ReactNativeHapticFeedback.trigger('selection', { | ||
// enableVibrateFallback: true, | ||
// ignoreAndroidSystemSettings: true, | ||
// }); | ||
// } | ||
// } | ||
|
||
// const Haptic = new HapticService(); | ||
|
||
// export default Haptic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters