Skip to content

Commit

Permalink
[iOS] Custom navigation vanishes after camera was opened #220
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Sep 10, 2019
1 parent 4b3a5ab commit 0bf7941
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
20 changes: 12 additions & 8 deletions src/barcodescanner.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ export class BarcodeScanner {
public stop(): Promise<any> {
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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0bf7941

Please sign in to comment.