@umituz/react-native-haptics 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-haptics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Haptic feedback (vibration) for React Native using expo-haptics with impact, notification, and selection feedback patterns",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -22,9 +22,9 @@ export type NotificationType = 'Success' | 'Warning' | 'Error';
|
|
|
22
22
|
* Haptic patterns for common interactions
|
|
23
23
|
*/
|
|
24
24
|
export type HapticPattern =
|
|
25
|
-
| '
|
|
26
|
-
| '
|
|
27
|
-
| '
|
|
25
|
+
| 'success'
|
|
26
|
+
| 'warning'
|
|
27
|
+
| 'error'
|
|
28
28
|
| 'selection';
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -36,16 +36,3 @@ export const HAPTIC_CONSTANTS = {
|
|
|
36
36
|
DELETE_IMPACT: 'Medium' as ImpactStyle,
|
|
37
37
|
ERROR_IMPACT: 'Heavy' as ImpactStyle,
|
|
38
38
|
} as const;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Haptic utilities
|
|
42
|
-
* Simplified - pattern handling moved to HapticService
|
|
43
|
-
*/
|
|
44
|
-
export class HapticUtils {
|
|
45
|
-
/**
|
|
46
|
-
* Get default impact style for common patterns
|
|
47
|
-
*/
|
|
48
|
-
static getDefaultImpact(): ImpactStyle {
|
|
49
|
-
return 'Light';
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -62,19 +62,22 @@ export class HapticService {
|
|
|
62
62
|
*/
|
|
63
63
|
static async pattern(pattern: HapticPattern): Promise<void> {
|
|
64
64
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
switch (pattern) {
|
|
66
|
+
case 'selection':
|
|
67
|
+
await HapticService.selection();
|
|
68
|
+
break;
|
|
69
|
+
case 'success':
|
|
70
|
+
await HapticService.notification('Success');
|
|
71
|
+
break;
|
|
72
|
+
case 'warning':
|
|
73
|
+
await HapticService.notification('Warning');
|
|
74
|
+
break;
|
|
75
|
+
case 'error':
|
|
76
|
+
await HapticService.notification('Error');
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
await HapticService.impact('Light');
|
|
68
80
|
}
|
|
69
|
-
|
|
70
|
-
// Success, Warning, Error map to notification feedback
|
|
71
|
-
if (pattern === 'Success' || pattern === 'Warning' || pattern === 'Error') {
|
|
72
|
-
await HapticService.notification(pattern as NotificationType);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Default to light impact
|
|
77
|
-
await HapticService.impact('Light');
|
|
78
81
|
} catch (error) {
|
|
79
82
|
// Silent fail
|
|
80
83
|
}
|
|
@@ -88,15 +91,15 @@ export class HapticService {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
static async success(): Promise<void> {
|
|
91
|
-
await HapticService.pattern('
|
|
94
|
+
await HapticService.pattern('success');
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
static async error(): Promise<void> {
|
|
95
|
-
await HapticService.pattern('
|
|
98
|
+
await HapticService.pattern('error');
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
static async warning(): Promise<void> {
|
|
99
|
-
await HapticService.pattern('
|
|
102
|
+
await HapticService.pattern('warning');
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
static async delete(): Promise<void> {
|