forked from EddyVerbruggen/nativescript-barcodescanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarcodescanner.common.ts
109 lines (96 loc) · 2.76 KB
/
barcodescanner.common.ts
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
export interface CommonScanOptions {
/**
* A comma sep. string of barcode types: "QR_CODE,PDF_417"
* Default: empty, so all types of codes can be scanned.
*/
formats?: string;
/**
* By default the scanned object is returned in the Promise,
* but if you want to scan continuously (until you call 'stop'),
* you can provide a callback function that receives the same object
* as the Promise would, but every time something is scanned.
*
* This function doesn't report duplicates in the same scanning session,
* unless reportDuplicates is set to true.
*/
continuousScanCallback?: Function;
/**
* Wheter or not to report duplicate scan results during continuous scanning.
*
* Default false.
*/
reportDuplicates?: boolean;
/**
* Start the scanner with the front camera?
* Default: false, so the back camera is used.
*/
preferFrontCamera?: boolean;
/**
* While scanning for a barcode show a button to flip to the other camera (front or back).
* Default: false
*/
showFlipCameraButton?: boolean;
/**
* Default: false
*/
showTorchButton?: boolean;
/**
* Launch the scanner with the flashlight turned on.
*/
torchOn?: boolean;
/**
* Play a sound when a code was scanned.
* Default: true
*/
beepOnScan?: boolean;
}
export interface IOS extends CommonScanOptions {
/**
* The label of the button used to close the scanner.
* Default: "Close".
*/
cancelLabel?: string;
/**
* You can send the user to the settings app if access was previously denied.
* Default: false
*/
openSettingsIfPermissionWasPreviouslyDenied?: boolean;
}
export interface Android extends CommonScanOptions {
/**
* The message shown when looking for something to scan.
* Default: "Place a barcode inside the viewfinder rectangle to scan it."
*/
message?: string;
/**
* Optionally lock the orientation to 'portrait' or 'landscape'.
* Default: "sensor", which follows the current device rotation.
*/
orientation?: string;
/**
* Default is 1500, set to 0 o suppress the scanner echoing the scanned text.
*/
resultDisplayDuration?: number;
}
export interface ScanOptions extends IOS, Android {
IOS?: IOS;
Android?: Android;
}
export declare class BarcodeScanner {
private _observer;
private _observerActive;
private _currentVolume;
private _scanner;
constructor();
private _hasCameraPermission;
private _hasDeniedCameraPermission;
private _addVolumeObserver;
private _removeVolumeObserver;
private _enableTorch;
private _disableTorch;
available(): Promise<boolean>;
hasCameraPermission(): Promise<boolean>;
requestCameraPermission(): Promise<boolean>;
stop(): Promise<any>;
scan(arg: ScanOptions): Promise<any>;
}