Open bosen opened 10 months ago
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch react-native-custom-haptics@1.0.1 for the project I'm working on.
react-native-custom-haptics@1.0.1
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-custom-haptics/src/HapticsProvider/HapticsProvider.tsx b/node_modules/react-native-custom-haptics/src/HapticsProvider/HapticsProvider.tsx index 56c7e19..eb3f79e 100644 --- a/node_modules/react-native-custom-haptics/src/HapticsProvider/HapticsProvider.tsx +++ b/node_modules/react-native-custom-haptics/src/HapticsProvider/HapticsProvider.tsx @@ -51,7 +51,13 @@ const HapticsProvider = ({ children }: IHapticsProvider) => { Vibration.vibrate(); // Use native impact type } else { - await Haptics.impactAsync(getHapticImpactEnum(e)); + if (e === 'select') { + await Haptics.selectionAsync(); + } else if (e === 'silence') { + // do nothing + } else { + await Haptics.impactAsync(getHapticImpactEnum(e)); + } } // Await for the pause } else { diff --git a/node_modules/react-native-custom-haptics/src/HapticsProvider/types.tsx b/node_modules/react-native-custom-haptics/src/HapticsProvider/types.tsx index e42182a..b895241 100644 --- a/node_modules/react-native-custom-haptics/src/HapticsProvider/types.tsx +++ b/node_modules/react-native-custom-haptics/src/HapticsProvider/types.tsx @@ -5,7 +5,7 @@ export type HapticImpactStrength = 'light' | 'medium' | 'heavy'; export type VibrateLength = 'vibrate' | number; /** Softer impact used for selection */ -export type HapticImpactSharpness = 'select'; +export type HapticImpactSharpness = 'select' | 'silence'; /** All types of non-traditional vibrations */ export type HapticImpact = HapticImpactStrength | HapticImpactSharpness; diff --git a/node_modules/react-native-custom-haptics/src/HapticsProvider/utils.ts b/node_modules/react-native-custom-haptics/src/HapticsProvider/utils.ts index 7c446e3..a453e29 100644 --- a/node_modules/react-native-custom-haptics/src/HapticsProvider/utils.ts +++ b/node_modules/react-native-custom-haptics/src/HapticsProvider/utils.ts @@ -5,6 +5,7 @@ import * as Haptics from 'expo-haptics'; export async function hapticsPattern(...pattern: Impact[]) { for (let i = 0; i < pattern.length; ++i) { const e = pattern[i]; + if (i % 2 === 0) { // Vibration length, always 400 for iOS if (typeof e === 'number') { @@ -17,6 +18,8 @@ export async function hapticsPattern(...pattern: Impact[]) { } else { if (e === 'select') { await Haptics.selectionAsync(); + } else if (e === 'silence') { + // do nothing } else { await Haptics.impactAsync(getHapticImpactEnum(e)); }
This issue body was partially generated by patch-package.
Hi! Thank you for using the package!
This is a great idea π
I will take a look and keep you posted.
Cheers!
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch
react-native-custom-haptics@1.0.1
for the project I'm working on.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.