UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

739 lines (723 loc) 22.5 kB
import { ArOverlayGeneralConfiguration } from '../barcode/ArTrackingOverlayConfiguration'; import { ArOverlayPolygonConfiguration } from '../barcode/ArTrackingOverlayConfiguration'; import { BackgroundStyle } from '../common/Common'; import { BadgeStyle } from '../common/Common'; import { BadgedButton } from '../common/Common'; import { BarcodeInfoMapping } from '../barcode/BarcodeInfoMapping'; import { BarcodeItemConfiguration } from '../barcode/ArTrackingOverlayConfiguration'; import { BarcodeItemErrorState } from '../barcode/BarcodeInfoMapping'; import { ButtonConfiguration } from '../common/Common'; import { PartiallyConstructible } from '../../utils'; import { ForegroundStyle } from '../common/Common'; import { IconStyle } from '../common/Common'; import { PolygonStyle } from '../common/Common'; import { StyledText } from '../common/Common'; /** Configuration of the mode used for scanning multiple barcodes. - `COUNTING`: Scan barcodes even if they have the same value and count the number of repeated barcodes. - `UNIQUE`: Only scan barcodes with unique values. Subsequent barcodes with the same values will be ignored. */ /** Configuration of the barcode result sheet's default visibility state. - `BUTTON`: Result sheet is hidden and can be opened by pressing the button. The button can show the total barcode count. - `COLLAPSED_SHEET`: Result sheet is visible and collapsed and can be expanded by dragging it up. */ /** Configuration of the barcodes result sheet's height while collapsed. - `SMALL`: Result sheet is collapsed as much as possible, showing only the top part. - `LARGE`: Result sheet is not completely collapsed, revealing more information. */ /** Configuration of the preview mode for scanning multiple barcodes. */ export class Sheet extends PartiallyConstructible { /** Mode used for the preview for scanning multiple barcodes. Default is COLLAPSED_SHEET */ mode = 'COLLAPSED_SHEET'; /** Height of the collapsed result sheet. Default is SMALL */ collapsedVisibleHeight = 'SMALL'; /** Configuration of the list button. */ listButton = new BadgedButton({}); /** @param source {@displayType `DeepPartial<Sheet>`} */ constructor(source = {}) { super(); if (source.mode !== undefined) { this.mode = source.mode; } if (source.collapsedVisibleHeight !== undefined) { this.collapsedVisibleHeight = source.collapsedVisibleHeight; } if (source.listButton !== undefined) { this.listButton = new BadgedButton(source.listButton); } } } /** Configuration of the swipe-to-delete button. */ export class SwipeToDelete extends PartiallyConstructible { /** Whether swipe to delete is enabled or not. Default is true */ enabled = true; /** Color of the swipe-to-delete button. Default is "?sbColorNegative" */ backgroundColor = '?sbColorNegative'; /** Color of the icon on the swipe-to-delete button. Default is "?sbColorOnPrimary" */ iconColor = '?sbColorOnPrimary'; /** @param source {@displayType `DeepPartial<SwipeToDelete>`} */ constructor(source = {}) { super(); if (source.enabled !== undefined) { this.enabled = source.enabled; } if (source.backgroundColor !== undefined) { this.backgroundColor = source.backgroundColor; } if (source.iconColor !== undefined) { this.iconColor = source.iconColor; } } } /** Configuration of the dialog to manually edit the barcode count. */ export class ManualCountEditDialog extends PartiallyConstructible { /** Color of the edit dialog's background. Default is "?sbColorSurface" */ sheetColor = '?sbColorSurface'; /** Color of the divider and separator lines in the edit dialog. Default is "?sbColorOutline" */ dividerColor = '?sbColorOutline'; /** Background color of the overlay surrounding the edit dialog. Default is "?sbColorModalOverlay" */ modalOverlayColor = '?sbColorModalOverlay'; /** Configuration of the edit dialog's title. */ title = new StyledText({ text: 'Update count', color: '?sbColorOnSurface' }); /** Configuration of the edit dialog's info text. */ info = new StyledText({ text: 'Adjust the number of items you scanned.', color: '?sbColorOnSurfaceVariant' }); /** Configuration of the edit dialog's confirm button. Hiding both the update and cancel buttons simultaneously is an undefined behavior. */ updateButton = new ButtonConfiguration({ visible: true, text: 'Update', background: new BackgroundStyle({ strokeColor: '?sbColorPrimary', fillColor: '?sbColorPrimary', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnPrimary', useShadow: false }) }); /** Configuration of the edit dialog's cancel button. Hiding both the update and cancel buttons simultaneously is an undefined behavior. */ cancelButton = new ButtonConfiguration({ visible: true, text: 'Cancel', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorPrimary', useShadow: false }) }); /** Configuration of the edit dialog's button to clear the entered count number. */ clearTextButton = new IconStyle({ visible: true, color: '?sbColorOnSurfaceVariant' }); /** @param source {@displayType `DeepPartial<ManualCountEditDialog>`} */ constructor(source = {}) { super(); if (source.sheetColor !== undefined) { this.sheetColor = source.sheetColor; } if (source.dividerColor !== undefined) { this.dividerColor = source.dividerColor; } if (source.modalOverlayColor !== undefined) { this.modalOverlayColor = source.modalOverlayColor; } if (source.title !== undefined) { this.title = new StyledText(source.title); } if (source.info !== undefined) { this.info = new StyledText(source.info); } if (source.updateButton !== undefined) { this.updateButton = new ButtonConfiguration(source.updateButton); } if (source.cancelButton !== undefined) { this.cancelButton = new ButtonConfiguration(source.cancelButton); } if (source.clearTextButton !== undefined) { this.clearTextButton = new IconStyle(source.clearTextButton); } } } /** Configuration of the list containing the barcodes that have already been scanned. */ export class SheetContent extends PartiallyConstructible { /** Color of the list's background. Default is "?sbColorSurface" */ sheetColor = '?sbColorSurface'; /** The color of the dividers in the list sheet. Default is "?sbColorOutline" */ dividerColor = '?sbColorOutline'; /** Enables the user to change the number of scanned items by pressing +,-, or changing the number using a keyboard. Default is true */ manualCountChangeEnabled = true; /** The color of the outline of the manual counting buttons in the list sheet. Default is "?sbColorOutline" */ manualCountOutlineColor = '?sbColorOutline'; /** Color of the buttons for manually changing the barcode count. Default is "?sbColorPrimary" */ manualCountChangeColor = '?sbColorPrimary'; /** Configuration of the barcode list's title. By default displays the total number of scanned barcodes. */ title = new StyledText({ text: '%d items', color: '?sbColorOnSurface' }); /** Configuration of the button for clearing the barcode list. */ clearAllButton = new ButtonConfiguration({ visible: true, text: 'Clear all', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnSurface', useShadow: false }) }); /** Configuration of the title of a barcode list entry (displaying the barcode's value). */ barcodeItemTitle = new StyledText({ visible: true, text: 'BARCODE_TITLE', color: '?sbColorOnSurface', useShadow: false }); /** Configuration of the subtitle of a barcode list entry (displaying the barcode's symbology). */ barcodeItemSubtitle = new StyledText({ text: 'BARCODE_SUBTITLE', color: '?sbColorOnSurfaceVariant' }); /** Visibility of the barcode image in a barcode list entry. Default is true */ barcodeItemImageVisible = true; /** Configuration of the barcode list's submit button. */ submitButton = new ButtonConfiguration({ visible: true, text: 'Submit', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnSurface', useShadow: false }) }); /** Configuration of the button to start scanning displayed in an empty barcode list. */ startScanningButton = new ButtonConfiguration({ visible: true, text: 'Start scanning', background: new BackgroundStyle({ strokeColor: '?sbColorPrimary', fillColor: '?sbColorPrimary', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: true, color: '?sbColorOnPrimary', useShadow: false }) }); /** Configuration of the title displayed in an empty barcode list. */ placeholderTitle = new StyledText({ text: 'No barcodes here!', color: '?sbColorOnSurface' }); /** Configuration of the subtitle displayed in an empty barcode list. */ placeholderSubtitle = new StyledText({ text: 'The barcode list is currently empty. Close this sheet and scan your items to add them.', color: '?sbColorOnSurfaceVariant' }); /** Background color of the icon displayed in an empty barcode list. Default is "?sbColorOutline" */ placeholderIconBackground = '?sbColorOutline'; /** Configuration of the icon displayed in an empty barcode list. */ placeholderIcon = new IconStyle({ visible: true, color: '?sbColorOnSurface' }); /** The style of the swipe-to-delete button. */ swipeToDelete = new SwipeToDelete({ enabled: true, backgroundColor: '?sbColorNegative', iconColor: '?sbColorOnPrimary' }); /** @param source {@displayType `DeepPartial<SheetContent>`} */ constructor(source = {}) { super(); if (source.sheetColor !== undefined) { this.sheetColor = source.sheetColor; } if (source.dividerColor !== undefined) { this.dividerColor = source.dividerColor; } if (source.manualCountChangeEnabled !== undefined) { this.manualCountChangeEnabled = source.manualCountChangeEnabled; } if (source.manualCountOutlineColor !== undefined) { this.manualCountOutlineColor = source.manualCountOutlineColor; } if (source.manualCountChangeColor !== undefined) { this.manualCountChangeColor = source.manualCountChangeColor; } if (source.title !== undefined) { this.title = new StyledText(source.title); } if (source.clearAllButton !== undefined) { this.clearAllButton = new ButtonConfiguration(source.clearAllButton); } if (source.barcodeItemTitle !== undefined) { this.barcodeItemTitle = new StyledText(source.barcodeItemTitle); } if (source.barcodeItemSubtitle !== undefined) { this.barcodeItemSubtitle = new StyledText(source.barcodeItemSubtitle); } if (source.barcodeItemImageVisible !== undefined) { this.barcodeItemImageVisible = source.barcodeItemImageVisible; } if (source.submitButton !== undefined) { this.submitButton = new ButtonConfiguration(source.submitButton); } if (source.startScanningButton !== undefined) { this.startScanningButton = new ButtonConfiguration(source.startScanningButton); } if (source.placeholderTitle !== undefined) { this.placeholderTitle = new StyledText(source.placeholderTitle); } if (source.placeholderSubtitle !== undefined) { this.placeholderSubtitle = new StyledText(source.placeholderSubtitle); } if (source.placeholderIconBackground !== undefined) { this.placeholderIconBackground = source.placeholderIconBackground; } if (source.placeholderIcon !== undefined) { this.placeholderIcon = new IconStyle(source.placeholderIcon); } if (source.swipeToDelete !== undefined) { this.swipeToDelete = new SwipeToDelete(source.swipeToDelete); } } } /** Configuration of the mode for scanning multiple barcodes. */ export class MultipleScanningMode extends PartiallyConstructible { _type = 'MultipleScanningMode'; /** Time interval in milliseconds before a barcode is counted again. 0 = no delay. The default value is 1000. Default is 1000 */ countingRepeatDelay = 1000; /** Whether the user can submit an empty barcode list. Default is false */ allowEmptySubmission = false; /** Mode used for scanning multiple barcodes. Default is COUNTING */ mode = 'COUNTING'; /** Configuration of the preview mode for scanning multiple barcodes. */ sheet = new Sheet({ mode: 'COLLAPSED_SHEET', collapsedVisibleHeight: 'SMALL', listButton: new BadgedButton({ badgeBackgroundColor: '?sbColorSurface', badgeForegroundColor: '?sbColorPrimary', visible: true, backgroundColor: '?sbColorSurfaceHigh', foregroundColor: '?sbColorOnPrimary', activeBackgroundColor: '?sbColorSurfaceHigh', activeForegroundColor: '?sbColorOnPrimary' }) }); /** Configuration of the list containing the barcodes that have already been scanned. */ sheetContent = new SheetContent({ sheetColor: '?sbColorSurface', dividerColor: '?sbColorOutline', manualCountChangeEnabled: true, manualCountOutlineColor: '?sbColorOutline', manualCountChangeColor: '?sbColorPrimary', title: new StyledText({ text: '?multipleModeSheetTitle', color: '?sbColorOnSurface' }), clearAllButton: new ButtonConfiguration({ visible: true, text: '?sheetClearAllButton', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnSurface', useShadow: false }) }), barcodeItemTitle: new StyledText({ visible: true, text: 'BARCODE_TITLE', color: '?sbColorOnSurface', useShadow: false }), barcodeItemSubtitle: new StyledText({ visible: true, text: 'BARCODE_SUBTITLE', color: '?sbColorOnSurfaceVariant', useShadow: false }), barcodeItemImageVisible: true, submitButton: new ButtonConfiguration({ visible: true, text: '?sheetSubmitButton', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnSurface', useShadow: false }) }), startScanningButton: new ButtonConfiguration({ visible: true, text: '?sheetStartScanningButton', background: new BackgroundStyle({ strokeColor: '?sbColorPrimary', fillColor: '?sbColorPrimary', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnPrimary', useShadow: false }) }), placeholderTitle: new StyledText({ visible: true, text: '?sheetPlaceholderTitle', color: '?sbColorOnSurface', useShadow: false }), placeholderSubtitle: new StyledText({ visible: true, text: '?sheetPlaceholderSubtitle', color: '?sbColorOnSurfaceVariant', useShadow: false }), placeholderIconBackground: '?sbColorOutline', placeholderIcon: new IconStyle({ visible: true, color: '?sbColorOnSurface' }), swipeToDelete: new SwipeToDelete({ enabled: true, backgroundColor: '?sbColorNegative', iconColor: '?sbColorOnPrimary' }) }); /** Configuration of the dialog to manually edit the barcode count. */ manualCountEditDialog = new ManualCountEditDialog({ sheetColor: '?sbColorSurface', dividerColor: '?sbColorOutline', modalOverlayColor: '?sbColorModalOverlay', title: new StyledText({ text: '?manualCountEditDialogTitle', color: '?sbColorOnSurface' }), info: new StyledText({ text: '?manualCountEditDialogInfo', color: '?sbColorOnSurfaceVariant' }), updateButton: new ButtonConfiguration({ visible: true, text: '?manualCountEditDialogUpdateButton', background: new BackgroundStyle({ strokeColor: '?sbColorPrimary', fillColor: '?sbColorPrimary', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorOnPrimary', useShadow: false }) }), cancelButton: new ButtonConfiguration({ visible: true, text: '?manualCountEditDialogCancelButton', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorPrimary', useShadow: false }) }), clearTextButton: new IconStyle({ visible: true, color: '?sbColorOnSurfaceVariant' }) }); /** Appearance of the barcode info mapping. */ barcodeInfoMapping = new BarcodeInfoMapping({ sheetColor: '?sbColorSurface', dividerColor: '?sbColorOutline', modalOverlayColor: '?sbColorModalOverlay', loadingMessage: new StyledText({ text: '?barcodeInfoMappingLoadingMessage', color: '?sbColorPrimary' }), errorState: new BarcodeItemErrorState({ title: new StyledText({ text: '?barcodeInfoMappingErrorStateTitle', color: '?sbColorOnSurface' }), subtitle: new StyledText({ text: '?barcodeInfoMappingErrorStateSubtitle', color: '?sbColorOnSurfaceVariant' }), retryButton: new ButtonConfiguration({ visible: true, text: '?barcodeInfoMappingErrorStateRetryButton', background: new BackgroundStyle({ strokeColor: '?sbColorPrimary', fillColor: '?sbColorPrimary', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: true, color: '?sbColorOnPrimary', useShadow: false }) }), cancelButton: new ButtonConfiguration({ visible: true, text: '?barcodeInfoMappingErrorStateCancelButton', background: new BackgroundStyle({ strokeColor: '#00000000', fillColor: '#00000000', strokeWidth: 1.0 }), foreground: new ForegroundStyle({ iconVisible: false, color: '?sbColorPrimary', useShadow: false }) }) }) }); /** Configuration of the AR overlay. */ arOverlay = new ArOverlayGeneralConfiguration({ visible: false, counterBadge: new BadgeStyle({ visible: true, background: new BackgroundStyle({ strokeColor: '#FF000000', fillColor: '?sbColorPositive', strokeWidth: 0.0 }), foregroundColor: '?sbColorOnSurface' }), automaticSelectionEnabled: false, barcodeItemInfoPosition: 'BELOW', polygon: new ArOverlayPolygonConfiguration({ visible: true, deselected: new PolygonStyle({ strokeColor: '?sbColorSurface', fillColor: '#00000000', strokeWidth: 3.0, cornerRadius: 5.0 }), selected: new PolygonStyle({ strokeColor: '?sbColorPositive', fillColor: '#00000000', strokeWidth: 3.0, cornerRadius: 5.0 }) }), barcodeItemConfiguration: new BarcodeItemConfiguration({ imageVisible: true, titleSelected: new StyledText({ text: 'BARCODE_TITLE', color: '?sbColorOnSurface' }), subtitleSelected: new StyledText({ visible: true, text: 'BARCODE_SUBTITLE', color: '?sbColorOnSurfaceVariant', useShadow: false }), titleDeselected: new StyledText({ visible: true, text: 'BARCODE_TITLE', color: '?sbColorOnSurface', useShadow: false }), 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<MultipleScanningMode>`} */ constructor(source = {}) { super(); if (source.countingRepeatDelay !== undefined) { this.countingRepeatDelay = source.countingRepeatDelay; } if (source.allowEmptySubmission !== undefined) { this.allowEmptySubmission = source.allowEmptySubmission; } if (source.mode !== undefined) { this.mode = source.mode; } if (source.sheet !== undefined) { this.sheet = new Sheet(source.sheet); } if (source.sheetContent !== undefined) { this.sheetContent = new SheetContent(source.sheetContent); } if (source.manualCountEditDialog !== undefined) { this.manualCountEditDialog = new ManualCountEditDialog(source.manualCountEditDialog); } if (source.barcodeInfoMapping !== undefined) { this.barcodeInfoMapping = new BarcodeInfoMapping(source.barcodeInfoMapping); } if (source.arOverlay !== undefined) { this.arOverlay = new ArOverlayGeneralConfiguration(source.arOverlay); } } } //# sourceMappingURL=MultipleScanningModeUseCase.js.map