-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
52 lines (47 loc) · 1.42 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React, { Component } from 'react'
import ReactNative, { requireNativeComponent, NativeModules, UIManager, Platform } from 'react-native'
const NativeViewManager = NativeModules.HapticViewManager
const NativeHapticView = requireNativeComponent('HapticView', null)
class HapticView extends Component {
render() {
return (
<NativeHapticView {...this.props} />
)
}
performHaptic(params) {
if (Platform.OS === 'ios') {
NativeViewManager.performHaptic(ReactNative.findNodeHandle(this), params.ios)
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.HapticView.Commands.performHaptic,
[params.android]
)
}
}
}
export const HapticFeedbackConstants = {
ios: {
IMPACT_FEEDBACK: 0,
NOTIFICATION_FEEDBACK: {
SUCCESSES: 1,
FAILURES: 2,
WARNINGS: 3
},
SELECTION_FEEDBACK: 4
},
android: {
CLOCK_TICK: 'CLOCK_TICK',
CONTEXT_CLICK: 'CONTEXT_CLICK',
FLAG_IGNORE_GLOBAL_SETTING: 'FLAG_IGNORE_GLOBAL_SETTING',
FLAG_IGNORE_VIEW_SETTING: 'FLAG_IGNORE_VIEW_SETTING',
KEYBOARD_PRESS: 'KEYBOARD_PRESS',
KEYBOARD_RELEASE: 'KEYBOARD_RELEASE',
KEYBOARD_TAP: 'KEYBOARD_TAP',
LONG_PRESS: 'LONG_PRESS',
TEXT_HANDLE_MOVE: 'TEXT_HANDLE_MOVE',
VIRTUAL_KEY: 'VIRTUAL_KEY',
VIRTUAL_KEY_RELEASE: 'VIRTUAL_KEY_RELEASE',
}
}
export default HapticView