nativescript-barcodescanner
Advanced tools
Comparing version 3.3.2 to 3.4.0
@@ -56,2 +56,3 @@ import { ContentView } from "tns-core-modules/ui/content-view"; | ||
export declare const reportDuplicatesProperty: Property<BarcodeScannerView, boolean>; | ||
export declare const pauseProperty: Property<BarcodeScannerView, boolean>; | ||
export declare abstract class BarcodeScannerView extends ContentView { | ||
@@ -63,2 +64,5 @@ static scanResultEvent: string; | ||
protected reportDuplicates: boolean; | ||
protected pause: boolean; | ||
protected pauseScanning(): void; | ||
protected resumeScanning(): void; | ||
} |
@@ -25,2 +25,7 @@ "use strict"; | ||
}); | ||
exports.pauseProperty = new properties_1.Property({ | ||
name: "pause", | ||
defaultValue: false, | ||
valueConverter: view_base_1.booleanConverter | ||
}); | ||
var BarcodeScannerView = (function (_super) { | ||
@@ -31,2 +36,8 @@ __extends(BarcodeScannerView, _super); | ||
} | ||
BarcodeScannerView.prototype.pauseScanning = function () { | ||
console.log(">>> abstract pause"); | ||
}; | ||
BarcodeScannerView.prototype.resumeScanning = function () { | ||
console.log(">>> abstract resume"); | ||
}; | ||
BarcodeScannerView.prototype[exports.formatsProperty.setNative] = function (value) { | ||
@@ -44,2 +55,7 @@ this.formats = value; | ||
}; | ||
BarcodeScannerView.prototype[exports.pauseProperty.setNative] = function (value) { | ||
console.log(">> pause: " + value); | ||
this.pause = value; | ||
this.pause ? this.pauseScanning() : this.resumeScanning(); | ||
}; | ||
BarcodeScannerView.scanResultEvent = "scanResult"; | ||
@@ -49,2 +65,3 @@ return BarcodeScannerView; | ||
exports.BarcodeScannerView = BarcodeScannerView; | ||
exports.pauseProperty.register(BarcodeScannerView); | ||
exports.formatsProperty.register(BarcodeScannerView); | ||
@@ -51,0 +68,0 @@ exports.preferFrontCameraProperty.register(BarcodeScannerView); |
@@ -10,2 +10,4 @@ import { BarcodeScannerView as BarcodeScannerBaseView, ScanOptions, ScanResult } from "./barcodescanner-common"; | ||
onLayout(left: number, top: number, right: number, bottom: number): void; | ||
protected pauseScanning(): void; | ||
protected resumeScanning(): void; | ||
} | ||
@@ -12,0 +14,0 @@ export declare class BarcodeScanner { |
@@ -50,3 +50,5 @@ "use strict"; | ||
_this.ios.layer.insertSublayerAtIndex(_this._reader.previewLayer, 0); | ||
_this._reader.startScanning(); | ||
if (!_this.pause) { | ||
_this._reader.startScanning(); | ||
} | ||
} | ||
@@ -61,2 +63,12 @@ }, 0); | ||
}; | ||
BarcodeScannerView.prototype.pauseScanning = function () { | ||
if (this._reader && this._reader.running()) { | ||
this._reader.stopScanning(); | ||
} | ||
}; | ||
BarcodeScannerView.prototype.resumeScanning = function () { | ||
if (this._reader && !this._reader.running()) { | ||
this._reader.startScanning(); | ||
} | ||
}; | ||
return BarcodeScannerView; | ||
@@ -156,2 +168,3 @@ }(barcodescanner_common_1.BarcodeScannerView)); | ||
_this._removeVolumeObserver(); | ||
_this._scanner.stopScanning(); | ||
_this._closeCallback && _this._closeCallback(); | ||
@@ -158,0 +171,0 @@ resolve(); |
{ | ||
"name": "nativescript-barcodescanner", | ||
"version": "3.3.2", | ||
"version": "3.4.0", | ||
"description": "Scan QR/barcodes with your NativeScript app.", | ||
@@ -5,0 +5,0 @@ "main": "barcodescanner", |
@@ -82,2 +82,4 @@ # NativeScript BarcodeScanner | ||
> 💡 TIP: If you don't destroy the component/page which embed the scanner (but instead show a modal, or navigate "forward") you can "pause" the scanner (since plugin version 3.4.0). Simply set that `pause` property to `true` when applicable. | ||
### XML | ||
@@ -98,3 +100,4 @@ ```xml | ||
preferFrontCamera="false" | ||
scanResult="onScanResult" /> | ||
pause="{{ pause }}" | ||
scanResult="{{ onScanResult }}" /> | ||
</iOS> | ||
@@ -120,2 +123,3 @@ ``` | ||
preferFrontCamera="false" | ||
[pause]="pause" | ||
(scanResult)="onScanResult($event)"> | ||
@@ -144,2 +148,3 @@ </BarcodeScanner> | ||
preferFrontCamera="false" | ||
:pause="pause" | ||
@scanResult="onScanResult" | ||
@@ -146,0 +151,0 @@ v-if="isIOS"> |
847
390
1680345
24