react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
449 lines (442 loc) • 14.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FindAndPickScanningMode = exports.ExpectedBarcode = void 0;
var _ArTrackingOverlayConfiguration = require("../barcode/ArTrackingOverlayConfiguration");
var _Common = require("../common/Common");
var _utils = require("../../utils");
var _MultipleScanningModeUseCase = require("../barcode/MultipleScanningModeUseCase");
var _ScanbotAlertDialog = require("../common/ScanbotAlertDialog");
/**
Configuration of the barcode to find and scan.
*/
class ExpectedBarcode extends _utils.PartiallyConstructible {
/**
Value of the barcode to find. If not set, any barcode value will be accepted.
*/
/**
Title of the barcode to find.
*/
/**
Image of the barcode to find.
*/
/**
Number of barcodes with given symbology/value required to scan.
Default is 1
*/
count = 1;
/**
Use this key to display the original barcode image
*/
static barcodeImageKey = 'BARCODE_IMAGE';
/** @param source {@displayType `DeepPartial<ExpectedBarcode>`} */
constructor(source = {}) {
super();
if (source.barcodeValue !== undefined) {
this.barcodeValue = source.barcodeValue;
} else {
throw new Error('barcodeValue must be present in constructor argument');
}
if (source.title !== undefined) {
this.title = source.title != null ? source.title : null;
} else {
throw new Error('title must be present in constructor argument');
}
if (source.image !== undefined) {
this.image = source.image != null ? source.image : null;
} else {
throw new Error('image must be present in constructor argument');
}
if (source.count !== undefined) {
this.count = source.count;
}
}
}
/**
Configuration of the Find and Pick barcode scanning mode.
*/
exports.ExpectedBarcode = ExpectedBarcode;
class FindAndPickScanningMode extends _utils.PartiallyConstructible {
_type = 'FindAndPickScanningMode';
/**
Color of the selected barcode.
Default is "?sbColorPositive"
*/
scanningCompletedColor = '?sbColorPositive';
/**
Color of the partially scanned barcode.
Default is "?sbColorWarning"
*/
scanningPartiallyColor = '?sbColorWarning';
/**
Color of the not scanned barcode .
Default is "?sbColorOutline"
*/
scanningNotScannedColor = '?sbColorOutline';
/**
If the user is allowed to finish the scanning process without scanning all the expected barcodes.
Default is false
*/
allowPartialScan = false;
/**
List of barcodes that the user has to find and scan.
*/
expectedBarcodes = [];
/**
Time interval in milliseconds before a barcode is counted again. 0 = no delay. The default value is 1000.
Default is 1000
*/
countingRepeatDelay = 1000;
/**
Configuration of the preview mode for the barcodes required to be found and scanned.
*/
sheet = new _MultipleScanningModeUseCase.Sheet({
mode: 'COLLAPSED_SHEET',
collapsedVisibleHeight: 'SMALL',
listButton: new _Common.BadgedButton({
badgeBackgroundColor: '?sbColorSurface',
badgeForegroundColor: '?sbColorPrimary',
visible: true,
backgroundColor: '?sbColorSurfaceHigh',
foregroundColor: '?sbColorOnPrimary',
activeBackgroundColor: '?sbColorSurfaceHigh',
activeForegroundColor: '?sbColorOnPrimary'
})
});
/**
Configuration of the list of barcodes required to be found and scanned.
*/
sheetContent = new _MultipleScanningModeUseCase.SheetContent({
sheetColor: '?sbColorSurface',
dividerColor: '?sbColorOutline',
manualCountChangeEnabled: true,
manualCountOutlineColor: '?sbColorOutline',
manualCountChangeColor: '?sbColorPrimary',
title: new _Common.StyledText({
visible: true,
text: '?findAndPickSheetTitle',
color: '?sbColorOnSurface',
useShadow: false
}),
clearAllButton: new _Common.ButtonConfiguration({
visible: true,
text: '?sheetResetButton',
background: new _Common.BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorOnSurface',
useShadow: false
})
}),
barcodeItemTitle: new _Common.StyledText({
text: 'BARCODE_TITLE',
color: '?sbColorOnSurface'
}),
barcodeItemSubtitle: new _Common.StyledText({
text: '?findAndPickSheetBarcodeItemSubtitle',
color: '?sbColorOnSurfaceVariant'
}),
barcodeItemImageVisible: true,
submitButton: new _Common.ButtonConfiguration({
visible: true,
text: '?sheetSubmitButton',
background: new _Common.BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorOnSurface',
useShadow: false
})
}),
startScanningButton: new _Common.ButtonConfiguration({
visible: true,
text: '?sheetStartScanningButton',
background: new _Common.BackgroundStyle({
strokeColor: '?sbColorPrimary',
fillColor: '?sbColorPrimary',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorOnPrimary',
useShadow: false
})
}),
placeholderTitle: new _Common.StyledText({
text: '?sheetPlaceholderTitle',
color: '?sbColorOnSurface'
}),
placeholderSubtitle: new _Common.StyledText({
text: '?sheetPlaceholderSubtitle',
color: '?sbColorOnSurfaceVariant'
}),
placeholderIconBackground: '?sbColorOutline',
placeholderIcon: new _Common.IconStyle({
visible: true,
color: '?sbColorOnSurface'
}),
swipeToDelete: new _MultipleScanningModeUseCase.SwipeToDelete({
enabled: false,
backgroundColor: '?sbColorNegative',
iconColor: '?sbColorOnPrimary'
})
});
/**
Configuration of the dialog to manually edit the barcode count.
*/
manualCountEditDialog = new _MultipleScanningModeUseCase.ManualCountEditDialog({
sheetColor: '?sbColorSurface',
dividerColor: '?sbColorOutline',
modalOverlayColor: '?sbColorModalOverlay',
title: new _Common.StyledText({
text: '?manualCountEditDialogTitle',
color: '?sbColorOnSurface'
}),
info: new _Common.StyledText({
text: '?manualCountEditDialogInfo',
color: '?sbColorOnSurfaceVariant'
}),
updateButton: new _Common.ButtonConfiguration({
visible: true,
text: '?manualCountEditDialogUpdateButton',
background: new _Common.BackgroundStyle({
strokeColor: '?sbColorPrimary',
fillColor: '?sbColorPrimary',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorOnPrimary',
useShadow: false
})
}),
cancelButton: new _Common.ButtonConfiguration({
visible: true,
text: '?manualCountEditDialogCancelButton',
background: new _Common.BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorPrimary',
useShadow: false
})
}),
clearTextButton: new _Common.IconStyle({
visible: true,
color: '?sbColorOnSurfaceVariant'
})
});
/**
Configuration of the AR overlay.
*/
arOverlay = new _ArTrackingOverlayConfiguration.ArOverlayFindAndPickConfiguration({
visible: true,
automaticSelectionEnabled: true,
polygon: new _ArTrackingOverlayConfiguration.FindAndPickArOverlayPolygonConfiguration({
partiallyScanned: new _Common.PolygonStyle({
strokeColor: '?sbColorWarning',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
}),
rejected: new _Common.PolygonStyle({
strokeColor: '?sbColorSurface',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
}),
completed: new _Common.PolygonStyle({
strokeColor: '?sbColorPositive',
fillColor: '#00000000',
strokeWidth: 3.0,
cornerRadius: 5.0
})
}),
badge: new _ArTrackingOverlayConfiguration.FindAndPickBadgeConfiguration({
partiallyScanned: new _Common.BadgeStyle({
visible: true,
background: new _Common.BackgroundStyle({
strokeColor: '#000000FF',
fillColor: '?sbColorWarning',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
}),
rejected: new _Common.BadgeStyle({
visible: true,
background: new _Common.BackgroundStyle({
strokeColor: '#000000FF',
fillColor: '?sbColorSurface',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
}),
completed: new _Common.BadgeStyle({
visible: true,
background: new _Common.BackgroundStyle({
strokeColor: '#000000FF',
fillColor: '?sbColorPositive',
strokeWidth: 0.0
}),
foregroundColor: '?sbColorOnSurface'
})
})
});
/**
If the partial scanned alert dialog is enabled.
Default is true
*/
partialScannedAlertDialogEnabled = true;
/**
Configuration of the partial scanned alert dialog.
*/
partialScannedAlertDialog = new _ScanbotAlertDialog.ScanbotAlertDialog({
title: new _Common.StyledText({
text: '?findAndPickPartialAlertTitle',
color: '?sbColorOnSurface'
}),
subtitle: new _Common.StyledText({
text: '?findAndPickPartialAlertSubtitle',
color: '?sbColorOnSurfaceVariant'
}),
sheetColor: '?sbColorSurface',
modalOverlayColor: '?sbColorModalOverlay',
dividerColor: '?sbColorOutline',
okButton: new _Common.ButtonConfiguration({
visible: true,
text: '?findAndPickPartialAlertSubmitButton',
background: new _Common.BackgroundStyle({
strokeColor: '?sbColorPrimary',
fillColor: '?sbColorPrimary',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: true,
color: '?sbColorOnPrimary',
useShadow: false
})
}),
cancelButton: new _Common.ButtonConfiguration({
visible: true,
text: '?findAndPickPartialAlertCancelButton',
background: new _Common.BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorPrimary',
useShadow: false
})
})
});
/**
If the confirmation alert dialog is enabled.
Default is false
*/
confirmationAlertDialogEnabled = false;
/**
Configuration of the confirmation alert dialog.
*/
confirmationAlertDialog = new _ScanbotAlertDialog.ScanbotAlertDialog({
title: new _Common.StyledText({
text: '?findAndPickCompleteAlertTitle',
color: '?sbColorOnSurface'
}),
subtitle: new _Common.StyledText({
text: '?findAndPickCompleteAlertSubtitle',
color: '?sbColorOnSurfaceVariant'
}),
sheetColor: '?sbColorSurface',
modalOverlayColor: '?sbColorModalOverlay',
dividerColor: '?sbColorOutline',
okButton: new _Common.ButtonConfiguration({
visible: true,
text: '?findAndPickCompleteAlertSubmitButton',
background: new _Common.BackgroundStyle({
strokeColor: '?sbColorPrimary',
fillColor: '?sbColorPrimary',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: true,
color: '?sbColorOnPrimary',
useShadow: false
})
}),
cancelButton: new _Common.ButtonConfiguration({
visible: true,
text: '?findAndPickCompleteAlertCancelButton',
background: new _Common.BackgroundStyle({
strokeColor: '#00000000',
fillColor: '#00000000',
strokeWidth: 1.0
}),
foreground: new _Common.ForegroundStyle({
iconVisible: false,
color: '?sbColorPrimary',
useShadow: false
})
})
});
/** @param source {@displayType `DeepPartial<FindAndPickScanningMode>`} */
constructor(source = {}) {
super();
if (source.scanningCompletedColor !== undefined) {
this.scanningCompletedColor = source.scanningCompletedColor;
}
if (source.scanningPartiallyColor !== undefined) {
this.scanningPartiallyColor = source.scanningPartiallyColor;
}
if (source.scanningNotScannedColor !== undefined) {
this.scanningNotScannedColor = source.scanningNotScannedColor;
}
if (source.allowPartialScan !== undefined) {
this.allowPartialScan = source.allowPartialScan;
}
if (source.expectedBarcodes !== undefined) {
this.expectedBarcodes = source.expectedBarcodes.map(it => new ExpectedBarcode(it));
}
if (source.countingRepeatDelay !== undefined) {
this.countingRepeatDelay = source.countingRepeatDelay;
}
if (source.sheet !== undefined) {
this.sheet = new _MultipleScanningModeUseCase.Sheet(source.sheet);
}
if (source.sheetContent !== undefined) {
this.sheetContent = new _MultipleScanningModeUseCase.SheetContent(source.sheetContent);
}
if (source.manualCountEditDialog !== undefined) {
this.manualCountEditDialog = new _MultipleScanningModeUseCase.ManualCountEditDialog(source.manualCountEditDialog);
}
if (source.arOverlay !== undefined) {
this.arOverlay = new _ArTrackingOverlayConfiguration.ArOverlayFindAndPickConfiguration(source.arOverlay);
}
if (source.partialScannedAlertDialogEnabled !== undefined) {
this.partialScannedAlertDialogEnabled = source.partialScannedAlertDialogEnabled;
}
if (source.partialScannedAlertDialog !== undefined) {
this.partialScannedAlertDialog = new _ScanbotAlertDialog.ScanbotAlertDialog(source.partialScannedAlertDialog);
}
if (source.confirmationAlertDialogEnabled !== undefined) {
this.confirmationAlertDialogEnabled = source.confirmationAlertDialogEnabled;
}
if (source.confirmationAlertDialog !== undefined) {
this.confirmationAlertDialog = new _ScanbotAlertDialog.ScanbotAlertDialog(source.confirmationAlertDialog);
}
}
}
exports.FindAndPickScanningMode = FindAndPickScanningMode;
//# sourceMappingURL=FindAndPickScanningModeUseCase.js.map