react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
390 lines (376 loc) • 12 kB
JavaScript
import { BackgroundStyle } from '../common/Common';
import { PartiallyConstructible } from '../../utils';
import { BadgeStyle } from '../common/Common';
import { PolygonStyle } from '../common/Common';
import { StyledText } from '../common/Common';
/**
Configuration of the overlay polygon displayed on top of a barcode in the camera preview.
*/
export class ArOverlayPolygonConfiguration extends PartiallyConstructible {
/**
Control the visibility of the overlay polygon.
Default is true
*/
visible = true;
/**
Appearance of the overlay polygon when a barcode is not selected.
*/
deselected = new PolygonStyle({
strokeColor: '?sbColorSurface',
fillColor: '#00000000',
strokeWidth: 2.0,
cornerRadius: 2.0
});
/**
Appearance of the overlay polygon after a barcode has been selected.
*/
selected = new PolygonStyle({
strokeColor: '?sbColorPositive',
fillColor: '#00000000',
strokeWidth: 2.0,
cornerRadius: 2.0
});
/** @param source {@displayType `DeepPartial<ArOverlayPolygonConfiguration>`} */
constructor(source = {}) {
super();
if (source.visible !== undefined) {
this.visible = source.visible;
}
if (source.deselected !== undefined) {
this.deselected = new PolygonStyle(source.deselected);
}
if (source.selected !== undefined) {
this.selected = new PolygonStyle(source.selected);
}
}
}
/**
Where to display the barcode info box in the camera preview.
- `DISABLED`:
Don't display any barcode info.
- `STACKED`:
Display the barcode info box in the center of the overlay polygon.
- `BELOW`:
Display the barcode info box below the overlay polygon.
- `ABOVE`:
Display the barcode info box above the overlay polygon.
*/
/**
Configuration of the barcode info box displayed in the camera preview.
*/
export class BarcodeItemConfiguration extends PartiallyConstructible {
/**
Control the visibility of the barcode image in the info box.
Default is true
*/
imageVisible = true;
/**
Configuration of the text displaying a barcode's value in the info box when the barcode has been selected.
*/
titleSelected = new StyledText({
text: 'BARCODE_TITLE',
color: '?sbColorOnSurface'
});
/**
Configuration of the text displaying a barcode's symbology in the info box when the barcode has been selected.
*/
subtitleSelected = new StyledText({
text: 'BARCODE_SUBTITLE',
color: '?sbColorOnSurfaceVariant'
});
/**
Configuration of the text displaying a barcode's value in the info box when the barcode is yet to be selected.
*/
titleDeselected = new StyledText({
text: 'BARCODE_TITLE',
color: '?sbColorOnSurface'
});
/**
Configuration of the text displaying a barcode's symbology in the info box when the barcode is yet to be selected.
*/
subtitleDeselected = new StyledText({
text: 'BARCODE_SUBTITLE',
color: '?sbColorOnSurfaceVariant'
});
/**
Appearance of the barcode info box's background when a barcode has been selected.
*/
backgroundSelected = new PolygonStyle({
strokeColor: '?sbColorPositive',
fillColor: '?sbColorPositive',
strokeWidth: 0.0,
cornerRadius: 10.0
});
/**
Appearance of the barcode info box's background when a barcode is yet to be selected.
*/
backgroundDeselected = new PolygonStyle({
strokeColor: '?sbColorSurface',
fillColor: '?sbColorSurface',
strokeWidth: 0.0,
cornerRadius: 10.0
});
/** @param source {@displayType `DeepPartial<BarcodeItemConfiguration>`} */
constructor(source = {}) {
super();
if (source.imageVisible !== undefined) {
this.imageVisible = source.imageVisible;
}
if (source.titleSelected !== undefined) {
this.titleSelected = new StyledText(source.titleSelected);
}
if (source.subtitleSelected !== undefined) {
this.subtitleSelected = new StyledText(source.subtitleSelected);
}
if (source.titleDeselected !== undefined) {
this.titleDeselected = new StyledText(source.titleDeselected);
}
if (source.subtitleDeselected !== undefined) {
this.subtitleDeselected = new StyledText(source.subtitleDeselected);
}
if (source.backgroundSelected !== undefined) {
this.backgroundSelected = new PolygonStyle(source.backgroundSelected);
}
if (source.backgroundDeselected !== undefined) {
this.backgroundDeselected = new PolygonStyle(source.backgroundDeselected);
}
}
}
/**
Configuration of the AR overlay displayed on top of barcodes in the camera preview.
*/
export class ArOverlayGeneralConfiguration extends PartiallyConstructible {
/**
Control the visibility of the user guidance.
Default is false
*/
visible = false;
/**
Parameters of the counter badge appearance e.g. color of background its stroke and text/icon color.
*/
counterBadge = new BadgeStyle({
background: new BackgroundStyle({}),
foregroundColor: '?sbColorOnSurface'
});
/**
If enabled, the scanner will always immediately scan a barcode in the viewfinder or the camera view. The overlay will mark the scanned barcodes and stays above them.
Default is false
*/
automaticSelectionEnabled = false;
/**
Where to display the barcode info box in the camera preview.
Default is BELOW
*/
barcodeItemInfoPosition = 'BELOW';
/**
Configuration of the overlay polygon displayed on top of a barcode in the camera preview.
*/
polygon = new ArOverlayPolygonConfiguration({
visible: true,
deselected: new PolygonStyle({}),
selected: new PolygonStyle({})
});
/**
Configuration of the barcode info box displayed in the camera preview.
*/
barcodeItemConfiguration = new BarcodeItemConfiguration({
imageVisible: true,
titleSelected: new StyledText({
text: 'BARCODE_TITLE',
color: '?sbColorOnSurface'
}),
subtitleSelected: new StyledText({
text: 'BARCODE_SUBTITLE',
color: '?sbColorOnSurfaceVariant'
}),
titleDeselected: new StyledText({
text: 'BARCODE_TITLE',
color: '?sbColorOnSurface'
}),
subtitleDeselected: new StyledText({
text: 'BARCODE_SUBTITLE',
color: '?sbColorOnSurfaceVariant'
}),
backgroundSelected: new PolygonStyle({
strokeColor: '?sbColorPositive',
fillColor: '?sbColorPositive',
strokeWidth: 1.0,
cornerRadius: 5.0
}),
backgroundDeselected: new PolygonStyle({
strokeColor: '?sbColorSurface',
fillColor: '?sbColorSurface',
strokeWidth: 1.0,
cornerRadius: 5.0
})
});
/** @param source {@displayType `DeepPartial<ArOverlayGeneralConfiguration>`} */
constructor(source = {}) {
super();
if (source.visible !== undefined) {
this.visible = source.visible;
}
if (source.counterBadge !== undefined) {
this.counterBadge = new BadgeStyle(source.counterBadge);
}
if (source.automaticSelectionEnabled !== undefined) {
this.automaticSelectionEnabled = source.automaticSelectionEnabled;
}
if (source.barcodeItemInfoPosition !== undefined) {
this.barcodeItemInfoPosition = source.barcodeItemInfoPosition;
}
if (source.polygon !== undefined) {
this.polygon = new ArOverlayPolygonConfiguration(source.polygon);
}
if (source.barcodeItemConfiguration !== undefined) {
this.barcodeItemConfiguration = new BarcodeItemConfiguration(source.barcodeItemConfiguration);
}
}
}
/**
Configuration of the overlay polygon displayed on top of a barcode in the camera preview.
*/
export class FindAndPickArOverlayPolygonConfiguration extends PartiallyConstructible {
/**
Control the visibility of the overlay polygon.
Default is true
*/
visible = true;
/**
Appearance of the overlay polygon when a barcode is partially scanned.
*/
partiallyScanned = new PolygonStyle({
strokeColor: '?sbColorWarning',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
});
/**
Appearance of the overlay polygon when a barcode is rejected.
*/
rejected = new PolygonStyle({
strokeColor: '?sbColorSurface',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
});
/**
Appearance of the overlay polygon when a barcode is completed.
*/
completed = new PolygonStyle({
strokeColor: '?sbColorPositive',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
});
/** @param source {@displayType `DeepPartial<FindAndPickArOverlayPolygonConfiguration>`} */
constructor(source = {}) {
super();
if (source.visible !== undefined) {
this.visible = source.visible;
}
if (source.partiallyScanned !== undefined) {
this.partiallyScanned = new PolygonStyle(source.partiallyScanned);
}
if (source.rejected !== undefined) {
this.rejected = new PolygonStyle(source.rejected);
}
if (source.completed !== undefined) {
this.completed = new PolygonStyle(source.completed);
}
}
}
/**
Configuration of the round badge on find and pick ar layer.
*/
export class FindAndPickBadgeConfiguration extends PartiallyConstructible {
/**
Appearance of the badge when a barcode is partially scanned.
*/
partiallyScanned = new BadgeStyle({
visible: true,
background: new BackgroundStyle({
strokeColor: '#FFFFFF30',
fillColor: '?sbColorWarning',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
});
/**
Appearance of the badge when a barcode is rejected.
*/
rejected = new BadgeStyle({
visible: true,
background: new BackgroundStyle({
strokeColor: '#FFFFFF30',
fillColor: '?sbColorNegative',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
});
/**
Appearance of the badge when a barcode is completed.
*/
completed = new BadgeStyle({
visible: true,
background: new BackgroundStyle({
strokeColor: '#FFFFFF30',
fillColor: '?sbColorPositive',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
});
/** @param source {@displayType `DeepPartial<FindAndPickBadgeConfiguration>`} */
constructor(source = {}) {
super();
if (source.partiallyScanned !== undefined) {
this.partiallyScanned = new BadgeStyle(source.partiallyScanned);
}
if (source.rejected !== undefined) {
this.rejected = new BadgeStyle(source.rejected);
}
if (source.completed !== undefined) {
this.completed = new BadgeStyle(source.completed);
}
}
}
/**
Configuration of the AR overlay.
*/
export class ArOverlayFindAndPickConfiguration extends PartiallyConstructible {
/**
Control the visibility of the user guidance.
Default is false
*/
visible = false;
/**
If enabled, the scanner will always immediately scan a barcode in the viewfinder or the camera view. The overlay will mark the scanned barcodes and stays above them.
Default is true
*/
automaticSelectionEnabled = true;
/**
Configuration of the overlay polygon displayed on top of a barcode in the camera preview.
*/
polygon = new FindAndPickArOverlayPolygonConfiguration({});
/**
Configuration of the round badge on find and pick ar layer.
*/
badge = new FindAndPickBadgeConfiguration({});
/** @param source {@displayType `DeepPartial<ArOverlayFindAndPickConfiguration>`} */
constructor(source = {}) {
super();
if (source.visible !== undefined) {
this.visible = source.visible;
}
if (source.automaticSelectionEnabled !== undefined) {
this.automaticSelectionEnabled = source.automaticSelectionEnabled;
}
if (source.polygon !== undefined) {
this.polygon = new FindAndPickArOverlayPolygonConfiguration(source.polygon);
}
if (source.badge !== undefined) {
this.badge = new FindAndPickBadgeConfiguration(source.badge);
}
}
}
//# sourceMappingURL=ArTrackingOverlayConfiguration.js.map