doc(barcode-scanner): optimize example code

This commit is contained in:
Daniel Sogl 2018-03-16 14:19:16 +01:00 committed by GitHub
parent f11be24f74
commit 1546cec694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface BarcodeScannerOptions { export interface BarcodeScannerOptions {
/** /**
* Prefer front camera. Supported on iOS and Android. * Prefer front camera. Supported on iOS and Android.
*/ */
@ -52,11 +51,26 @@ export interface BarcodeScannerOptions {
* Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only. * Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
*/ */
resultDisplayDuration?: number; resultDisplayDuration?: number;
} }
export interface BarcodeScanResult { 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' | 'PDF417' | 'AZTEC' | 'MSI'; format:
| 'QR_CODE'
| 'DATA_MATRIX'
| 'UPC_E'
| 'UPC_A'
| 'EAN_8'
| 'EAN_13'
| 'CODE_128'
| 'CODE_39'
| 'CODE_93'
| 'CODABAR'
| 'ITF'
| 'RSS14'
| 'RSS_EXPANDED'
| 'PDF417'
| 'AZTEC'
| 'MSI';
cancelled: boolean; cancelled: boolean;
text: string; text: string;
} }
@ -77,10 +91,10 @@ export interface BarcodeScanResult {
* ... * ...
* *
* *
* this.barcodeScanner.scan().then((barcodeData) => { * this.barcodeScanner.scan().then(barcodeData => {
* // Success! Barcode data is here * console.log('Barcode data', barcodeData);
* }, (err) => { * }).catch(err => {
* // An error occurred * console.log('Error', err);
* }); * });
* ``` * ```
* @interfaces * @interfaces
@ -96,7 +110,6 @@ export interface BarcodeScanResult {
}) })
@Injectable() @Injectable()
export class BarcodeScanner extends IonicNativePlugin { export class BarcodeScanner extends IonicNativePlugin {
Encode: { Encode: {
TEXT_TYPE: string; TEXT_TYPE: string;
EMAIL_TYPE: string; EMAIL_TYPE: string;
@ -117,7 +130,9 @@ export class BarcodeScanner extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> { return; } scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
return;
}
/** /**
* Encodes data into a barcode. * Encodes data into a barcode.
@ -127,6 +142,7 @@ export class BarcodeScanner extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
encode(type: string, data: any): Promise<any> { return; } encode(type: string, data: any): Promise<any> {
return;
}
} }