-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS & Angular] Open barcode scanner from a modal page not working #183
- Loading branch information
1 parent
3d0592b
commit eab6b7d
Showing
9 changed files
with
161 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<GridLayout rows="auto, auto, auto" backgroundColor="white"> | ||
<label row="0" text="Modal dialog"></label> | ||
<button row="1" text="close" (tap)="close()"></button> | ||
<button row="2" text="QR scanner" (tap)="openNotification()" class="btn btn-primary"></button> | ||
</GridLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Component } from "@angular/core"; | ||
import { ModalDialogParams } from "nativescript-angular/modal-dialog"; | ||
import { BarcodeScanner } from "nativescript-barcodescanner"; | ||
|
||
@Component({ | ||
selector: "modal", | ||
moduleId: module.id, | ||
templateUrl: "./modal.component.html", | ||
styleUrls: ["./modal.component.css"], | ||
|
||
}) | ||
|
||
export class ModalComponent { | ||
barcodescanner: any; | ||
|
||
constructor(private params: ModalDialogParams) { | ||
this.barcodescanner = new BarcodeScanner(); | ||
} | ||
|
||
close() { | ||
this.params.closeCallback(); | ||
} | ||
|
||
public onScanResult(evt) { | ||
// console.log(evt.object); | ||
console.log(`onScanResult: ${evt.text} (${evt.format})`); | ||
} | ||
|
||
openNotification() { | ||
console.log("OPEN NOTIFICATION!"); | ||
this.close(); | ||
|
||
this.barcodescanner.scan({ | ||
formats: "QR_CODE, EAN_13", | ||
cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close' | ||
cancelLabelBackgroundColor: "#333333", // iOS only, default '#000000' (black) | ||
|
||
showFlipCameraButton: true, // default false | ||
preferFrontCamera: false, // default false | ||
showTorchButton: true, // default false | ||
beepOnScan: true, // Play or Suppress beep on scan (default true) | ||
torchOn: false, // launch with the flashlight on (default false) | ||
closeCallback: () => { | ||
console.log("Scanner closed"); | ||
}, // invoked when the scanner was closed (success or abort) | ||
|
||
openSettingsIfPermissionWasPreviouslyDenied: true // On iOS you can send the user to the settings app if access was previously denied | ||
}).then((result) => { | ||
// Note that this Promise is never invoked when a 'continuousScanCallback' function is provided | ||
console.log({ | ||
title: "Scan result", | ||
message: "Format: " + result.format + ",\nValue: " + result.text, | ||
okButtonText: "OK" | ||
}); | ||
}, (errorMessage) => { | ||
console.log("No scan. " + errorMessage); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters