forked from mozes-pb/react-native-visenze-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
91 lines (86 loc) · 3.62 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { NativeModules, NativeEventEmitter } from 'react-native';
const { RNVisenzeBridge } = NativeModules;
let resultListener = {}
const ReactNativeVisenze = {
/**
* Initiate Visearch with app key
* Also set the listener for callback
* @param {string} appkey
*/
start: function start(appkey) {
RNVisenzeBridge.start(appkey);
},
/**
* Search using id
* @param {string} id
* @param {callback} callback - callback function to be invoked
*/
searchById: function searchById(id, callback) {
resultListener = callback;
new NativeEventEmitter(RNVisenzeBridge).addListener('VisenzeResultEvent', (result) => {
resultListener(result);
});
RNVisenzeBridge.searchById(id);
},
/**
* Search using URL of the image
* Example : https://static.independent.co.uk/s3fs-public/thumbnails/image/2017/03/01/11/spring-handbags-lifestyle.jpg
* @param {string} url - URL of the image
* @param {callback} callback - callback function to be invoked
* @param {string} limitDetection - limit the image detection = "all", "top", "dress", "bottom", "shoe", "bag", "watch" and "indian ethnic wear". default = "all"
*/
searchByUrl: function searchByUrl(url, callback, limitDetection = "all") {
resultListener = callback;
new NativeEventEmitter(RNVisenzeBridge).addListener('VisenzeResultEvent', (result) => {
resultListener(result);
});
RNVisenzeBridge.searchByUrl(url, limitDetection);
},
/**
* Search using URI of the image
* @param {string} Uri - Uri of the image
* @param {callback} callback - callback function to be invoked
* @param {string} limitDetection - limit the image detection = "all", "top", "dress", "bottom", "shoe", "bag", "watch" and "indian ethnic wear". default = "all"
*/
searchByUri: function searchByUri(uri, callback, limitDetection = "all") {
resultListener = callback;
new NativeEventEmitter(RNVisenzeBridge).addListener('VisenzeResultEvent', (result) => {
resultListener(result);
});
RNVisenzeBridge.searchByUri(uri, limitDetection);
},
/**
* Search using local path of the image
* @param {string} path - local path of the image
* @param {callback} callback - callback function to be invoked
* @param {string} limitDetection - limit the image detection = "all", "top", "dress", "bottom", "shoe", "bag", "watch" and "indian ethnic wear". default = "all"
*/
searchByPath: function searchByPath(path, callback, limitDetection = "all") {
resultListener = callback;
new NativeEventEmitter(RNVisenzeBridge).addListener('VisenzeResultEvent', (result) => {
resultListener(result);
});
RNVisenzeBridge.searchByPath(path, limitDetection);
},
/**
* Search using Hex color
* @param {string} hexString - Hex Color "111111" for white, "000000" for black
* @param {callback} callback - callback function to be invoked
*/
searchByColor: function searchByColor(hexString, callback) {
resultListener = callback;
new NativeEventEmitter(RNVisenzeBridge).addListener('VisenzeResultEvent', (result) => {
resultListener(result);
});
RNVisenzeBridge.searchByColor(hexString);
},
/**
* Track Click Event
* @param {string} imageName
* @param {string} reqID
*/
trackSearchResultClickEvent: function trackSearchResultClickEvent(imageName, reqID) {
RNVisenzeBridge.trackSearchResultClickEvent(imageName, reqID);
},
};
export default ReactNativeVisenze;