SparkScan AIO View

Defined under the namespace Scandit.Datacapture.Barcode.Spark.Ui

SparkScanAioView
class SparkScanAioView

Added in version 8.7.0

An all-in-one React component for SparkScan. Rendering this single element replaces the manual assembly of a DataCaptureContext, a SparkScan mode and a SparkScanView — the component owns all of them, along with its camera claim and its lifecycle.

The component must be rendered inside a ScanditProvider, which supplies the DataCaptureContext and the shared camera. Scanning starts once the component is mounted and enabled, and stops when it unmounts.

Configuration is passed through SparkScanAioViewProps. To gain manual control over the component, attach a React ref typed as SparkScanAioViewHandle. Toolbar interactions are reported through SparkScanAioViewUiListener.

To build your first screen with the AIO components, refer to the AIO components getting started guide. For the classic API, refer to the SparkScan Get Started guide.

SparkScanAioViewProps
interface SparkScanAioViewProps

Added in version 8.7.0

Configuration for SparkScanAioView.

A settings source is required: pass either symbologies or sparkScanSettings. Both are optional on this interface, but SparkScanAioView requires one of them, so rendering the component with neither is a compile error. Supplying both is allowed, and sparkScanSettings takes precedence. Every other prop is optional.

didScan(barcodes, session, getFrameData)
didScan?(barcodes: Barcode[],
        session: SparkScanSession,
        getFrameData: () => Promise<FrameData | null>): void | Promise<void>

Added in version 8.7.0

Called for each newly-recognized barcode, with the barcodes taken from SparkScanSession.newlyRecognizedBarcode (an empty array when there are none).

Return a promise to keep the frame alive while asynchronous work runs. getFrameData() resolves to the FrameData for the frame, and becomes invalid once the returned promise resolves.

Backed by the native SparkScanListener.didScan() event, so it fires only on a recognition, independently of didUpdateSession().

didUpdateSession(session, getFrameData)
didUpdateSession?(session: SparkScanSession,
        getFrameData: () => Promise<FrameData | null>): void | Promise<void>

Added in version 8.7.0

Called on every session update, regardless of whether a barcode was recognized. Backed by the native SparkScanListener.didUpdateSession() event and independent of didScan().

symbologies
symbologies?: Symbology[]

Added in version 8.7.0

Symbologies to enable. Shorthand for SparkScanSettings.enabledSymbologies; ignored when sparkScanSettings is set.

scanIntention
scanIntention?: ScanIntention

Added in version 8.7.0

Whether scanning is smart or manual. Shorthand for SparkScanSettings.scanIntention; ignored when sparkScanSettings is set.

enabledCompositeTypes
enabledCompositeTypes?: CompositeType[]

Added in version 8.7.0

Composite barcode types to enable. Shorthand for SparkScanSettings.enabledCompositeTypes; ignored when sparkScanSettings is set.

itemDefinitions
itemDefinitions?: ScanItemDefinition[]

Added in version 8.7.0

Item definitions for USI-style scanning. Shorthand for the equivalent setting on SparkScanSettings; ignored when sparkScanSettings is set.

codeDuplicateFilter
codeDuplicateFilter?: number

Added in version 8.7.0

Time interval in milliseconds during which duplicate barcodes are filtered out. Shorthand for SparkScanSettings.codeDuplicateFilter; ignored when sparkScanSettings is set.

batterySaving
batterySaving?: BatterySavingMode

Added in version 8.7.0

Battery saving mode. Shorthand for SparkScanSettings.batterySaving; ignored when sparkScanSettings is set.

sparkScanSettings
sparkScanSettings?: SparkScanSettings | null

Added in version 8.7.0

The settings applied to the underlying mode, as a complete SparkScanSettings object. Takes precedence over the shorthand settings props above; when both are given, the shorthand props are ignored and a warning is logged.

sparkScanViewSettings
sparkScanViewSettings?: SparkScanViewSettings | null

Added in version 8.7.0

View-level settings such as the mini preview size and trigger animation, as a SparkScanViewSettings object. Omit to use the defaults.

uiListener
uiListener?: SparkScanAioViewUiListener

Added in version 8.7.0

