npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@juit/nativescript-barcodeview

v1.1.3

Published

Embedded barcode scanning view for NativeScript 7

Downloads

2

Readme

Barcode-Scanning View for NativeScript 7

This package implements a minimalistic barcode-scanning View for NativeScript (from v. 7).

Sample

Sample

Attributes

The BarcodeScannerView exposes a few attributes to control the operation of barcode scanning:

XML

<BarcodeScannerView
  formats="QR_CODE, CODE_39"
  preferFrontCamera="false"
  isPaused="false"
  (scanResult)="barcodeScanned($event)"
/>

TypeScript

import { ScanResultEventData } from '@juit/nativescript-barcodeview'

export function barcodeScanned(event: ScanResultEventData) {
  alert(`Scanned "${event.format}" barcode: ${event.text}`)
}

formats

The formats property is defined as a KnownBarcodeFormat[] and informs the barcode scanner what formats should be recognized.

When specified as a string, the formats are case-insensitive, comma and/or whitespace separated

See Barcode Formats below for a list of supported formats.

The default (empty array) represents all supported formats.

isPaused

The isPaused boolean attribute specifies whether barcode scanning is running (false) or paused (true)paused or running.

preferFrontCamera

The preferFrontCamera boolean attribute specifies whether preferentially the scanner should use the back camera (false) or the front one (true).

Events

The scanResult event is triggered once a barcode has been scanned. The event instance associated with this is a ScanResultEventData defined as follows:

export interface ScanResultEventData extends EventData {
  /** The event name, always `scanResult` */
  eventName: ScanResultEvent,
  /** The `BarcodeScannerView` source of this event */
  object: BarcodeScannerView,
  /** The `BarcodeFormat` of the scanned barcode */
  format: BarcodeFormat;
  /** The text contained in the scanned barcode */
  text: string;
}

Clearing results

The BarcodeScannerView will not emit a scanResult event once it detects the same barcode. To clear the last result and be notified of the same barcode, you can call the clearScanResult() method on its instance.

barcodeScannerView.on('scanResult', (result: ScanResultEventData) => {
  // do something with the result and then clear it,
  // allowing it to be reported it once more
  result.object.clearScanResult()
})

Dismissal

Make sure that the BarcodeScannerView's own disposeNativeView() is called to release the camera and barcode-scanning resources

Image Parsing

In some cases (e.g. simulators) it might be necessary to simulate the scanning of a barcode using an image stored on the device.

While this library doesn't support picking images (see the wonderful @nativescript/imagepicker plugin for a good implementation), it offers function to scan ImageAssets.

import { parseBarcodes, BarcodeFormat } from '@juit/nativescript-barcodeview'

const ImageAsset asset = // ... get this with '@nativescript/imagepicker'

parseBarcode(asset, [ BarcodeFormat.QR_CODE ])
  .then((result: scanResult) => {
    console.log(`Scanned "${event.format}" barcode from image: ${event.text}`)
  })

Barcode Formats

| Format | iOS | Android | | ------------------------- | ------- | ------- | | AZTEC | ✓ | ✓ | | CODABAR | ✗ | ✓ | | CODE_128 | ✓ | ✓ | | CODE_39 | ✓ | ✓ | | CODE_39_MOD_43 | ✓ | ✗ | | CODE_93 | ✓ | ✓ | | DATA_MATRIX | ✓ | ✓ | | EAN_13 | ✓ | ✓ | | EAN_8 | ✓ | ✓ | | INTERLEAVED_2_OF_5 | ✓ | ✗ | | ITF_14 | ✓ | ✓ | | MAXICODE | ✗ | ✓ | | PDF_417 | ✓ | ✓ | | QR_CODE | ✓ | ✓ | | RSS_14 | ✗ | ✓ | | RSS_EXPANDED | ✗ | ✓ | | UPC_A | ✗ | ✓ | | UPC_E | ✓ | ✓ | | UPC_EAN_EXTENSION | ✗ | ✓ |