react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
289 lines (287 loc) • 9.37 kB
JavaScript
import { ActionBarConfiguration } from '../common/ActionBarConfiguration';
import { AspectRatio } from '../common/Common';
import { BackgroundStyle } from '../common/Common';
import { BarcodeRecognizerConfiguration } from '../barcode/BarcodeRecognizerConfiguration';
import { BarcodeTextLocalization } from '../barcode/BarcodeTextLocalization';
import { BarcodeUseCase } from '../barcode/BarcodeUseCase';
import { ButtonConfiguration } from '../common/Common';
import { CameraConfiguration } from '../common/CameraConfiguration';
import { CameraPermissionScreen } from '../common/CameraPermission';
import { PartiallyConstructible } from '../../utils';
import { FinderCorneredStyle } from '../common/ViewFinderConfiguration';
import { ForegroundStyle } from '../common/Common';
import { IconStyle } from '../common/Common';
import { Palette } from '../common/Common';
import { RoundButton } from '../common/Common';
import { SingleScanningMode } from '../barcode/SingleScanningModeUseCase';
import { Sound } from '../common/Common';
import { StyledText } from '../common/Common';
import { Timeouts } from '../common/Common';
import { TopBarConfiguration } 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"
*/
version = '1.0';
/**
The configuration object should be applied for this screen.
Default is "BarcodeScanner"
*/
screen = 'BarcodeScanner';
/**
Define the screen's base color values from which other colors are derived.
*/
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.
*/
localization = new BarcodeTextLocalization({});
/**
Color of the screen's background.
Default is "?sbColorSurfaceLow"
*/
backgroundColor = '?sbColorSurfaceLow';
/**
Configuration of the top bar.
*/
topBar = 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.
*/
actionBar = 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.
*/
viewFinder = 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.
*/
userGuidance = 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.
*/
cameraPermission = 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.
*/
cameraConfiguration = new CameraConfiguration({});
/**
Configuration of the scanning behavior.
*/
recognizerConfiguration = new BarcodeRecognizerConfiguration({});
/**
Configuration of the barcode scanner screen's behavior.
*/
useCase = new SingleScanningMode({});
/**
Configuration of the scan confirmation sound.
*/
sound = new Sound({
successBeepEnabled: true,
soundType: 'MODERN_BEEP'
});
/**
Configuration of the scan scan confirmation vibration.
*/
vibration = new Vibration({
enabled: true
});
/**
Configuration of timeouts.
*/
timeouts = new Timeouts({
autoCancelTimeout: 0,
initialScanDelay: 0
});
/** @param source {@displayType `DeepPartial<BarcodeScannerConfiguration>`} */
constructor(source = {}) {
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);
}
}
}
//# sourceMappingURL=BarcodeScannerConfiguration.js.map