Skip to content

Commit 1458313

Browse files
committed
feat: alpha.0
1 parent 9a7d9bc commit 1458313

30 files changed

Lines changed: 876 additions & 134 deletions

File tree

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
1-
import { Observable, EventData, Page } from '@nativescript/core';
1+
import { Observable, EventData, Page, Dialogs } from '@nativescript/core';
22
import { DemoSharedMlkitCore } from '@demo/shared';
3-
import { MLKitView } from '@nativescript/mlkit-core';
4-
3+
import { DetectionType, MLKitView } from '@nativescript/mlkit-core';
4+
import { BarcodeResult } from '@nativescript/mlkit-barcode-scanning';
5+
import { FaceResult } from '@nativescript/mlkit-face-detection';
6+
import { ImageLabelingResult } from '@nativescript/mlkit-image-labeling';
7+
import { ObjectResult } from '@nativescript/mlkit-object-detection';
8+
import { PoseResult } from '@nativescript/mlkit-pose-detection';
9+
import { TextResult } from '@nativescript/mlkit-text-recognition';
510
export function navigatingTo(args: EventData) {
611
const page = <Page>args.object;
712
page.bindingContext = new DemoModel();
813
}
914

1015
export class DemoModel extends DemoSharedMlkitCore {
1116
camera: MLKitView;
17+
detectorType = "all";
1218

13-
onLoaded(args){
19+
onLoaded(args) {
1420
this.camera = args.object;
1521
}
1622

17-
onDetection(data) {
18-
console.log('onDetection', data);
23+
onDetection(data, type: DetectionType) {
24+
console.log('onDetection', data, type);
1925
}
2026

21-
toggleCamera(){
27+
toggleCamera() {
2228
this.camera.toggleCamera();
2329
}
30+
31+
requestPermission() {
32+
this.camera.requestCameraPermission();
33+
}
34+
35+
changeType(args) {
36+
Dialogs.action('Change Detector Type', 'Cancel', [
37+
'all',
38+
'barcode',
39+
'digitalInk (unsupport atm)',
40+
'face',
41+
'image',
42+
'object',
43+
'pose',
44+
'text',
45+
'none'
46+
]).then(value => {
47+
if (value === 'Cancel') { return }
48+
if (value.indexOf('digitalInk') > -1) {
49+
Dialogs.alert('digitalInk is currently unsupported')
50+
this.set('detectorType', 'none');
51+
} else {
52+
this.set('detectorType', value);
53+
}
54+
})
55+
}
2456
}
57+

apps/demo/src/plugin-demos/mlkit-core.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
<ActionBar title="mlkit-core" icon="" class="action-bar">
44
</ActionBar>
55
</Page.actionBar>
6-
<GridLayout class="p-20">
7-
<ui:MLKitView loaded="{{ onLoaded }}" cameraPosition="back" detectionType="all" onDetection="{{ onDetection }}"/>
8-
<Button text="Toggle Camera" tap="{{ toggleCamera }}" />
6+
<GridLayout rows="*,auto,auto,auto,auto" height="100%">
7+
<ui:MLKitView height="100%" rowSpan="3" loaded="{{ onLoaded }}" cameraPosition="back" detectionType="{{ detectorType }}" onDetection="{{ onDetection }}"/>
8+
<Button row="1" height="40" text="Toggle Camera" tap="{{ toggleCamera }}" />
9+
<Button row="2" height="40" text="Request Camera Permission" tap="{{ requestPermission }}" />
10+
<Label row="3" text="{{'Detecting ' + detectorType }}"/>
11+
<Button row="4" height="40" text="Change Detector Type" tap="{{ changeType }}" />
912
</GridLayout>
1013
</Page>
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
export enum EncryptionType {
2+
Open = 'open',
3+
WPA = 'wpa',
4+
WEP = 'wep',
5+
Unknown = 'unknown'
6+
}
7+
8+
export interface WiFi {
9+
encryptionType: EncryptionType
10+
password: string
11+
ssid: string
12+
}
13+
14+
export interface UrlBookmark {
15+
title?: string
16+
url?: string
17+
}
18+
19+
export interface Sms {
20+
message: string
21+
phoneNumber: string
22+
}
23+
24+
export enum PhoneType {
25+
Unknown = "unknown",
26+
Home = "home",
27+
Work = "work",
28+
Fax = "fax",
29+
Mobile = "mobile"
30+
}
31+
32+
export interface Phone {
33+
number: string
34+
type: PhoneType
35+
}
36+
37+
38+
export enum EmailType {
39+
Unknown = "unknown",
40+
Home = "home",
41+
Work = "work"
42+
}
43+
44+
45+
export interface Email {
46+
address: string
47+
subject: string
48+
body: string
49+
type: EmailType
50+
}
51+
52+
export interface DriverLicense {
53+
documentType: string;
54+
firstName: string;
55+
middleName: string;
56+
lastName: string;
57+
gender: string;
58+
addressStreet: string;
59+
addressCity: string;
60+
addressState: string;
61+
addressZip: string;
62+
licenseNumber: string;
63+
issueDate: string;
64+
expiryDate: string;
65+
birthDate: string;
66+
issuingCountry: string;
67+
}
68+
69+
70+
export interface CalenderEvent {
71+
description?: string
72+
location?: string
73+
organizer?: string
74+
status?: string
75+
summary?: string;
76+
start?: string
77+
end?: string
78+
}
79+
80+
export enum AddressType {
81+
Unknown = "unknown",
82+
Home = "home",
83+
Work = "work"
84+
}
85+
86+
export interface Address {
87+
addressLines: string[]
88+
type: AddressType;
89+
}
90+
91+
export interface ContactInfo {
92+
addresses: Address[]
93+
}
94+
95+
export interface Origin {
96+
x: number;
97+
y: number;
98+
}
99+
100+
export interface Size {
101+
width: number;
102+
height: number;
103+
}
104+
105+
export interface Bounds {
106+
origin: Origin;
107+
size: Size;
108+
}
109+
110+
export interface Point {
111+
x: number;
112+
y: number;
113+
}
114+
115+
export interface GeoPoint {
116+
lat: number;
117+
lng: number;
118+
}
119+
120+
121+
export enum ValueType {
122+
ContactInfo = "contactInfo",
123+
Email = "email",
124+
ISBN = "isbn",
125+
Phone = "phone",
126+
Product = "product",
127+
Text = "text",
128+
Sms = "sms",
129+
URL = "url",
130+
WiFi = "wifi",
131+
Geo = "geo",
132+
CalenderEvent = "calender",
133+
DriverLicense = "driverLicense",
134+
Unknown = "unknown"
135+
}
136+
137+
138+
export interface BarcodeResult {
139+
calendarEvent?: CalenderEvent
140+
contactInfo?: ContactInfo
141+
bounds?: Bounds
142+
points?: Point[]
143+
displayValue?: string
144+
driverLicense?: DriverLicense
145+
email?: Email
146+
format: BarcodeScanner.BarcodeFormat
147+
geoPoint?: GeoPoint
148+
phone?: Phone
149+
rawBytes?: any[]
150+
rawValue?: string;
151+
sms?: Sms
152+
url?: UrlBookmark
153+
valueType?: ValueType
154+
wifi?: WiFi
155+
}

packages/mlkit-barcode-scanning/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nativescript/mlkit-barcode-scanning",
3-
"version": "1.0.0",
4-
"description": "Add a plugin description",
3+
"version": "1.0.0-alpha.0",
4+
"description": "NativeScript MLKit Barcode Scanner module",
55
"main": "index",
66
"typings": "index.d.ts",
77
"nativescript": {

0 commit comments

Comments
 (0)