From 47ea6ad851d963d369432569d41c6f9ab2bbfa16 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 16 Sep 2023 06:21:15 -0400 Subject: [PATCH] Start scan --- REMEMBER.txt | 4 +- src/app/app-routing.module.ts | 4 + .../pages/familylogin/familylogin.page.html | 2 +- src/app/pages/familylogin/familylogin.page.ts | 49 +-- .../startscan/startscan-routing.module.ts | 17 + src/app/pages/startscan/startscan.module.ts | 20 + src/app/pages/startscan/startscan.page.html | 12 + src/app/pages/startscan/startscan.page.scss | 385 ++++++++++++++++++ .../pages/startscan/startscan.page.spec.ts | 24 ++ src/app/pages/startscan/startscan.page.ts | 76 ++++ 10 files changed, 546 insertions(+), 47 deletions(-) create mode 100644 src/app/pages/startscan/startscan-routing.module.ts create mode 100644 src/app/pages/startscan/startscan.module.ts create mode 100644 src/app/pages/startscan/startscan.page.html create mode 100644 src/app/pages/startscan/startscan.page.scss create mode 100644 src/app/pages/startscan/startscan.page.spec.ts create mode 100644 src/app/pages/startscan/startscan.page.ts diff --git a/REMEMBER.txt b/REMEMBER.txt index af4cb7d..1aae2cc 100644 --- a/REMEMBER.txt +++ b/REMEMBER.txt @@ -26,4 +26,6 @@ npm install bn-ng-idle npm install @capacitor-community/barcode-scanner npx cap sync -https://github.com/capacitor-community/barcode-scanner \ No newline at end of file +https://github.com/capacitor-community/barcode-scanner + +ionic generate page startscan diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ed6bbad..a493d42 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -214,6 +214,10 @@ const routes: Routes = [ path: 'familymember', loadChildren: () => import('./pages/familymember/familymember.module').then(m => m.FamilymemberPageModule) }, + { + path: 'startscan', + loadChildren: () => import('./pages/startscan/startscan.module').then(m => m.StartscanPageModule) + }, ]; @NgModule({ diff --git a/src/app/pages/familylogin/familylogin.page.html b/src/app/pages/familylogin/familylogin.page.html index 6105675..e620bf0 100644 --- a/src/app/pages/familylogin/familylogin.page.html +++ b/src/app/pages/familylogin/familylogin.page.html @@ -4,7 +4,7 @@
- Scan Qr Code + Scan Qr Code
diff --git a/src/app/pages/familylogin/familylogin.page.ts b/src/app/pages/familylogin/familylogin.page.ts index 12a7e1b..3216eb8 100644 --- a/src/app/pages/familylogin/familylogin.page.ts +++ b/src/app/pages/familylogin/familylogin.page.ts @@ -91,49 +91,8 @@ export class FamilyloginPage implements OnInit { this.router.navigate(['login']); } - - async checkPermission() { - try { - // check or request permission - const status = await BarcodeScanner.checkPermission({ force: true }); - if (status.granted) { - // the user granted permission - return true; - } - return false; - } catch(e) { - console.log(e); - } - } - scannedResult:any; - async startScan() { - try { - const permission = await this.checkPermission(); - if(!permission) { - return; - } - await BarcodeScanner.hideBackground(); - document.querySelector('body').classList.add('scanner-active'); - this.content_visibility = 'hidden'; - const result = await BarcodeScanner.startScan(); - console.log(result); - BarcodeScanner.showBackground(); - document.querySelector('body').classList.remove('scanner-active'); - this.content_visibility = ''; - if(result?.hasContent) { - this.scannedResult = result.content; - console.log(this.scannedResult); - } - } catch(e) { - console.log(e); - this.stopScan(); - } - } - - stopScan() { - BarcodeScanner.showBackground(); - BarcodeScanner.stopScan(); - document.querySelector('body').classList.remove('scanner-active'); - this.content_visibility = ''; - } +moveToStartScan(){ + this.router.navigate(['startscan']); +} + } diff --git a/src/app/pages/startscan/startscan-routing.module.ts b/src/app/pages/startscan/startscan-routing.module.ts new file mode 100644 index 0000000..e8f21cf --- /dev/null +++ b/src/app/pages/startscan/startscan-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +import { StartscanPage } from './startscan.page'; + +const routes: Routes = [ + { + path: '', + component: StartscanPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class StartscanPageRoutingModule {} diff --git a/src/app/pages/startscan/startscan.module.ts b/src/app/pages/startscan/startscan.module.ts new file mode 100644 index 0000000..21b283e --- /dev/null +++ b/src/app/pages/startscan/startscan.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { IonicModule } from '@ionic/angular'; + +import { StartscanPageRoutingModule } from './startscan-routing.module'; + +import { StartscanPage } from './startscan.page'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + StartscanPageRoutingModule + ], + declarations: [StartscanPage] +}) +export class StartscanPageModule {} diff --git a/src/app/pages/startscan/startscan.page.html b/src/app/pages/startscan/startscan.page.html new file mode 100644 index 0000000..170565a --- /dev/null +++ b/src/app/pages/startscan/startscan.page.html @@ -0,0 +1,12 @@ + + + + + + + +
+ Stop Scan +
+
+
diff --git a/src/app/pages/startscan/startscan.page.scss b/src/app/pages/startscan/startscan.page.scss new file mode 100644 index 0000000..1c3cf7a --- /dev/null +++ b/src/app/pages/startscan/startscan.page.scss @@ -0,0 +1,385 @@ + +ion-content { + .back_image { + width: 100%; + height: 230px; + + .back { + font-size: 25px; + color: white; + } + } + + .flex { + display: flex; + justify-content: space-between; + align-items: center; + + ion-icon { + font-size: 22px; + } + } + + .row { + display: flex; + align-items: center; + margin-top: 10px; + + .bg_text { + color: var(--ion-color-primary); + background: #dfe1f3; + font-size: 12px; + padding: 2px 5px; + border-radius: 5px; + margin-right: 10px; + } + + .rate { + display: flex; + align-items: center; + + .review { + margin-left: 5px; + } + } + } + + .color_text { + margin-top: 10px; + font-size: 22px; + font-family: 'semi-bold'; + color: var(--ion-color-primary); + } + + .items { + display: flex; + justify-content: space-between; + margin-top: 10px; + margin-bottom: 20px; + border-bottom: 1px solid lightgrey; + padding-bottom: 10px; + + .stud { + display: flex; + align-items: center; + + ion-icon { + margin-right: 5px; + } + + ion-label { + color: grey; + } + } + } + + .about { + margin-top: 10px; + + .head_text { + font-size: 18px; + font-family: 'semi-bold'; + margin-bottom: 10px; + } + + .mentor { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 20px; + + .left { + display: flex; + + .men_image { + height: 50px; + width: 50px; + border-radius: 100%; + } + + .bold { + font-family: 'semi-bold'; + } + + .grey { + color: grey; + font-size: 14px; + } + } + + ion-icon { + font-size: 25px; + } + } + + .description { + color: grey; + margin-bottom: 5px; + } + } + + .lesson { + margin-top: 20px; + + .bold { + font-family: 'semi-bold'; + } + + .color { + color: var(--ion-color-primary); + } + + .grey { + color: grey; + } + + .sec { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 10px; + } + + .video { + display: flex; + justify-content: space-between; + align-items: center; + background-color: white; + padding: 15px; + box-shadow: 0px 0px 20px 1px rgba(0, 0, 0, 0.1); + border-radius: 10px; + margin-top: 20px; + + .left { + display: flex; + } + + .men_image { + height: 40px; + width: 40px; + border-radius: 100%; + } + + .text { + margin-left: 10px; + } + + .bold_text { + font-size: 16px; + font-family: 'bold'; + } + + .grey_text { + font-size: 14px; + color: grey; + } + } + } + + .review_tab { + margin-top: 20px; + + .total { + display: flex; + align-items: center; + justify-content: space-between; + + .star-rate { + display: flex; + align-items: center; + + .bold { + font-size: 17px; + font-family: 'semi-bold'; + margin-left: 5px; + } + } + + .color { + color: var(--ion-color-primary); + font-size: 14px; + } + } + + + .story-item { + overflow: scroll; + display: flex; + flex-direction: row; + margin-top: 20px; + + .menu { + width: 100%; + display: flex; + flex-direction: row; + + .item { + padding: 5px; + margin: 5px; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + + ion-thumbnail { + border-radius: 15px; + width: max-content; + height: 60px; + width: 60px; + --border-radius: 50%; + } + + ion-label { + font-size: 14px; + font-family: "medium"; + color: var(--ion-color-medium); + } + } + + .text { + + display: flex; + align-items: center; + text-align: center; + + .select { + display: flex; + align-items: center; + border: 1px solid var(--ion-color-primary); + border-radius: 20px; + padding: 2px 15px; + margin-right: 10px; + + .rate_num { + margin-left: 5px; + color: var(--ion-color-primary); + } + } + + .show { + background-color: var(--ion-color-primary); + } + + .white { + color: white !important; + } + + .choice { + display: flex; + } + } + } + } + + .reviw_list { + margin-top: 25px; + + .profile { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; + + .left { + display: flex; + align-items: center; + + .men_image { + height: 40px; + width: 40px; + border-radius: 100%; + } + + + .bold { + font-family: 'semi-bold'; + } + + .grey { + color: grey; + font-size: 14px; + } + } + + .right { + display: flex; + align-items: center; + + .select { + display: flex; + align-items: center; + border: 1px solid var(--ion-color-primary); + border-radius: 20px; + padding: 2px 15px; + margin-right: 10px; + + .rate_num { + margin-left: 5px; + color: var(--ion-color-primary); + } + } + + ion-icon { + font-size: 20px; + } + } + } + + .like { + display: flex; + align-items: center; + margin-top: 10px; + + .heart { + font-size: 25px; + margin-right: 5px; + } + + .count { + margin-right: 10px; + } + + .time { + color: grey; + font-size: 14px; + } + } + } + } + + + + .bold_text { + font-size: 20px; + font-family: 'bold'; + } +} + + +ion-footer { + --background: white; + + ion-toolbar { + --border-width: 0px; + padding: 10px; + align-items: center; + + ion-icon { + color: white; + font-size: 25px; + } + + .button { + background-color: var(--ion-color-primary); + display: flex; + align-items: center; + justify-content: space-around; + border-radius: 30px; + padding: 12px 0; + + .text { + color: white; + } + } + } +} diff --git a/src/app/pages/startscan/startscan.page.spec.ts b/src/app/pages/startscan/startscan.page.spec.ts new file mode 100644 index 0000000..3f23bdb --- /dev/null +++ b/src/app/pages/startscan/startscan.page.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { StartscanPage } from './startscan.page'; + +describe('StartscanPage', () => { + let component: StartscanPage; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ StartscanPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(StartscanPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/startscan/startscan.page.ts b/src/app/pages/startscan/startscan.page.ts new file mode 100644 index 0000000..e436997 --- /dev/null +++ b/src/app/pages/startscan/startscan.page.ts @@ -0,0 +1,76 @@ +import { Component, OnInit } from '@angular/core'; +import {NavController} from "@ionic/angular"; +import {Router} from "@angular/router"; +import { BarcodeScanner } from '@capacitor-community/barcode-scanner'; +@Component({ + selector: 'app-startscan', + templateUrl: './startscan.page.html', + styleUrls: ['./startscan.page.scss'], +}) +export class StartscanPage implements OnInit { + + content_visibility = ''; + tabs = 'about'; + + constructor( + private navctr: NavController, + private router: Router + ) { } + + ngOnInit() { + this.startScan(); + } + + onBack() { + this.stopScan(); + this.navctr.back(); + } + + + async checkPermission() { + try { + // check or request permission + const status = await BarcodeScanner.checkPermission({ force: true }); + if (status.granted) { + // the user granted permission + return true; + } + return false; + } catch(e) { + console.log(e); + } + } + scannedResult:any; + async startScan() { + try { + const permission = await this.checkPermission(); + if(!permission) { + this. stopScan(); + return; + } + await BarcodeScanner.hideBackground(); + document.querySelector('body').classList.add('scanner-active'); + this.content_visibility = 'hidden'; + const result = await BarcodeScanner.startScan(); + console.log(result); + BarcodeScanner.showBackground(); + document.querySelector('body').classList.remove('scanner-active'); + this.content_visibility = ''; + if(result?.hasContent) { + this.scannedResult = result.content; + console.log(this.scannedResult); + } + } catch(e) { + console.log(e); + this.stopScan(); + } + } + + stopScan() { + BarcodeScanner.showBackground(); + BarcodeScanner.stopScan(); + document.querySelector('body').classList.remove('scanner-active'); + this.content_visibility = ''; + } + +}