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 cbcb61d commit d9d6dbb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/barcodescanner-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/barcodescanner.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit d9d6dbb

Please sign in to comment.