SparkScan AIO View
Defined under the namespace Scandit.Datacapture.Barcode.Spark.Ui
- SparkScanAioView
class SparkScanAioViewAdded 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
reftyped 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 SparkScanAioViewPropsAdded 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 |
nullAdded 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 |
nullAdded 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?: ScanditNavigationProp
Added in version 8.7.0
Navigation object for the screen the component is rendered on, for example React Navigation’s
navigationprop (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 |
nullAdded in version 8.7.0
The toolbar background color.
- toolbarIconActiveTintColor
toolbarIconActiveTintColor?: Color |
nullAdded in version 8.7.0
The toolbar icon active color.
- toolbarIconInactiveTintColor
toolbarIconInactiveTintColor?: Color |
nullAdded in version 8.7.0
The toolbar icon inactive color.
- triggerButtonAnimationColor
triggerButtonAnimationColor?: Color |
nullAdded in version 8.7.0
The color of the pulsing animation around the trigger button, shown while the scanner is active.
- triggerButtonExpandedColor
triggerButtonExpandedColor?: Color |
nullAdded in version 8.7.0
The background color of the trigger button when it is expanded.
- triggerButtonCollapsedColor
triggerButtonCollapsedColor?: Color |
nullAdded in version 8.7.0
The background color of the trigger button when it is collapsed.
- triggerButtonTintColor
triggerButtonTintColor?: Color |
nullAdded in version 8.7.0
The trigger button tint color.
- triggerButtonImage
triggerButtonImage?: string |
nullAdded in version 8.7.0
The image displayed in the trigger button.
- feedbackDelegate
feedbackDelegate?: SparkScanFeedbackDelegate |
nullAdded 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.
- SparkScanAioViewHandle
interface SparkScanAioViewHandleAdded in version 8.7.0
Imperative operations on a SparkScanAioView, reached through a
refon 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.
- SparkScanAioViewUiListener
interface SparkScanAioViewUiListenerAdded 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):
voidAdded 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):
voidAdded 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):
voidAdded 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):
voidAdded in version 8.7.0
Called when the SparkScanViewState changes. Called from the main thread.
- didChangeScanningMode(newScanningMode)
didChangeScanningMode?(newScanningMode: SparkScanScanningMode):
voidAdded in version 8.7.0
Called when the current SparkScanScanningMode changes. Called from the main thread.