react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
98 lines (93 loc) • 3.04 kB
text/typescript
import { CameraPreviewMode } from '../common/Common';
import { DeepPartial, PartiallyConstructible } from '../../utils';
import { OrientationLockMode } from '../common/Common';
/**
Determines which camera module to use on start-up.
- `FRONT`:
Use the front camera.
- `BACK`:
Use the default back camera.
- `BACK_WIDEST`:
Use the back camera with the widest available angle. iOS only.
*/
export type CameraModule = 'FRONT' | 'BACK' | 'BACK_WIDEST';
/**
Configuration of the camera settings to be used while scanning.
*/
export class CameraConfiguration extends PartiallyConstructible {
/**
Determines which camera module to use on start-up.
Default is BACK
*/
public cameraModule: CameraModule = 'BACK';
/**
The zoom steps available to the user.
*/
public zoomSteps: number[] = [1.0, 2.0, 5.0];
/**
The default zoom factor on start-up.
Default is 1.0
*/
public defaultZoomFactor: number = 1.0;
/**
Determines whether the flash is enabled on start-up.
Default is false
*/
public flashEnabled: boolean = false;
/**
Determines whether to lock the focus at the minimum possible distance (device-specific).
Default is false
*/
public minFocusDistanceLock: boolean = false;
/**
Determines whether touch-to-focus is enabled or not. Android only.
Default is false
*/
public touchToFocusEnabled: boolean = false;
/**
Determines whether pinch-to-zoom is enabled or not.
Default is true
*/
public pinchToZoomEnabled: boolean = true;
/**
Determines which mode to use when orientation should be locked to landscape or portrait.
Default is NONE
*/
public orientationLockMode: OrientationLockMode = 'NONE';
/**
Determines which camera preview mode to use.
Default is FILL_IN
*/
public cameraPreviewMode: CameraPreviewMode = 'FILL_IN';
/** @param source {@displayType `DeepPartial<CameraConfiguration>`} */
public constructor(source: DeepPartial<CameraConfiguration> = {}) {
super();
if (source.cameraModule !== undefined) {
this.cameraModule = source.cameraModule;
}
if (source.zoomSteps !== undefined) {
this.zoomSteps = source.zoomSteps.map((it) => it);
}
if (source.defaultZoomFactor !== undefined) {
this.defaultZoomFactor = source.defaultZoomFactor;
}
if (source.flashEnabled !== undefined) {
this.flashEnabled = source.flashEnabled;
}
if (source.minFocusDistanceLock !== undefined) {
this.minFocusDistanceLock = source.minFocusDistanceLock;
}
if (source.touchToFocusEnabled !== undefined) {
this.touchToFocusEnabled = source.touchToFocusEnabled;
}
if (source.pinchToZoomEnabled !== undefined) {
this.pinchToZoomEnabled = source.pinchToZoomEnabled;
}
if (source.orientationLockMode !== undefined) {
this.orientationLockMode = source.orientationLockMode;
}
if (source.cameraPreviewMode !== undefined) {
this.cameraPreviewMode = source.cameraPreviewMode;
}
}
}