Skip to content

Commit cdb4cdf

Browse files
author
farfromrefuge
committed
feat: aspectRatio property
1 parent f4b820a commit cdb4cdf

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/ui-cameraview/index.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TakePictureOptions } from '.';
22
import {
33
CameraViewBase,
44
ScaleType,
5+
aspectRatioProperty,
56
autoFocusProperty,
67
captureModeProperty,
78
enablePinchZoomProperty,
@@ -235,6 +236,9 @@ export class CameraView extends CameraViewBase {
235236
[stretchProperty.setNative](value) {
236237
this.nativeViewProtected.setScaleType(getScaleType(value));
237238
}
239+
[aspectRatioProperty.setNative](value) {
240+
this.nativeViewProtected.setAspectRatio(value);
241+
}
238242
[flashModeProperty.setNative](value: string | number) {
239243
if (typeof value === 'string') {
240244
switch (value) {

src/ui-cameraview/index.common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const jpegQualityProperty = new Property<CameraViewBase, number>({
6969
valueConverter: (d) => parseInt(d, 10)
7070
});
7171
export const stretchProperty = new Property<CameraViewBase, string>({ name: 'stretch' });
72+
export const aspectRatioProperty = new Property<CameraViewBase, string>({ name: 'aspectRatio' });
7273

7374
jpegQualityProperty.register(CameraViewBase);
7475
pictureSizeProperty.register(CameraViewBase);
@@ -78,3 +79,4 @@ autoFocusProperty.register(CameraViewBase);
7879
enablePinchZoomProperty.register(CameraViewBase);
7980
saveToGalleryProperty.register(CameraViewBase);
8081
stretchProperty.register(CameraViewBase);
82+
aspectRatioProperty.register(CameraViewBase);

src/ui-cameraview/typings/android.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ declare namespace com {
290290
public getAllowExifRotation(): boolean;
291291
public setScaleType(param0: androidx.camera.view.PreviewView.ScaleType): void;
292292
public getScaleType(): androidx.camera.view.PreviewView.ScaleType;
293+
public setAspectRatio(param0: string): void;
294+
public getAspectRatio(): string;
293295
public getRotation(): CameraOrientation;
294296
public getAllAvailablePictureSizes(): androidNative.Array<Size>;
295297
public orientationUpdated(): void;

0 commit comments

Comments
 (0)