From d9d6dbb46efcaff9aa05b0d2a5bbf12c32f6bd8a Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Tue, 10 Sep 2019 21:00:22 +0200 Subject: [PATCH] [iOS] Custom navigation vanishes after camera was opened #220 --- .travis.yml | 18 +++++++++++------- CHANGELOG.md | 10 ++++++++++ README.md | 3 ++- demo/app/main-view-model.ts | 1 + src/barcodescanner-common.ts | 6 ++++++ src/barcodescanner.ios.ts | 6 +++--- src/package.json | 8 ++++---- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90a101f..a41fa1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,40 +3,44 @@ matrix: - stage: "Lint" language: node_js os: linux - node_js: "8" + node_js: "10" script: cd src && npm run ci.tslint - stage: "WebPack, Build" os: osx env: - WebPack="iOS" - osx_image: xcode10.0 + osx_image: xcode10.2 language: node_js - node_js: "8" + node_js: "10" jdk: oraclejdk8 + before_script: pod repo update script: cd demo && npm run build.plugin && npm i && tns build ios --bundle --env.uglify - language: android os: linux env: - WebPack="Android" jdk: oraclejdk8 - before_install: nvm install 8 + dist: trusty + before_install: nvm install 10 script: cd demo && npm run build.plugin && npm i && tns build android --bundle --env.uglify --env.snapshot - language: android env: - BuildAndroid="28" os: linux jdk: oraclejdk8 - before_install: nvm install stable + dist: trusty + before_install: nvm install 10 script: - cd src && npm i && npm run tsc && cd ../demo && tns build android - os: osx env: - BuildiOS="12" - Xcode="10.0" - osx_image: xcode10.0 + osx_image: xcode10.2 language: node_js - node_js: "8" + node_js: "10" jdk: oraclejdk8 + before_script: pod repo update script: - cd src && npm i && npm run tsc && cd ../demo && tns build ios diff --git a/CHANGELOG.md b/CHANGELOG.md index e316363..53e06cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,21 @@ # Changelog +## [3.3.0](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.3.0) (2019-09-10) +[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/43?closed=1) + + +## [3.2.2](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.2.2) (2019-07-30) +[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/42?closed=1) + + ## [3.2.1](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.2.1) (2019-07-04) [Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/41?closed=1) + ## [3.2.0](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.2.0) (2019-06-07) [Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/40?closed=1) + ## [3.1.2](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.1.2) (2019-03-12) [Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/38?closed=1) diff --git a/README.md b/README.md index 77a7a60..f7dce31 100755 --- a/README.md +++ b/README.md @@ -185,7 +185,8 @@ Tip: during a scan you can use the volume up/down buttons to toggle the torch. closeCallback: () => { console.log("Scanner closed")}, // invoked when the scanner was closed (success or abort) resultDisplayDuration: 500, // Android only, default 1500 (ms), set to 0 to disable echoing the scanned text orientation: orientation, // Android only, default undefined (sensor-driven orientation), other options: portrait|landscape - openSettingsIfPermissionWasPreviouslyDenied: true // On iOS you can send the user to the settings app if access was previously denied + openSettingsIfPermissionWasPreviouslyDenied: true, // On iOS you can send the user to the settings app if access was previously denied + presentInRootViewController: true // iOS-only; If you're sure you're not presenting the (non embedded) scanner in a modal, or are experiencing issues with fi. the navigationbar, set this to 'true' and see if it works better for your app (default false). }).then((result) => { // Note that this Promise is never invoked when a 'continuousScanCallback' function is provided alert({ diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index 07d5e7f..6278cd2 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -100,6 +100,7 @@ export class HelloWorldModel extends Observable { private scan(front: boolean, flip: boolean, torch?: boolean, orientation?: string) { this.barcodeScanner.scan({ + presentInRootViewController: true, // not needed here, but added it just for show cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close' cancelLabelBackgroundColor: "#333333", // iOS only, default '#000000' (black) message: "Use the volume buttons for extra light", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.' diff --git a/src/barcodescanner-common.ts b/src/barcodescanner-common.ts index bb9bf7f..9107b05 100644 --- a/src/barcodescanner-common.ts +++ b/src/barcodescanner-common.ts @@ -100,6 +100,12 @@ export interface IOS extends CommonScanOptions { * Default: false */ openSettingsIfPermissionWasPreviouslyDenied?: boolean; + /** + * If you're sure you're not presenting the (non embedded) scanner in a modal, + * or are experiencing issues with fi. the navigationbar, please set this to 'true'. + * Default: false + */ + presentInRootViewController?: boolean; } export interface Android extends CommonScanOptions { diff --git a/src/barcodescanner.ios.ts b/src/barcodescanner.ios.ts index b2b1068..c505bdb 100644 --- a/src/barcodescanner.ios.ts +++ b/src/barcodescanner.ios.ts @@ -285,7 +285,7 @@ export class BarcodeScanner { } setTimeout(() => { - this.getViewControllerToPresentFrom().presentViewControllerAnimatedCompletion(this._scanner, true, () => { + this.getViewControllerToPresentFrom(arg.presentInRootViewController).presentViewControllerAnimatedCompletion(this._scanner, true, () => { if (arg.torchOn) { this._enableTorch(); } @@ -319,12 +319,12 @@ export class BarcodeScanner { return false; } - private getViewControllerToPresentFrom(): UIViewController { + private getViewControllerToPresentFrom(presentInRootViewController?: boolean): UIViewController { let frame = require("tns-core-modules/ui/frame"); let viewController: UIViewController; let topMostFrame = frame.topmost(); - if (topMostFrame) { + if (topMostFrame && presentInRootViewController !== true) { viewController = topMostFrame.currentPage && topMostFrame.currentPage.ios; if (viewController) { diff --git a/src/package.json b/src/package.json index 348c426..9b13b8e 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-barcodescanner", - "version": "3.2.2", + "version": "3.3.0", "description": "Scan QR/barcodes with your NativeScript app.", "main": "barcodescanner", "typings": "index.d.ts", @@ -23,7 +23,7 @@ "plugin.tscwatch": "npm run tsc -- -w", "demo.ios": "npm run build && cd ../demo && tns run ios", "demo.reset": "cd ../demo && rimraf platforms", - "demo-ng.ios": "npm run build && cd ../demo-ng && tns run ios", + "demo-ng.ios": "npm run build && cd ../publish && ./pack.sh && cd ../demo-ng && tns plugin remove nativescript-barcodescanner && tns plugin add ../publish/package/*.tgz && tns run ios", "demo.android": "npm run build && cd ../demo && tns run android", "demo-vue.ios": "npm run tsc && cd ../demo-vue && tns run ios --bundle", "demo-vue.android": "npm run tsc && cd ../demo-vue && tns run android --bundle", @@ -69,8 +69,8 @@ }, "homepage": "https://github.com/eddyverbruggen/nativescript-barcodescanner", "devDependencies": { - "tns-core-modules": "~6.0.0", - "tns-platform-declarations": "~6.0.0", + "tns-core-modules": "~6.1.0", + "tns-platform-declarations": "~6.1.0", "typescript": "3.4.5", "prompt": "^1.0.0", "rimraf": "^2.6.2",