/
index.ts
85 lines (79 loc) · 2.61 KB
/
index.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
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
export interface BarcodeScannerOptions {
/**
* Prefer front camera. Supported on iOS and Android.
*/
preferFrontCamera?: boolean;
/**
* Show flip camera button. Supported on iOS and Android.
*/
showFlipCameraButton?: boolean;
/**
* Show torch button. Supported on iOS and Android.
*/
showTorchButton?: boolean;
/**
* Disable animations. Supported on iOS only.
*/
disableAnimations?: boolean;
/**
* Disable success beep. Supported on iOS only.
*/
disableSuccessBeep?: boolean;
/**
* Prompt text. Supported on Android only.
*/
prompt?: string;
/**
* Formats separated by commas. Defaults to all formats except `PDF_417` and `RSS_EXPANDED`.
*/
formats?: string;
/**
* 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.
*/
orientation?: string;
/**
* Launch with the torch switched on (if available). Supported on Android only.
*/
torchOn?: boolean;
/**
* Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
*/
resultDisplayDuration?: number;
}
export interface BarcodeScanResult {
format: 'QR_CODE' | 'DATA_MATRIX' | 'UPC_E' | 'UPC_A' | 'EAN_8' | 'EAN_13' | 'CODE_128' | 'CODE_39' | 'CODE_93' | 'CODABAR' | 'ITF' | 'RSS14' | 'RSS_EXPANDED' | 'PDF_417' | 'AZTEC' | 'MSI';
cancelled: boolean;
text: string;
}
export class BarcodeScannerMock extends BarcodeScanner {
Encode: {
TEXT_TYPE: string;
EMAIL_TYPE: string;
PHONE_TYPE: string;
SMS_TYPE: string;
};
/**
* Open the barcode scanner.
* @param {BarcodeScannerOptions} [options] Optional options to pass to the scanner
* @returns {Promise<any>} Returns a Promise that resolves with scanner data, or rejects with an error.
*/
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
let theResult: BarcodeScanResult = { format: 'QR_CODE', cancelled: false, text: 'RESPONSE' };
return new Promise((resolve, reject) => {
resolve(theResult);
});
}
/**
* Encodes data into a barcode.
* NOTE: not well supported on Android
* @param {string} type Type of encoding
* @param {any} data Data to encode
* @returns {Promise<any>}
*/
encode(type: string, data: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
}
}