Skip to main content

Advanced Configurations

MatrixScan Find is optimized by default for efficiency, accuracy, and a seamless user experience. However, there are multiple advanced settings available to further customize MatrixScan Find to best fit your needs.

BarcodeFind Listener

You may want more fine-grained knowledge over the different events happening during the life of the BarcodeFind mode, such as when the search starts, pauses, and stops.

To do this, you can directly register a SDCBarcodeFindListener on the mode itself, keeping in mind that these listeners are called from a background thread.

mode.addListener(self)

extension PlaygroundViewController: BarcodeFindListener {
func barcodeFind(_ barcodeFind: BarcodeFind,
didPauseSearch foundItems: Set<BarcodeFindItem>) {
// The mode was paused
}

func barcodeFindDidStartSearch(_ barcodeFind: BarcodeFind) {
// The mode was started
}

func barcodeFind(_ barcodeFind: BarcodeFind,
didStopSearch foundItems: Set<BarcodeFindItem>) {
// The mode was stopped
}
}

Multiple criteria

You can assign different brushes to each BarcodeFindItem, so they appear visually different to the end user. This can be used to make some items stand out more, or to help the user mentally group certain items together.

let availableBrush = Brush(fill: .green.withAlphaComponent(0.2), stroke: .green, strokeWidth: 1)
let expiredBrush = Brush(fill: .red.withAlphaComponent(0.2), stroke: .red, strokeWidth: 1)

var items = Set<BarcodeFindItem>()
items.insert(BarcodeFindItem(
searchOptions: BarcodeFindItemSearchOptions(barcodeData: "9783598215438", brush: availableBrush),
content: BarcodeFindItemContent(
info: "Mini Screwdriver Set",
additionalInfo: "(6-Piece)",
image: nil)
))
items.insert(BarcodeFindItem(
searchOptions: BarcodeFindItemSearchOptions(barcodeData: "9783598215414", brush: expiredBrush),
content: nil
))

Set Up a Transformation

Sometimes the barcode data needs to be transformed. For example, if the barcode contains the product identifier and other information, when a product is scanned, the barcode data is first parsed (via a transformation) and then the input list is checked.

First conform to the SDCBarcodeFindTransformer protocol. For example, if you want to only consider the first 5 characters:

class Transformer: NSObject, BarcodeFindTransformer {
func transformBarcodeData(_ data: String) -> String? {
return String(data.prefix(5))
}
}

Then the transformer needs to be set so it can be used by Barcode Find:

barcodeFind.setBarcodeTransformer(Transformer())

UI Customization

The SDCBarcodeFindView by default shows a set of UI elements, any of which can be optionally hidden:

  • Play/Pause button
  • Finish button
  • Searched items carousel
  • Guidance hints
  • Progress bar (hidden by default)

Each of these elements can be shown or hidden as needed. For example:

barcodeFindView.shouldShowCarousel = false
barcodeFindView.shouldShowProgressBar = true