add props for BarcodeScanOptions

This commit is contained in:
Jeff Wu
2017-09-18 11:14:46 +08:00
parent e4ce585bf2
commit 3b4ce7625b
2 changed files with 21 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for phonegap-plugin-barcodescanner
// Project: https://github.com/phonegap/phonegap-plugin-barcodescanner
// Definitions by: Nathan Ainslie <https://www.github.com/nainslie>
// Jeff Wu <https://www.github.com/jeffwu85182>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface CordovaPlugins {
@@ -13,13 +14,19 @@ declare namespace phonegapBarcode {
format: string;
cancelled: boolean;
}
interface BarcodeScanOptions {
preferFrontCamera?: boolean;
showFlipCameraButton?: boolean;
showTorchButton?: boolean;
torchOn?: boolean;
saveHistory?: boolean;
resultDisplayDuration? :number;
disableAnimations: boolean;
prompt?: string;
formats?: string;
orientation?: "landscape" | "portrait";
disableSuccessBeep?: boolean;
}
interface EncodingType {
@@ -34,4 +41,4 @@ declare namespace phonegapBarcode {
encode: (encodingType: EncodingType, data: string, success: ((result: any) => any), failure?: ((err: any) => any)) => void;
Encode: EncodingType;
}
}
}

View File

@@ -11,11 +11,17 @@ cordova.plugins.barcodeScanner.scan(
alert("Scanning failed: " + error);
},
{
"preferFrontCamera" : true, // iOS and Android
"showFlipCameraButton" : true, // iOS and Android
"prompt" : "Place a barcode inside the scan area", // supported on Android only
"formats" : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
"orientation" : "landscape" // Android only (portrait|landscape), default unset so it rotates with the device
preferFrontCamera : true, // iOS and Android
showFlipCameraButton : true, // iOS and Android
showTorchButton : true, // iOS and Android
torchOn: true, // Android, launch with the torch switched on (if available)
saveHistory: true, // Android, save scan history (default false)
prompt : "Place a barcode inside the scan area", // Android
resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
disableAnimations : true, // iOS
disableSuccessBeep: false // iOS and Android
}
);
@@ -25,4 +31,4 @@ cordova.plugins.barcodeScanner.encode(cordova.plugins.barcodeScanner.Encode.TEXT
}, function(fail) {
alert("encoding failed: " + fail);
}
);
);