@@ -9,114 +9,159 @@ import {
9
9
} from '@awesome-cordova-plugins/core' ;
10
10
import { Observable } from 'rxjs' ;
11
11
12
- export interface BarcodeScannerOptions {
13
- /**
14
- * Prefer front camera. Supported on iOS and Android.
15
- */
16
- preferFrontCamera ?: boolean ;
17
-
18
- /**
19
- * Show flip camera button. Supported on iOS and Android.
20
- */
21
- showFlipCameraButton ?: boolean ;
12
+ export interface FrameResult {
13
+ frameWidth : number ;
14
+ frameHeight : number ;
15
+ results : BarcodeResult [ ] ;
16
+ }
22
17
23
- /**
24
- * Show torch button. Supported on iOS and Android.
25
- */
26
- showTorchButton ?: boolean ;
18
+ export interface BarcodeResult {
19
+ barcodeText : string ;
20
+ barcodeFormat : string ;
21
+ x1 : number ;
22
+ x2 : number ;
23
+ x3 : number ;
24
+ x4 : number ;
25
+ y1 : number ;
26
+ y2 : number ;
27
+ y3 : number ;
28
+ y4 : number ;
29
+ }
27
30
31
+ /**
32
+ * @name dynamsoft-barcode-scanner
33
+ * @description
34
+ * This plugin scans barcodes using Dynamsoft Barcode Reader
35
+ *
36
+ * @usage
37
+ * ```typescript
38
+ * import { dynamsoft-barcode-scanner } from '@awesome-cordova-plugins/dynamsoft-barcode-scanner';
39
+ *
40
+ *
41
+ * constructor(private dynamsoft-barcode-scanner: dynamsoft-barcode-scanner) { }
42
+ *
43
+ * ...
44
+ *
45
+ *
46
+ * await this.dynamsoft-barcode-scanner.init("license");
47
+ * this.dynamsoft-barcode-scanner.startScanning("license").subscribe(result => {
48
+ console.log(result);
49
+ });
50
+ *
51
+ * ```
52
+ */
53
+ @Plugin ( {
54
+ pluginName : 'dynamsoft-barcode-scanner' ,
55
+ plugin : 'cordova-plugin-dynamsoft-barcode-reader' ,
56
+ pluginRef : 'cordova.plugins.DBR' ,
57
+ repo : 'https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader' ,
58
+ install : '' ,
59
+ installVariables : [ ] ,
60
+ platforms : [ 'Android' , 'iOS' ] ,
61
+ } )
62
+ @Injectable ( )
63
+ export class BarcodeScanner extends AwesomeCordovaNativePlugin {
28
64
/**
29
- * Disable animations. Supported on iOS only.
65
+ * Initialize Dynamsoft Barcode Reader
66
+ * @param license {string}
67
+ * @return {Promise<any> } Returns a promise that resolves when the initialization is done
30
68
*/
31
- disableAnimations ?: boolean ;
69
+ @Cordova ( {
70
+ successIndex : 1 ,
71
+ errorIndex : 2 ,
72
+ } )
73
+ init ( license : string ) : Promise < any > {
74
+ return ;
75
+ }
32
76
33
77
/**
34
- * Disable success beep. Supported on iOS only.
78
+ * Set up runtime settings
79
+ * @param settings {string} runtime settings template in JSON
80
+ * @return {Promise<any> } Returns a promise
35
81
*/
36
- disableSuccessBeep ?: boolean ;
82
+ @Cordova ( {
83
+ successIndex : 1 ,
84
+ errorIndex : 2 ,
85
+ } )
86
+ initRuntimeSettingsWithString ( settings ?: string ) : Promise < any > {
87
+ return ;
88
+ }
37
89
38
90
/**
39
- * Prompt text. Supported on Android only.
91
+ * Output runtime settings to JSON string
92
+ * @return {Promise<String> } Returns a promise
40
93
*/
41
- prompt ?: string ;
94
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
95
+ outputSettingsToString ( ) : Promise < string > {
96
+ return ;
97
+ }
42
98
43
99
/**
44
- * Formats separated by commas. Defaults to all formats except `PDF_417` and `RSS_EXPANDED`.
100
+ * destroy Dynamsoft Barcode Reader
101
+ * @return {Promise<any> } Returns a promise
45
102
*/
46
- formats ?: string ;
103
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
104
+ destroy ( ) : Promise < any > {
105
+ return ;
106
+ }
47
107
48
108
/**
49
- * Orientation. Supported on Android only. Can be set to `portrait` or `landscape`. Defaults to none so the user can rotate the phone and pick an orientation.
109
+ * start the camera to scan barcodes
110
+ * @param dceLicense {string} License of Dynamsoft Camera Enhancer
111
+ * @return {Observable<FrameResult> }
50
112
*/
51
- orientation ?: string ;
113
+ @Cordova ( {
114
+ successIndex : 1 ,
115
+ errorIndex : 2 ,
116
+ observable : true ,
117
+ } )
118
+ startScanning ( dceLicense ?: string ) : Observable < FrameResult > {
119
+ return ;
120
+ }
52
121
53
122
/**
54
- * Launch with the torch switched on (if available). Supported on Android only.
123
+ * stop scanning
124
+ * @return {Promise<any> } Returns a promise
55
125
*/
56
- torchOn ?: boolean ;
126
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
127
+ stopScanning ( ) : Promise < any > {
128
+ return ;
129
+ }
57
130
58
131
/**
59
- * Save scan history. Defaults to `false`. Supported on Android only.
132
+ * resume scanning
133
+ * @return {Promise<any> } Returns a promise
60
134
*/
61
- saveHistory ?: boolean ;
135
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
136
+ resumeScanning ( ) : Promise < any > {
137
+ return ;
138
+ }
62
139
63
140
/**
64
- * Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
141
+ * pause scanning
142
+ * @return {Promise<any> } Returns a promise
65
143
*/
66
- resultDisplayDuration ?: number ;
144
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
145
+ pauseScanning ( ) : Promise < any > {
146
+ return ;
147
+ }
67
148
68
149
/**
69
- * Long key for Dynamsoft Barcode Reader
150
+ * get resolution like: 1280x720
151
+ * @return {Promise<string> } Returns a promise
70
152
*/
71
- dynamsoftlicense ?: string ;
72
- }
73
-
74
- export interface BarcodeScanResult {
75
- format : string ;
76
- cancelled : boolean ;
77
- text : string ;
78
- }
153
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
154
+ getResolution ( ) : Promise < string > {
155
+ return ;
156
+ }
79
157
80
- /**
81
- * @name dynamsoft-barcode-scanner
82
- * @description
83
- * The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
84
- * Requires this Cordova plugin: [BarcodeScanner plugin](https://github.com/Dynamsoft/cordova-plugin-dbr/).
85
- * @usage
86
- * ```typescript
87
- * import { BarcodeScanner } from '@awesome-cordova-plugins/dynamsoft-barcode-scanner';
88
- *
89
- * ...
90
- *
91
- * const results = await BarcodeScanner.scan({"dynamsoftlicense":"license"});
92
- * console.log(results);
93
- *
94
- * ```
95
- * @interfaces
96
- * BarcodeScannerOptions
97
- * BarcodeScanResult
98
- */
99
- @Plugin ( {
100
- pluginName : 'dynamsoft-barcode-scanner' ,
101
- plugin : 'cordova-plugin-dbr' ,
102
- pluginRef : 'cordova.plugins.barcodeScanner' ,
103
- repo : 'https://github.com/Dynamsoft/cordova-plugin-dbr' ,
104
- install : '' ,
105
- installVariables : [ ] ,
106
- platforms : [ 'Android' , 'iOS' ] ,
107
- } )
108
- @Injectable ( )
109
- export class BarcodeScanner extends AwesomeCordovaNativePlugin {
110
158
/**
111
- * Open the barcode scanner.
112
- *
113
- * @param {BarcodeScannerOptions } [options] Optional options to pass to the scanner
114
- * @returns {Promise<any> } Returns a Promise that resolves with scanner data, or rejects with an error.
159
+ * switch torch
160
+ * @param desiredStatus {string} on or off
161
+ * @return {Promise<any> } Returns a promise
115
162
*/
116
- @Cordova ( {
117
- callbackOrder : 'reverse' ,
118
- } )
119
- scan ( options ?: BarcodeScannerOptions ) : Promise < BarcodeScanResult > {
163
+ @Cordova ( { successIndex : 1 , errorIndex : 2 } )
164
+ switchTorch ( desiredStatus : string ) : Promise < any > {
120
165
return ;
121
166
}
122
167
}
0 commit comments