1 | import { NativeModules, Platform, Vibration } from 'react-native';
|
2 | const VIBRATION_DURATION_MS = 100;
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export var NotificationFeedbackType;
|
9 | (function (NotificationFeedbackType) {
|
10 | |
11 |
|
12 |
|
13 | NotificationFeedbackType["Success"] = "success";
|
14 | |
15 |
|
16 |
|
17 | NotificationFeedbackType["Warning"] = "warning";
|
18 | |
19 |
|
20 |
|
21 | NotificationFeedbackType["Error"] = "error";
|
22 | })(NotificationFeedbackType || (NotificationFeedbackType = {}));
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export var ImpactFeedbackStyle;
|
29 | (function (ImpactFeedbackStyle) {
|
30 | |
31 |
|
32 |
|
33 | ImpactFeedbackStyle["Light"] = "light";
|
34 | |
35 |
|
36 |
|
37 | ImpactFeedbackStyle["Medium"] = "medium";
|
38 | |
39 |
|
40 |
|
41 | ImpactFeedbackStyle["Heavy"] = "heavy";
|
42 | })(ImpactFeedbackStyle || (ImpactFeedbackStyle = {}));
|
43 |
|
44 |
|
45 |
|
46 | export function notification(type = NotificationFeedbackType.Success) {
|
47 | if (Platform.OS === 'ios') {
|
48 | NativeModules.ExponentHaptic.notification(type);
|
49 | }
|
50 | else {
|
51 | console.warn('`Expo.Haptic` is only available on iOS');
|
52 | Vibration.vibrate(VIBRATION_DURATION_MS, false);
|
53 | }
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 | export function impact(style = ImpactFeedbackStyle.Medium) {
|
59 | if (Platform.OS === 'ios') {
|
60 | NativeModules.ExponentHaptic.impact(style);
|
61 | }
|
62 | else {
|
63 | console.warn('`Expo.Haptic` is only available on iOS');
|
64 | Vibration.vibrate(VIBRATION_DURATION_MS, false);
|
65 | }
|
66 | }
|
67 |
|
68 |
|
69 |
|
70 | export function selection() {
|
71 | if (Platform.OS === 'ios') {
|
72 | NativeModules.ExponentHaptic.selection();
|
73 | }
|
74 | else {
|
75 | console.warn('`Expo.Haptic` is only available on iOS');
|
76 | Vibration.vibrate(VIBRATION_DURATION_MS, false);
|
77 | }
|
78 | }
|
79 |
|
\ | No newline at end of file |