Skip to content

Commit

Permalink
feat(firebase-vision): add barcodeDetector (#3426)
Browse files Browse the repository at this point in the history
  • Loading branch information
alon22 authored Jun 11, 2020
1 parent ef17dc5 commit 1aacb48
Showing 1 changed file with 188 additions and 0 deletions.
188 changes: 188 additions & 0 deletions src/@ionic-native/plugins/firebase-vision/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,185 @@
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';

export enum BarcodeFormat {
UNKNOWN = -1,
ALL_FORMATS = 0,
CODE_128 = 1,
CODE_39 = 2,
CODE_93 = 4,
CODABAR = 8,
DATA_MATRIX = 16,
EAN_13 = 32,
EAN_8 = 64,
ITF = 128,
QR_CODE = 256,
UPC_A = 512,
UPC_E = 1024,
PDF417 = 2048,
AZTEC = 4096
}

export enum BarcodeValueType {
/** Unknown Barcode value types. */
Unknown,
/** Barcode value type for contact info. */
ContactInfo,
/** Barcode value type for email addresses. */
Email,
/** Barcode value type for ISBNs. */
ISBN,
/** Barcode value type for phone numbers. */
Phone,
/** Barcode value type for product codes. */
Product,
/** Barcode value type for SMS details. */
SMS,
/** Barcode value type for plain text. */
Text,
/** Barcode value type for URLs/bookmarks. */
URL,
/** Barcode value type for Wi-Fi access point details. */
WiFi,
/** Barcode value type for geographic coordinates. */
GeographicCoordinates,
/** Barcode value type for calendar events. */
CalendarEvent,
/** Barcode value type for driver's license data. */
DriversLicense
}

export enum BarcodeEmailType {
/** Unknown email type. */
Unknown,
/** Barcode work email type. */
Work,
/** Barcode home email type. */
Home
}

export enum BarcodePhoneType {
/** Unknown phone type. */
Unknown,
/** Barcode work phone type. */
Work,
/** Barcode home phone type. */
Home,
/** Barcode fax phone type. */
Fax,
/** Barcode mobile phone type. */
Mobile
}

export enum BarcodeWiFiEncryptionType {
/** Barcode unknown Wi-Fi encryption type. */
Unknown,
/** Barcode open Wi-Fi encryption type. */
Open,
/** Barcode WPA Wi-Fi encryption type. */
WPA,
/** Barcode WEP Wi-Fi encryption type. */
WEP
}

export enum BarcodeAddressType {
/** Barcode unknown address type. */
Unknown,
/** Barcode work address type. */
Work,
/** Barcode home address type. */
Home
}

export interface Barcode {
valueType: BarcodeValueType
format: BarcodeFormat
rawValue: string
displayValue: string
cornerPoints: any
email: BarcodeEmail
phone: BarcodePhone
sms: BarcodeSms
url: BarcodeUrl
wifi: BarcodeWifi
geoPoint: BarcodeGeoPoint
calendarEvent: BarcodeCalendarEvent
contactInfo: BarcodeContactInfo
driverLicense: BarcodeDriverLicense
}

export interface BarcodeEmail {
address: string
body: string
subject: string
type: BarcodeEmailType
}

export interface BarcodePhone {
number: string
type: BarcodePhoneType
}

export interface BarcodeSms {
phoneNumber: string
message: string
}

export interface BarcodeUrl {
title: string
url: string
}
export interface BarcodeWifi {
ssid: string
password: string
type: BarcodeWiFiEncryptionType
}
export interface BarcodeGeoPoint {
latitude: number
longitude: number
}

export interface BarcodeCalendarEvent {
eventDescription: string
location: string
organizer: string
status: string
summary: string
start: any
end: any
}

export interface BarcodeContactInfo {
title: string
name: string
addresses: BarcodeAddress[]
phones: BarcodePhone[]
emails: BarcodeEmail[]
organization: string
urls: string
}

export interface BarcodeAddress {
addressLine: string
type: BarcodeAddressType
}

export interface BarcodeDriverLicense {
firstName: string
middleName: string
lastName: string
gender: string
addressCity: string
addressState: string
addressStreet: string
addressZip: string
birthDate: string
documentType: string
licenseNumber: string
expiryDate: string
issuingDate: string
issuingCountry: string
}

/**
* @name Firebase Vision
* @description
Expand All @@ -20,6 +199,10 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* .then((res: string) => console.log(res))
* .catch((error: string) => console.error(error));
*
* this.firebaseVision.barcodeDetector(FILE_URI)
* .then((res: Barcode[]) => console.log(res))
* .catch((error: string) => console.error(error));
*
* ```
*/
@Plugin({
Expand All @@ -40,4 +223,9 @@ export class FirebaseVision extends IonicNativePlugin {
onDeviceTextRecognizer(file_uri: string): Promise<string> {
return;
}

@Cordova()
barcodeDetector(file_uri: string): Promise<Barcode[]> {
return;
}
}

0 comments on commit 1aacb48

Please sign in to comment.