react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
310 lines (307 loc) • 12.5 kB
text/typescript
import { ActionBarConfiguration } from '../common/ActionBarConfiguration';
import { ArOverlayFindAndPickConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { ArOverlayGeneralConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { ArOverlayPolygonConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { AspectRatio } from '../common/Common';
import { AustraliaPostCustomerFormat } from '../barcode/BarcodeRecognizerConfiguration';
import { BackgroundStyle } from '../common/Common';
import { BadgeStyle } from '../common/Common';
import { BadgedButton } from '../common/Common';
import { BarcodeDocumentFormat } from '../barcode/BarcodeRecognizerConfiguration';
import { BarcodeFormat } from '../barcode/BarcodeRecognizerConfiguration';
import { BarcodeInfoMapping } from '../barcode/BarcodeInfoMapping';
import { BarcodeItemConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { BarcodeItemErrorState } from '../barcode/BarcodeInfoMapping';
import { BarcodeItemInfoPosition } from '../barcode/ArTrackingOverlayConfiguration';
import { BarcodeItemMapper } from '../BarcodeItemMapper';
import { BarcodeRecognizerConfiguration } from '../barcode/BarcodeRecognizerConfiguration';
import { BarcodeTextLocalization } from '../barcode/BarcodeTextLocalization';
import { BarcodeUseCase } from '../barcode/BarcodeUseCase';
import { BarcodesExtensionFilter } from '../barcode/BarcodeRecognizerConfiguration';
import { ButtonConfiguration } from '../common/Common';
import { CameraConfiguration } from '../common/CameraConfiguration';
import { CameraModule } from '../common/CameraConfiguration';
import { CameraPermissionScreen } from '../common/CameraPermission';
import { CameraPreviewMode } from '../common/Common';
import { CollapsedVisibleHeight } from '../barcode/MultipleScanningModeUseCase';
import { DeepPartial, PartiallyConstructible } from '../../utils';
import { ExpectedBarcode } from '../barcode/FindAndPickScanningModeUseCase';
import { FindAndPickArOverlayPolygonConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { FindAndPickBadgeConfiguration } from '../barcode/ArTrackingOverlayConfiguration';
import { FindAndPickScanningMode } from '../barcode/FindAndPickScanningModeUseCase';
import { FinderCorneredStyle } from '../common/ViewFinderConfiguration';
import { FinderStrokedStyle } from '../common/ViewFinderConfiguration';
import { FinderStyle } from '../common/ViewFinderConfiguration';
import { ForegroundStyle } from '../common/Common';
import { Gs1Handling } from '../barcode/BarcodeRecognizerConfiguration';
import { IconStyle } from '../common/Common';
import { MSIPlesseyChecksumAlgorithm } from '../barcode/BarcodeRecognizerConfiguration';
import { ManualCountEditDialog } from '../barcode/MultipleScanningModeUseCase';
import { MultipleBarcodesScanningMode } from '../barcode/MultipleScanningModeUseCase';
import { MultipleScanningMode } from '../barcode/MultipleScanningModeUseCase';
import { OrientationLockMode } from '../common/Common';
import { Palette } from '../common/Common';
import { PolygonStyle } from '../common/Common';
import { RoundButton } from '../common/Common';
import { ScanbotAlertDialog } from '../common/ScanbotAlertDialog';
import { SheetContent } from '../barcode/MultipleScanningModeUseCase';
import { SheetMode } from '../barcode/MultipleScanningModeUseCase';
import { Sheet } from '../barcode/MultipleScanningModeUseCase';
import { SingleScanningMode } from '../barcode/SingleScanningModeUseCase';
import { SoundType } from '../common/Common';
import { Sound } from '../common/Common';
import { StatusBarMode } from '../common/TopBarConfiguration';
import { StyledText } from '../common/Common';
import { SwipeToDelete } from '../barcode/MultipleScanningModeUseCase';
import { Timeouts } from '../common/Common';
import { TopBarConfiguration } from '../common/TopBarConfiguration';
import { TopBarMode } from '../common/TopBarConfiguration';
import { UserGuidanceConfiguration } from '../common/UserGuidanceConfiguration';
import { Vibration } from '../common/Common';
import { ViewFinderConfiguration } from '../common/ViewFinderConfiguration';
/**
Configuration of the barcode scanner screen.
*/
export class BarcodeScannerConfiguration extends PartiallyConstructible {
/**
Version number of the configuration object.
Default is "1.0"
*/
public readonly version: string = '1.0';
/**
The configuration object should be applied for this screen.
Default is "BarcodeScanner"
*/
public readonly screen: string = 'BarcodeScanner';
/**
Define the screen's base color values from which other colors are derived.
*/
public palette: Palette = new Palette({
sbColorPrimary: '#C8193C',
sbColorPrimaryDisabled: '#F5F5F5',
sbColorNegative: '#FF3737',
sbColorPositive: '#4EFFB4',
sbColorWarning: '#FFCE5C',
sbColorSecondary: '#FFEDEE',
sbColorSecondaryDisabled: '#F5F5F5',
sbColorOnPrimary: '#FFFFFF',
sbColorOnSecondary: '#C8193C',
sbColorSurface: '#FFFFFF',
sbColorOutline: '#EFEFEF',
sbColorOnSurfaceVariant: '#707070',
sbColorOnSurface: '#000000',
sbColorSurfaceLow: '#00000026',
sbColorSurfaceHigh: '#0000007A',
sbColorModalOverlay: '#000000A3',
});
/**
Configuration of the all strings for barcode scanner.
*/
public localization: BarcodeTextLocalization = new BarcodeTextLocalization({});
/**
Color of the screen's background.
Default is "?sbColorSurfaceLow"
*/
public backgroundColor: string = '?sbColorSurfaceLow';
/**
Configuration of the top bar.
*/
public topBar: TopBarConfiguration = new TopBarConfiguration({
title: new StyledText({ text: '?topBarTitle', color: '?sbColorOnPrimary' }),
mode: 'SOLID',
statusBarMode: 'LIGHT',
backgroundColor: '?sbColorPrimary',
cancelButton: new ButtonConfiguration({
visible: true,
text: '?topBarCancelButton',
background: new BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 0.0,
}),
foreground: new ForegroundStyle({
iconVisible: true,
color: '?sbColorOnPrimary',
useShadow: false,
}),
}),
});
/**
Configuration of the action bar.
*/
public actionBar: ActionBarConfiguration = new ActionBarConfiguration({
flashButton: new RoundButton({
visible: true,
accessibilityDescription: '?accessibilityDescriptionFlashButton',
backgroundColor: '?sbColorSurfaceHigh',
foregroundColor: '?sbColorOnPrimary',
activeBackgroundColor: '?sbColorWarning',
activeForegroundColor: '#1C1B1F',
}),
zoomButton: new RoundButton({
visible: true,
accessibilityDescription: '?accessibilityDescriptionZoomButton',
backgroundColor: '?sbColorSurfaceHigh',
foregroundColor: '?sbColorOnPrimary',
activeBackgroundColor: '?sbColorSurfaceHigh',
activeForegroundColor: '?sbColorOnPrimary',
}),
flipCameraButton: new RoundButton({
visible: true,
accessibilityDescription: '?accessibilityDescriptionFlipCameraButton',
backgroundColor: '?sbColorSurfaceHigh',
foregroundColor: '?sbColorOnPrimary',
activeBackgroundColor: '?sbColorSurfaceHigh',
activeForegroundColor: '?sbColorOnPrimary',
}),
});
/**
Configuration of the view finder.
*/
public viewFinder: ViewFinderConfiguration = new ViewFinderConfiguration({
visible: true,
style: new FinderCorneredStyle({
strokeColor: '?sbColorSurface',
strokeWidth: 2.0,
cornerRadius: 10.0,
}),
overlayColor: '?sbColorSurfaceLow',
aspectRatio: new AspectRatio({ width: 1.0, height: 1.0 }),
});
/**
Configuration of the text hint guiding users to move the view finder over a barcode.
*/
public userGuidance: UserGuidanceConfiguration = new UserGuidanceConfiguration({
visible: true,
title: new StyledText({ text: '?userGuidance', color: '?sbColorOnPrimary' }),
background: new BackgroundStyle({
strokeColor: '#00000000',
fillColor: '?sbColorSurfaceLow',
strokeWidth: 0.0,
}),
});
/**
Configuration of the dialog for requesting camera permissions.
*/
public cameraPermission: CameraPermissionScreen = new CameraPermissionScreen({
statusBarMode: 'DARK',
background: '?sbColorSurface',
iconBackground: '?sbColorOutline',
icon: new IconStyle({ visible: true, color: '?sbColorOnSurface' }),
enableCameraButton: new ButtonConfiguration({
visible: true,
text: '?cameraPermissionEnableCameraButton',
background: new BackgroundStyle({
strokeColor: '?sbColorPrimary',
fillColor: '?sbColorPrimary',
strokeWidth: 0.0,
}),
foreground: new ForegroundStyle({
iconVisible: false,
color: '?sbColorOnPrimary',
useShadow: false,
}),
}),
closeButton: new ButtonConfiguration({
visible: true,
text: '?cameraPermissionCloseButton',
background: new BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 0.0,
}),
foreground: new ForegroundStyle({
iconVisible: false,
color: '?sbColorPrimary',
useShadow: false,
}),
}),
enableCameraTitle: new StyledText({
text: '?cameraPermissionEnableCameraTitle',
color: '?sbColorOnSurface',
}),
enableCameraExplanation: new StyledText({
text: '?cameraPermissionEnableCameraExplanation',
color: '?sbColorOnSurfaceVariant',
}),
});
/**
Configuration of the camera behavior.
*/
public cameraConfiguration: CameraConfiguration = new CameraConfiguration({});
/**
Configuration of the scanning behavior.
*/
public recognizerConfiguration: BarcodeRecognizerConfiguration =
new BarcodeRecognizerConfiguration({});
/**
Configuration of the barcode scanner screen's behavior.
*/
public useCase: BarcodeUseCase = new SingleScanningMode({});
/**
Configuration of the scan confirmation sound.
*/
public sound: Sound = new Sound({ successBeepEnabled: true, soundType: 'MODERN_BEEP' });
/**
Configuration of the scan scan confirmation vibration.
*/
public vibration: Vibration = new Vibration({ enabled: true });
/**
Configuration of timeouts.
*/
public timeouts: Timeouts = new Timeouts({ autoCancelTimeout: 0, initialScanDelay: 0 });
/** @param source {@displayType `DeepPartial<BarcodeScannerConfiguration>`} */
public constructor(source: DeepPartial<BarcodeScannerConfiguration> = {}) {
super();
if (source.version !== undefined) {
this.version = source.version;
}
if (source.screen !== undefined) {
this.screen = source.screen;
}
if (source.palette !== undefined) {
this.palette = new Palette(source.palette);
}
if (source.localization !== undefined) {
this.localization = new BarcodeTextLocalization(source.localization);
}
if (source.backgroundColor !== undefined) {
this.backgroundColor = source.backgroundColor;
}
if (source.topBar !== undefined) {
this.topBar = new TopBarConfiguration(source.topBar);
}
if (source.actionBar !== undefined) {
this.actionBar = new ActionBarConfiguration(source.actionBar);
}
if (source.viewFinder !== undefined) {
this.viewFinder = new ViewFinderConfiguration(source.viewFinder);
}
if (source.userGuidance !== undefined) {
this.userGuidance = new UserGuidanceConfiguration(source.userGuidance);
}
if (source.cameraPermission !== undefined) {
this.cameraPermission = new CameraPermissionScreen(source.cameraPermission);
}
if (source.cameraConfiguration !== undefined) {
this.cameraConfiguration = new CameraConfiguration(source.cameraConfiguration);
}
if (source.recognizerConfiguration !== undefined) {
this.recognizerConfiguration = new BarcodeRecognizerConfiguration(
source.recognizerConfiguration
);
}
if (source.useCase !== undefined) {
this.useCase = BarcodeUseCase.From(source.useCase);
}
if (source.sound !== undefined) {
this.sound = new Sound(source.sound);
}
if (source.vibration !== undefined) {
this.vibration = new Vibration(source.vibration);
}
if (source.timeouts !== undefined) {
this.timeouts = new Timeouts(source.timeouts);
}
}
}