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

@nativescript/mlkit-barcode-scanning

v2.1.0

Published

NativeScript MLKit Barcode Scanner module

Downloads

4,570

Readme

@nativescript/mlkit-barcode-scanning

This plugin is used with @nativescript/mlkit-core. It enables barcode scanning and provides the BarcodeResult type for the barcode-scanned data.

Contents

Installation

npm install @nativescript/mlkit-barcode-scanning

Use @nativescript/mlkit-barcode-scanning

Follow these steps to scan a barcode:

  1. Add MLKitView to your page and set the detectionType property to "barcode".
<StackLayout>
    <MLKitView
    detectionType="barcode" 
    detection="{{ onDetection }}"
    />
    <Label row="6">
        <FormattedString>
            <Span text="Barcode: "/>
            <Span text="{{ barcode }}" class="text-green-500"/>
        </FormattedString>
    </Label>
</StackLayout>
  1. To receive the scanned barcode data, handle the detection event and get the data if the event's type is "barcode".
import { Observable } from "@nativescript/core"
import { DetectionEvent, DetectionType } from "@nativescript/mlkit-core";
import { BarcodeResult } from "@nativescript/mlkit-barcode-scanning";

export class BarcodeScannerViewModel extends Observable {
    barcode = ""
...
    onDetection(event: DetectionEvent){

        if(event.type == DetectionType.Barcode){
            const barcodeData: BarcodeResult = event.data[0] as BarcodeResult;
            this.set("barcode", barcodeData?.rawValue)
        }
}
}

Demo app

You can try a demo app at StackBlitz with the NativeScript Preview app.

API

Interfaces

BarcodeResult

The scanned barcode data object has the following properties:

| Property | Type | Optional |:---------|:-----|:------------------ | format | BarcodeFormats | No | calendarEvent | CalenderEvent | Yes | contactInfo | ContactInfo | Yes | bounds | Bounds | Yes | points | Point[] | Yes | displayValue | string | Yes | driverLicense| DriverLicense | Yes | email | Email | Yes | geoPoint | GeoPoint | Yes | phone| Phone | Yes | rawBytes| any[] | Yes | rawValue | string | Yes | sms| Sms | Yes | url| UrlBookmark | Yes | valueType| ValueType | Yes | wifi| WiFi | Yes

WiFi

| Property | Type | Optional |:---------|:-----|:------- | encryptionType | string | No | password| string | No | ssid| string | No

UrlBookmark

| Property | Type | Optional |:---------|:-----|:------- | title | string | Yes | url| string | Yes

Sms

| Property | Type | Optional |:---------|:-----|:------- | message | string | No | honeNumber| string | No

Phone

| Property | Type | Optional |:---------|:-----|:------- | number | string | No | type| PhoneType | No

Email

| Property | Type | Optional |:---------|:-----|:------- | address | string | No | subject | string | No | body | string | No | type | EmailType

DriverLicense

| Property | Type | Optional |:---------|:-----|:------- | documentType| string | No | firstName| string | No | middleName| string | No | lastName| string | No | gender| string | No | addressStreet| string | No | addressCity| string | No | addressState| string | No | addressZip| string | No | licenseNumber| string | No | issueDate| string | No | expiryDate| string | No | birthDate| string | No | issuingCountry| string | No

CalenderEvent

| Property | Type | Optional |:---------|:-----|:------- | description| string | Yes | location| string | Yes | organizer| string | Yes | status| string | Yes | summary| string | Yes | start| string | Yes | end| string | Yes

Address

| Property | Type | Optional |:---------|:-----|:------- | addressLines| string[]| No | type | AddressType | No

ContactInfo

| Property | Type | Optional |:---------|:-----|:------- | addresses| Address[] | No

Origin

| Property | Type | Optional |:---------|:-----|:------- | x| number | No | y| number | No

Size

| Property | Type | Optional |:---------|:-----|:------- | width| number | No | height| number | No

Bounds

| Property | Type | Optional |:---------|:-----|:------- | origin | Origin | No | size | Size | No

Point

| Property | Type | Optional |:---------|:-----|:------- | x| number | No | y| number | No

GeoPoint

| Property | Type | Optional |:---------|:-----|:------- | lat| number | No | lng| number | No

Enums

EncryptionType

  • Open = 'open'
  • WPA = 'wpa'
  • WEP = 'wep'
  • Unknown = 'unknown'

PhoneType

  • Unknown = "unknown"
  • Home = "home"
  • Work = "work"
  • Fax = "fax"
  • Mobile = "mobile"

EmailType

  • Unknown = "unknown"
  • Home = "home"
  • Work = "work"

AddressType

  • Unknown = "unknown"
  • Home = "home"
  • Work = "work"

ValueType

  • ContactInfo= "contactInfo"
  • Email= "email"
  • ISBN= "isbn"
  • Phone= "phone"
  • Product= "product"
  • Text= "text"
  • Sms= "sms"
  • URL= "url"
  • WiFi= "wifi"
  • Geo= "geo"
  • CalenderEvent= "calender"
  • DriverLicense= "driverLicense"
  • Unknown= "unknown"

BarcodeFormats

  • ALL = 'all'
  • CODE_128 = 'code_128'
  • CODE_39 = 'code_39'
  • CODE_93 = 'code_93'
  • CODABAR = 'codabar'
  • DATA_MATRIX = 'data_matrix'
  • EAN_13 = 'ean_13'
  • EAN_8 = 'ean_8'
  • ITF = 'itf'
  • QR_CODE = 'qr_code'
  • UPC_A = 'upc_a'
  • UPC_E = 'upc_e'
  • PDF417 = 'pdf417'
  • AZTEC = 'aztec'
  • UNKOWN = 'unknown'

License

Apache License Version 2.0