UNPKG

react-native-scanbot-sdk

Version:

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

150 lines (141 loc) 4.32 kB
import { ButtonConfiguration } from '../common/Common'; import { PartiallyConstructible } from '../../utils'; import { StyledText } from '../common/Common'; /** Configuration of the the mapper's error dialog. */ export class BarcodeItemErrorState extends PartiallyConstructible { /** Title displayed above the error message. */ title = new StyledText({ text: 'Connection Error!', color: '?sbColorOnSurface' }); /** Error message. */ subtitle = new StyledText({ text: 'There was an issue and the data requested was not fetched. You could try again or discard this result to start a new scan.', color: '?sbColorOnSurfaceVariant' }); /** Configuration of the retry button. */ retryButton = new ButtonConfiguration({}); /** Configuration of the cancel button. */ cancelButton = new ButtonConfiguration({}); /** @param source {@displayType `DeepPartial<BarcodeItemErrorState>`} */ constructor(source = {}) { super(); if (source.title !== undefined) { this.title = new StyledText(source.title); } if (source.subtitle !== undefined) { this.subtitle = new StyledText(source.subtitle); } if (source.retryButton !== undefined) { this.retryButton = new ButtonConfiguration(source.retryButton); } if (source.cancelButton !== undefined) { this.cancelButton = new ButtonConfiguration(source.cancelButton); } } } /** Format of the mapped barcode data. */ export class BarcodeMappedData extends PartiallyConstructible { /** Title of the barcode. */ /** Subtitle of the barcode. */ /** Image of the barcode. */ /** Use this key to display the original barcode image */ static barcodeImageKey = 'BARCODE_IMAGE'; /** @param source {@displayType `DeepPartial<BarcodeMappedData>`} */ constructor(source = {}) { super(); if (source.title !== undefined) { this.title = source.title; } else { throw new Error('title must be present in constructor argument'); } if (source.subtitle !== undefined) { this.subtitle = source.subtitle; } else { throw new Error('subtitle must be present in constructor argument'); } if (source.barcodeImage !== undefined) { this.barcodeImage = source.barcodeImage; } else { throw new Error('barcodeImage must be present in constructor argument'); } } } /** Configuration of the barcode data mapping. */ export class BarcodeInfoMapping extends PartiallyConstructible { /** Callback to map the barcode data to the data of the corresponding product. */ barcodeItemMapper = null; /** Background color of the barcode info dialog. Default is "?sbColorSurface" */ sheetColor = '?sbColorSurface'; /** Color of the divider and separator lines in the barcode info dialog. Default is "?sbColorOutline" */ dividerColor = '?sbColorOutline'; /** Background color of the overlay surrounding the barcode mapping error dialog. Default is "?sbColorModalOverlay" */ modalOverlayColor = '?sbColorModalOverlay'; /** Text being displayed while a barcode is being mapped. */ loadingMessage = new StyledText({ text: 'Loading message for barcode info mapping.', color: '?sbColorPrimary' }); /** Configuration of the error state displayed when processing a barcode fails. */ errorState = new BarcodeItemErrorState({}); /** @param source {@displayType `DeepPartial<BarcodeInfoMapping>`} */ constructor(source = {}) { super(); if (source.barcodeItemMapper !== undefined) { this.barcodeItemMapper = source.barcodeItemMapper != null ? source.barcodeItemMapper : null; } 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.loadingMessage !== undefined) { this.loadingMessage = new StyledText(source.loadingMessage); } if (source.errorState !== undefined) { this.errorState = new BarcodeItemErrorState(source.errorState); } } } //# sourceMappingURL=BarcodeInfoMapping.js.map