Listener that receives callbacks for toolbar button taps and view state changes. See SparkScanAioViewUiListener.

feedback
feedback?: SparkScanBarcodeFeedback

Added in version 8.7.0

Sound and vibration feedback applied to every scanned barcode. Shorthand for a constant feedbackDelegate, which decides feedback per barcode and takes precedence when both are set.

navigation
navigation?: ScanditNavigationProp

Added in version 8.7.0

Navigation object for the screen the component is rendered on, for example React Navigation’s navigation prop (typed as ScanditNavigationProp). When it is provided, scanning is suspended — the mode is disabled and the camera turned off — while the screen is blurred or the application is backgrounded, and resumed when the screen regains focus. Ignored while disabled is set.

disabled
disabled?: boolean

Added in version 8.7.0

Set to true to keep scanning off. Leaving it false does not keep scanning on — navigation and app-state handling still turn the mode on and off on their own.

SparkScanAioViewHandle.enable() and SparkScanAioViewHandle.disable() change the same state directly. If you call those, this prop no longer reflects whether the component is actually scanning.

appStateHandlingDisabled
appStateHandlingDisabled?: boolean

Added in version 8.7.0

Turns off the automatic enabling and disabling of the mode in response to the application moving between foreground and background.

previewSizeControlVisible
previewSizeControlVisible?: boolean

Added in version 8.7.0

Whether the mini preview size control is shown. Defaults to true.

scanningBehaviorButtonVisible
scanningBehaviorButtonVisible?: boolean

Added in version 8.7.0

Whether the scanning behavior button is shown. Defaults to false.

barcodeCountButtonVisible
barcodeCountButtonVisible?: boolean

Added in version 8.7.0

Whether the barcode count button is shown. Defaults to false.

barcodeFindButtonVisible
barcodeFindButtonVisible?: boolean

Added in version 8.7.0

Whether the barcode find button is shown. Defaults to false.

targetModeButtonVisible
targetModeButtonVisible?: boolean

Added in version 8.7.0

Deprecated since version 8.7: Use selectionModeButtonVisible instead. The target mode button toggles SparkScanSettings.selectionMode between SelectionMode.On and SelectionMode.Off. This property will be removed in a future release.

Whether the target mode button is shown. Defaults to false.

selectionModeButtonVisible
selectionModeButtonVisible?: boolean

Added in version 8.7.0

Whether the selection mode button is shown. Defaults to false. The button toggles SparkScanSettings.selectionMode between SelectionMode.On and SelectionMode.Off.

Replaces the deprecated targetModeButtonVisible. Both control the same state; this one wins when both are set.

labelCaptureButtonVisible
labelCaptureButtonVisible?: boolean

Added in version 8.7.0

Whether the label capture button is shown. Defaults to false.

cameraSwitchButtonVisible
cameraSwitchButtonVisible?: boolean

Added in version 8.7.0

Whether the camera switch button is shown. Defaults to false.

torchControlVisible
torchControlVisible?: boolean

Added in version 8.7.0

Whether the torch control is shown. Defaults to true.

zoomSwitchControlVisible
zoomSwitchControlVisible?: boolean

Added in version 8.7.0

Whether the zoom switch control is shown. Defaults to true.

previewCloseControlVisible
previewCloseControlVisible?: boolean

Added in version 8.7.0

Whether the mini preview close control is shown. Defaults to true.

triggerButtonVisible
triggerButtonVisible?: boolean

Added in version 8.7.0

Whether the trigger button is shown. Defaults to true.

toolbarBackgroundColor
toolbarBackgroundColor?: Color | null

Added in version 8.7.0

The toolbar background color.

toolbarIconActiveTintColor
toolbarIconActiveTintColor?: Color | null

Added in version 8.7.0

The toolbar icon active color.

toolbarIconInactiveTintColor
toolbarIconInactiveTintColor?: Color | null

Added in version 8.7.0

The toolbar icon inactive color.

triggerButtonAnimationColor
triggerButtonAnimationColor?: Color | null

Added in version 8.7.0

The color of the pulsing animation around the trigger button, shown while the scanner is active.

triggerButtonExpandedColor
triggerButtonExpandedColor?: Color | null

Added in version 8.7.0

