diff options
author | Ansh Nanda <anshnanda10@gmail.com> | 2023-05-22 18:46:36 -0700 |
---|---|---|
committer | Ansh Nanda <anshnanda10@gmail.com> | 2023-05-22 18:46:36 -0700 |
commit | dfcdd37087c0be4055c92a0f88431b32646ced6f (patch) | |
tree | 874e053215833aba81fbe49295c67c2f0bdacb43 /src/lib/haptics.ts | |
parent | 64e303d911d351a2f492a23ae97207e5c6035b6e (diff) | |
download | voidsky-dfcdd37087c0be4055c92a0f88431b32646ced6f.tar.zst |
add haptics to save, like, and pin actions on feed
Diffstat (limited to 'src/lib/haptics.ts')
-rw-r--r-- | src/lib/haptics.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/haptics.ts b/src/lib/haptics.ts new file mode 100644 index 000000000..23a321796 --- /dev/null +++ b/src/lib/haptics.ts @@ -0,0 +1,24 @@ +import { isIOS } from 'platform/detection' +import ReactNativeHapticFeedback, { + HapticFeedbackTypes, +} from 'react-native-haptic-feedback' + + +const hapticImpact: HapticFeedbackTypes = isIOS ? 'impactMedium' : 'impactLight' // Users said the medium impact was too strong on Android; see APP-537s + + +export class Haptics { + static default = () => ReactNativeHapticFeedback.trigger(hapticImpact) + static impact = (type: HapticFeedbackTypes = hapticImpact) => ReactNativeHapticFeedback.trigger(type) + static selection = () => ReactNativeHapticFeedback.trigger('selection') + static notification = (type: 'success' | 'warning' | 'error') => { + switch (type) { + case 'success': + return ReactNativeHapticFeedback.trigger('notificationSuccess') + case 'warning': + return ReactNativeHapticFeedback.trigger('notificationWarning') + case 'error': + return ReactNativeHapticFeedback.trigger('notificationError') + } + } +} \ No newline at end of file |