Skip to content

Commit

Permalink
Merge pull request #46 from SCCapstone/rohanbsher
Browse files Browse the repository at this point in the history
Rohanbsher
  • Loading branch information
rohanbsher authored Dec 6, 2019
2 parents df989ec + f498049 commit 1c8bf3f
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 175 deletions.
73 changes: 19 additions & 54 deletions AddMe/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions AddMe/src/app/camera/camera.page.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<ion-header>
<ion-toolbar>
<ion-button slot="start" shape="round" (click)="goToHome()">
<ion-icon name="arrow-back"></ion-icon>
<ion-button slot="start" fill="clear" shape="round" (click)="goToHome()">
<ion-icon color="dark" name="arrow-back"></ion-icon>
</ion-button>
<ion-title class="ion-text-center">Camera</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>

</ion-content>
6 changes: 6 additions & 0 deletions AddMe/src/app/camera/camera.page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ion-content
{
opacity:0;
width:100vw;
height:100vh;
}
40 changes: 22 additions & 18 deletions AddMe/src/app/camera/camera.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@ import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner/ngx';
styleUrls: ['./camera.page.scss'],
})
export class CameraPage implements OnInit {

constructor(private router: Router, private qrScanner: QRScanner) { }
constructor(private router: Router, private qrScanCtrl: QRScanner) { }

goToHome() {
this.router.navigate(['home']);
}
ngOnInit(){
this.qrScanCtrl.prepare()
.then((status: QRScannerStatus) => {
if (status.authorized) {
// Open camera preview
this.qrScanCtrl.show();
const scanSub = this.qrScanCtrl.scan().subscribe((text: string) => {
// At this point, a QR code was recognized and scanned
alert(`QR Code Scanned!: ${text}`)
// The QR data is stored in 'text'...

ngOnInit() {
this.qrScanner.prepare().then((state: QRScannerStatus) => {
if(state.authorized) {
alert("authorized");
this.qrScanner.useBackCamera();

this.qrScanner.show();
this.qrScanner.scan().subscribe(txt => {
alert(txt);
//this.qrScanner.hide();
// Close QR scanner
this.qrScanCtrl.hide();
this.qrScanCtrl.destroy();
scanSub.unsubscribe()
});
} else if(state.denied) {
alert("denied");
this.qrScanner.openSettings();
}
}).catch((e: any) => alert('Error: '+e));
}
else if (status.denied) {
alert('camera permission denied');
this.qrScanCtrl.openSettings();
}
})
.catch((e: any) => {alert(e)});
}

}
Loading

0 comments on commit 1c8bf3f

Please sign in to comment.