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 bca8e6d commit 4b3a5ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 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.0](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.0) (2019-09-10)
## [3.3.1](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.1) (2019-09-10)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/43?closed=1)


Expand Down
11 changes: 8 additions & 3 deletions src/barcodescanner.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class BarcodeScanner {
private _audioSession: AVAudioSession;
private _closeCallback: any;
private _device: AVCaptureDevice;
private _lastScanOptions: ScanOptions;
private _lastScanViewController: UIViewController;

constructor() {
if (typeof AVAudioSession.sharedInstance().setCategoryModeOptionsError === "function") {
Expand Down Expand Up @@ -192,7 +192,12 @@ export class BarcodeScanner {
public stop(): Promise<any> {
return new Promise((resolve, reject) => {
try {
this.getViewControllerToPresentFrom(this._lastScanOptions ? this._lastScanOptions.presentInRootViewController : false).dismissViewControllerAnimatedCompletion(true, null);
if (this._lastScanViewController) {
this._lastScanViewController.dismissViewControllerAnimatedCompletion(true, null);
this._lastScanViewController = undefined;
} else {
this.getViewControllerToPresentFrom().dismissViewControllerAnimatedCompletion(true, null);
}
this._removeVolumeObserver();
this._closeCallback && this._closeCallback();
resolve();
Expand All @@ -217,7 +222,6 @@ export class BarcodeScanner {
this._addVolumeObserver();

arg = arg || {};
this._lastScanOptions = arg;

let closeButtonLabel = arg.cancelLabel || "Close";
let isContinuous = typeof arg.continuousScanCallback === "function";
Expand Down Expand Up @@ -347,6 +351,7 @@ export class BarcodeScanner {
viewController = UIApplication.sharedApplication.keyWindow.rootViewController;
}

this._lastScanViewController = viewController;
return viewController;
}
}
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.0",
"version": "3.3.1",
"description": "Scan QR/barcodes with your NativeScript app.",
"main": "barcodescanner",
"typings": "index.d.ts",
Expand Down

0 comments on commit 4b3a5ab

Please sign in to comment.