diff --git a/CHANGELOG.md b/CHANGELOG.md index c4e4b83..b8ae2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [3.3.1](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.1) (2019-09-10) +## [3.3.2](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.2) (2019-09-10) [Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/43?closed=1) diff --git a/src/barcodescanner.ios.ts b/src/barcodescanner.ios.ts index 512d34e..b031bbd 100644 --- a/src/barcodescanner.ios.ts +++ b/src/barcodescanner.ios.ts @@ -192,12 +192,7 @@ export class BarcodeScanner { public stop(): Promise { return new Promise((resolve, reject) => { try { - if (this._lastScanViewController) { - this._lastScanViewController.dismissViewControllerAnimatedCompletion(true, null); - this._lastScanViewController = undefined; - } else { - this.getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null); - } + this.close(); this._removeVolumeObserver(); this._closeCallback && this._closeCallback(); resolve(); @@ -326,6 +321,15 @@ export class BarcodeScanner { return false; } + private close(): void { + if (this._lastScanViewController) { + this._lastScanViewController.dismissViewControllerAnimatedCompletion(true, null); + this._lastScanViewController = undefined; + } else { + this.getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null); + } + } + private getViewControllerToPresentFrom(presentInRootViewController?: boolean): UIViewController { let frame = require("tns-core-modules/ui/frame"); let viewController: UIViewController; @@ -451,7 +455,7 @@ class QRCodeReaderDelegateImpl extends NSObject implements QRCodeReaderDelegate } public readerDidCancel(reader: QRCodeReaderViewController): void { - this._owner.get().getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null); + this._owner.get().close(); this._callback(); } @@ -485,7 +489,7 @@ class QRCodeReaderDelegateImpl extends NSObject implements QRCodeReaderDelegate } } else { validResult = true; - this._owner.get().getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null); + this._owner.get().close(); this._callback(value, barcodeFormat); } diff --git a/src/package.json b/src/package.json index 0dcb4e0..b2a9d77 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-barcodescanner", - "version": "3.3.1", + "version": "3.3.2", "description": "Scan QR/barcodes with your NativeScript app.", "main": "barcodescanner", "typings": "index.d.ts",