Skip to content

Commit

Permalink
Merge pull request #2001 from numbersprotocol/feat-tap-to-focus
Browse files Browse the repository at this point in the history
Feat tap to focus
  • Loading branch information
bafu committed Sep 5, 2022
2 parents dbf9494 + b94188e commit e78d5ed
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
31 changes: 28 additions & 3 deletions package-lock.json

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

Expand Up @@ -4,7 +4,7 @@
*transloco="let t"
>
<ng-container *ngIf="(mode$ | ngrxPush) === 'capture'">
<div id="camera-flash-placeholder"></div>
<div id="camera-flash-placeholder" (click)="focus($event)"></div>

<mat-icon
*ngIf="isFlashAvailable"
Expand Down
5 changes: 5 additions & 0 deletions src/app/features/home/custom-camera/custom-camera.page.ts
Expand Up @@ -187,6 +187,11 @@ export class CustomCameraPage implements OnInit, OnDestroy {
this.isFlashOn = (await this.customCameraService.isTorchOn()).result;
}

// eslint-disable-next-line class-methods-use-this
async focus(event: PointerEvent | MouseEvent) {
await this.customCameraService.focus(event.x, event.y);
}

async leaveCustomCamera() {
return this.location.back();
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/features/home/custom-camera/custom-camera.service.ts
Expand Up @@ -115,6 +115,13 @@ export class CustomCameraService {
return Promise.resolve();
}

async focus(x: number, y: number) {
if (this.isNativePlatform) {
return await PreviewCamera.focus({ x, y });
}
return Promise.resolve();
}

async isTorchAvailable(): Promise<boolean> {
if (this.isNativePlatform) {
return (await PreviewCamera.isTorchAvailable()).result;
Expand Down

0 comments on commit e78d5ed

Please sign in to comment.