forked from CherryHQ/cherry-studio-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhaptic.ts
More file actions
22 lines (21 loc) · 979 Bytes
/
haptic.ts
File metadata and controls
22 lines (21 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { AndroidHaptics, impactAsync, ImpactFeedbackStyle, performAndroidHapticsAsync } from 'expo-haptics'
import { Platform } from 'react-native'
export function haptic(type: ImpactFeedbackStyle = ImpactFeedbackStyle.Medium): void {
if (Platform.OS === 'ios') {
impactAsync(type)
} else if (Platform.OS === 'android') {
if (type === ImpactFeedbackStyle.Light) {
performAndroidHapticsAsync(AndroidHaptics.Keyboard_Tap)
} else if (type === ImpactFeedbackStyle.Medium) {
performAndroidHapticsAsync(AndroidHaptics.Confirm)
} else if (type === ImpactFeedbackStyle.Heavy) {
performAndroidHapticsAsync(AndroidHaptics.Reject)
} else if (type === ImpactFeedbackStyle.Rigid) {
performAndroidHapticsAsync(AndroidHaptics.Long_Press)
} else if (type === ImpactFeedbackStyle.Soft) {
performAndroidHapticsAsync(AndroidHaptics.Virtual_Key_Release)
} else {
performAndroidHapticsAsync(AndroidHaptics.Virtual_Key)
}
}
}