nativescript-barcodescanner
Advanced tools
Comparing version 3.2.2 to 3.3.0
@@ -23,2 +23,3 @@ import { ContentView } from "tns-core-modules/ui/content-view"; | ||
openSettingsIfPermissionWasPreviouslyDenied?: boolean; | ||
presentInRootViewController?: boolean; | ||
} | ||
@@ -25,0 +26,0 @@ export interface Android extends CommonScanOptions { |
@@ -225,3 +225,3 @@ "use strict"; | ||
setTimeout(function () { | ||
_this.getViewControllerToPresentFrom().presentViewControllerAnimatedCompletion(_this._scanner, true, function () { | ||
_this.getViewControllerToPresentFrom(arg.presentInRootViewController).presentViewControllerAnimatedCompletion(_this._scanner, true, function () { | ||
if (arg.torchOn) { | ||
@@ -254,7 +254,7 @@ _this._enableTorch(); | ||
}; | ||
BarcodeScanner.prototype.getViewControllerToPresentFrom = function () { | ||
BarcodeScanner.prototype.getViewControllerToPresentFrom = function (presentInRootViewController) { | ||
var frame = require("tns-core-modules/ui/frame"); | ||
var viewController; | ||
var topMostFrame = frame.topmost(); | ||
if (topMostFrame) { | ||
if (topMostFrame && presentInRootViewController !== true) { | ||
viewController = topMostFrame.currentPage && topMostFrame.currentPage.ios; | ||
@@ -261,0 +261,0 @@ if (viewController) { |
{ | ||
"name": "nativescript-barcodescanner", | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"description": "Scan QR/barcodes with your NativeScript app.", | ||
@@ -26,3 +26,3 @@ "main": "barcodescanner", | ||
"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", | ||
@@ -73,4 +73,4 @@ "demo-vue.ios": "npm run tsc && cd ../demo-vue && tns run ios --bundle", | ||
"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", | ||
@@ -77,0 +77,0 @@ "prompt": "^1.0.0", |
@@ -188,3 +188,4 @@ # NativeScript BarcodeScanner | ||
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) => { | ||
@@ -314,38 +315,39 @@ // Note that this Promise is never invoked when a 'continuousScanCallback' function is provided | ||
When using Angular 2, it is best to inject dependencies into your classes. Here is an example of how you | ||
can set up `nativescript-barcodescanner` in an Angular 2 app with dependency injection. | ||
You may have injected the `BarcodeScanner` class in your component constructor in the past, | ||
but please don't do that anymore because in release builds you may experience a crash. | ||
1. Register the provider with your module | ||
```typescript | ||
//app.module.ts | ||
import { NgModule, ValueProvider } from '@angular/core'; | ||
import { BarcodeScanner } from 'nativescript-barcodescanner'; | ||
//other imports | ||
So instead of: | ||
@NgModule({ | ||
//bootstrap, declarations, imports, etc. | ||
providers: [ | ||
BarcodeScanner | ||
] | ||
}) | ||
export class AppModule {} | ||
``` | ||
1. Inject it into your component | ||
```typescript | ||
// my-component.ts | ||
import { Component, Inject } from '@angular/core'; | ||
import { BarcodeScanner } from 'nativescript-barcodescanner'; | ||
```typescript | ||
// my-component.ts | ||
import { Component, Inject } from '@angular/core'; | ||
import { BarcodeScanner } from 'nativescript-barcodescanner'; | ||
@Component({ ... }) | ||
export class MyComponent { | ||
constructor(private barcodeScanner: BarcodeScanner) { | ||
} | ||
@Component({ ... }) | ||
export class MyComponent { | ||
constructor(private barcodeScanner: BarcodeScanner) { | ||
} | ||
//use the barcodescanner wherever you need it. See general usage above. | ||
scanBarcode() { | ||
this.barcodeScanner.scan({ ... }); | ||
} | ||
} | ||
``` | ||
//use the barcodescanner wherever you need it. See general usage above. | ||
scanBarcode() { | ||
this.barcodeScanner.scan({ ... }); | ||
} | ||
} | ||
``` | ||
Simply do: | ||
```typescript | ||
// my-component.ts | ||
import { Component, Inject } from '@angular/core'; | ||
import { BarcodeScanner } from 'nativescript-barcodescanner'; | ||
@Component({ ... }) | ||
//use the barcodescanner wherever you need it. See general usage above. | ||
scanBarcode() { | ||
new BarcodeScanner().scan({ ... }); | ||
} | ||
} | ||
``` | ||
#### Webpack usage | ||
@@ -352,0 +354,0 @@ If you run into an error when Webpacking, open `app.module.ts` and add this: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1690680
799
385