forked from jdmunro/react-native-spotlight-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (35 loc) · 1.24 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
import {NativeModules, NativeEventEmitter, Platform} from 'react-native';
const {SpotlightSearch} = NativeModules;
const spotlightEventEmitter = new NativeEventEmitter(SpotlightSearch);
const EVENT_ITEM_TAPPED = 'spotlightSearchItemTapped';
const nullFunc = () => {};
export default {
getInitialSearchItem: Platform.select({
ios: SpotlightSearch?.getInitialSearchItem,
android: nullFunc
}),
indexItem: Platform.select({
ios: (item) => SpotlightSearch?.indexItem(item),
android: nullFunc
}),
indexItems: Platform.select({
ios: (items) => SpotlightSearch?.indexItems(items),
android: nullFunc
}),
deleteItemsWithIdentifiers: Platform.select({
ios: (ids) => SpotlightSearch?.deleteItemsWithIdentifiers(ids),
android: nullFunc
}),
deleteItemsInDomains: Platform.select({
ios: (domains) => SpotlightSearch?.deleteItemsInDomains(domains),
android: nullFunc
}),
deleteAllItems: Platform.select({
ios: () => SpotlightSearch?.deleteAllItems(),
android: nullFunc
}),
searchItemTapped: Platform.select({
ios: (callback) => spotlightEventEmitter?.addListener(EVENT_ITEM_TAPPED, callback),
android: nullFunc
}),
}