diff --git a/package-lock.json b/package-lock.json index 87527e8f4..db9507d5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "@ngx-formly/core": "^5.10.22", "@ngx-formly/material": "^5.10.22", "@ngx-formly/schematics": "^5.10.22", - "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera", "@numbersprotocol/preview-video": "github:numbersprotocol/preview-video", "@techiediaries/ngx-qrcode": "^9.1.0", "async-mutex": "^0.3.2", @@ -4157,8 +4157,8 @@ } }, "node_modules/@numbersprotocol/preview-camera": { - "version": "0.0.2", - "resolved": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#2ce3dc63f83780c4c8e7afe8291238b9c838eb5c", + "version": "0.0.3", + "resolved": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#cc4a7d544220040e4fad9730dbdd2251458390c3", "license": "MIT", "peerDependencies": { "@capacitor/core": "^3.0.0" @@ -28525,8 +28525,8 @@ } }, "@numbersprotocol/preview-camera": { - "version": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#2ce3dc63f83780c4c8e7afe8291238b9c838eb5c", - "from": "@numbersprotocol/preview-camera@github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "version": "git+ssh://git@github.com/numbersprotocol/preview-camera.git#cc4a7d544220040e4fad9730dbdd2251458390c3", + "from": "@numbersprotocol/preview-camera@numbersprotocol/preview-camera", "requires": {} }, "@numbersprotocol/preview-video": { diff --git a/package.json b/package.json index 825908e70..ef0a656e3 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@ngx-formly/core": "^5.10.22", "@ngx-formly/material": "^5.10.22", "@ngx-formly/schematics": "^5.10.22", - "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera#release-0.0.2-auto-rotate-fix", + "@numbersprotocol/preview-camera": "github:numbersprotocol/preview-camera", "@numbersprotocol/preview-video": "github:numbersprotocol/preview-video", "@techiediaries/ngx-qrcode": "^9.1.0", "async-mutex": "^0.3.2", diff --git a/src/app/features/home/custom-camera/custom-camera.page.html b/src/app/features/home/custom-camera/custom-camera.page.html index 0e7d2a6ed..aa169603f 100644 --- a/src/app/features/home/custom-camera/custom-camera.page.html +++ b/src/app/features/home/custom-camera/custom-camera.page.html @@ -5,6 +5,11 @@ >
+ + + {{ isFlashOn ? 'flash_on' : 'flash_off' }} + +
(this.captureVideoFinishedListener = listener)); this.startPreviewCamera(); + + this.isTorchOn().then(value => { + console.log(`isFlashOn: ${value.result}`); + + return (this.isFlashOn = value.result); + }); } async ionViewDidEnter() { @@ -167,6 +175,15 @@ export class CustomCameraPage implements OnInit, OnDestroy { this.leaveCustomCamera(); } + async isTorchOn() { + return this.customCameraService.isTorchOn(); + } + + async enableTorch() { + await this.customCameraService.enableTorch(!this.isFlashOn); + this.isFlashOn = (await this.customCameraService.isTorchOn()).result; + } + async leaveCustomCamera() { return this.location.back(); } diff --git a/src/app/features/home/custom-camera/custom-camera.service.ts b/src/app/features/home/custom-camera/custom-camera.service.ts index 2bce4eebe..a1ea82c23 100644 --- a/src/app/features/home/custom-camera/custom-camera.service.ts +++ b/src/app/features/home/custom-camera/custom-camera.service.ts @@ -98,6 +98,16 @@ export class CustomCameraService { await this.filesystemPlugin.deleteFile({ path: filePath }); } + // eslint-disable-next-line class-methods-use-this + async isTorchOn() { + return await PreviewCamera.isTorchOn(); + } + + // eslint-disable-next-line class-methods-use-this + async enableTorch(enable: boolean) { + return await PreviewCamera.enableTorch({ enable }); + } + private changeGlobalCSSBackgroundToTransparent() { document.querySelector('body')?.classList.add(this.globalCSSClass); document.querySelector('ion-app')?.classList.add(this.globalCSSClass);