The background color of the trigger button when it is expanded.

triggerButtonCollapsedColor
triggerButtonCollapsedColor?: Color | null

Added in version 8.7.0

The background color of the trigger button when it is collapsed.

triggerButtonTintColor
triggerButtonTintColor?: Color | null

Added in version 8.7.0

The trigger button tint color.

triggerButtonImage
triggerButtonImage?: string | null

Added in version 8.7.0

The image displayed in the trigger button.

feedbackDelegate
feedbackDelegate?: SparkScanFeedbackDelegate | null

Added in version 8.7.0

Delegate that decides the feedback per barcode. If none is set, the default SparkScanBarcodeFeedback.Success feedback is emitted.

shouldHandleAndroidLifecycleAutomatically
shouldHandleAndroidLifecycleAutomatically?: boolean

Added in version 8.7.0

Whether the native Android view pauses and resumes itself with the host activity’s lifecycle. Android only; ignored on iOS.

style
style?: StyleProp<ViewStyle>

Added in version 8.7.0

Style applied to the view, defaulting to { flex: 1 }. This is the only React Native View prop the component forwards; it renders its own native view and passes nothing else through.

children
children?: ReactNode

Added in version 8.7.0

Content rendered on top of the scanning UI.

SparkScanAioViewHandle
interface SparkScanAioViewHandle

Added in version 8.7.0

Imperative operations on a SparkScanAioView, reached through a ref on the component.

reset()
reset(): Promise<void>

Added in version 8.7.0

Resets the SparkScan session, clearing the history of scanned codes. This affects duplicate filtering: calling reset() every frame has the same effect as setting SparkScanSettings.codeDuplicateFilter to 0. Only call it from inside a listener callback.

showToast(text)
showToast(text: string): Promise<void>

Added in version 8.7.0

Shows a toast message over the scanning UI.

startScanning()
startScanning(): Promise<void>

Added in version 8.7.0

Starts the scanning process without user interaction.

pauseScanning()
pauseScanning(): Promise<void>

Added in version 8.7.0

Pauses the scanning process without user interaction.

stopScanning()
stopScanning(): Promise<void>

Added in version 8.7.0

Stops the scanning process: puts the view into an idle state and turns the camera off. Call it when the screen containing the component is navigated away from.

show()
show(): Promise<void>

Added in version 8.7.0

Shows the scanning UI.

hide()
hide(): Promise<void>

Added in version 8.7.0

Hides the scanning UI.

enable()
enable(): Promise<void>

Added in version 8.7.0

Turns scanning on now: enables the mode and turns the camera on. Automatic navigation and application-state handling may subsequently turn it off again.

disable()
disable(): Promise<void>

Added in version 8.7.0

Turns scanning off now: disables the mode and turns the camera off.

SparkScanAioViewUiListener
interface SparkScanAioViewUiListener

Added in version 8.7.0

Callbacks for taps on the toolbar buttons and for view state changes. Set it through SparkScanAioViewProps.uiListener.

The callbacks correspond to the SparkScanViewUiListener methods; the tap callbacks receive the SparkScanAioViewHandle as their first argument, so the view can be acted on without a separate ref.

didTapBarcodeCountButton(view)
didTapBarcodeCountButton?(view: SparkScanAioViewHandle): void

Added in version 8.7.0

Called when the barcode count button in the toolbar is tapped. Called from the main thread.

didTapBarcodeFindButton(view)
didTapBarcodeFindButton?(view: SparkScanAioViewHandle): void

Added in version 8.7.0

Called when the barcode find button in the toolbar is tapped. Called from the main thread.

didTapLabelCaptureButton(view)
didTapLabelCaptureButton?(view: SparkScanAioViewHandle): void

Added in version 8.7.0

Called when the label capture button in the toolbar is tapped. Called from the main thread.

didChangeViewState(newState)
didChangeViewState?(newState: SparkScanViewState): void

Added in version 8.7.0

Called when the SparkScanViewState changes. Called from the main thread.

didChangeScanningMode(newScanningMode)
didChangeScanningMode?(newScanningMode: SparkScanScanningMode): void

Added in version 8.7.0

Called when the current SparkScanScanningMode changes. Called from the main thread.