1- import { BarcodeFormats , barcodeFormatsProperty , CameraPosition , cameraPositionProperty , DetectionType , faceDetectionMinFaceSizeProperty , faceDetectionPerformanceModeProperty , faceDetectionTrackingEnabledProperty , imageLablerConfidenceThresholdProperty , MLKitViewBase , objectDetectionClassifyProperty , objectDetectionMultipleProperty } from "./common" ;
1+ import { BarcodeFormats , barcodeFormatsProperty , CameraPosition , cameraPositionProperty , DetectionType , faceDetectionMinFaceSizeProperty , faceDetectionPerformanceModeProperty , faceDetectionTrackingEnabledProperty , imageLablerConfidenceThresholdProperty , MLKitViewBase , objectDetectionClassifyProperty , objectDetectionMultipleProperty , onDetectionProperty } from "./common" ;
22import { Application , Device , Utils , AndroidActivityRequestPermissionsEventData } from '@nativescript/core' ;
33import lazy from '@nativescript/core/utils/lazy' ;
44
@@ -19,12 +19,11 @@ const IMAGE_LABELING_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamer
1919const OBJECT_DETECTION_SUPPORTED = lazy ( ( ) => typeof io . github . triniwiz . fancycamera ?. objectdetection ?. ObjectDetection ) ;
2020const POSE_DETECTION_SUPPORTED = lazy ( ( ) => typeof io . github . triniwiz . fancycamera ?. posedetection ?. PoseDetection ) ;
2121
22- export { BarcodeFormats , barcodeFormatsProperty , CameraPosition , cameraPositionProperty , DetectionType , faceDetectionMinFaceSizeProperty , faceDetectionPerformanceModeProperty , faceDetectionTrackingEnabledProperty , imageLablerConfidenceThresholdProperty , objectDetectionClassifyProperty , objectDetectionMultipleProperty } from './common' ;
22+ export { BarcodeFormats , barcodeFormatsProperty , CameraPosition , cameraPositionProperty , DetectionType , faceDetectionMinFaceSizeProperty , faceDetectionPerformanceModeProperty , faceDetectionTrackingEnabledProperty , imageLabelerConfidenceThresholdProperty , objectDetectionClassifyProperty , objectDetectionMultipleProperty } from './common' ;
2323
2424export class MLKitView extends MLKitViewBase {
2525 #camera: io . github . triniwiz . fancycamera . FancyCamera ;
2626 static #hasCamera: boolean ;
27- #onDetection: ( data : { [ key : string ] : any } ) => void ;
2827 #onTextListener: io . github . triniwiz . fancycamera . ImageAnalysisCallback ;
2928 #onBarcodeListener: io . github . triniwiz . fancycamera . ImageAnalysisCallback ;
3029 #onDigitalInkListener: io . github . triniwiz . fancycamera . ImageAnalysisCallback ;
@@ -87,11 +86,9 @@ export class MLKitView extends MLKitViewBase {
8786 return this . #hasCamera;
8887 }
8988
90- //@ts -ignore
91- set onDetection ( value ) {
92- this . #onDetection = value ;
89+ [ onDetectionProperty . setNative ] ( value ) {
9390 const ref = new WeakRef ( this ) ;
94- if ( ! this . #onTextListener && ( this . dectectionType === DetectionType . Text || this . dectectionType === DetectionType . All ) ) {
91+ if ( ! this . #onTextListener && ( this . detectionType === DetectionType . Text || this . detectionType === DetectionType . All ) ) {
9592 this . #onTextListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
9693 onSuccess ( param0 : string ) {
9794 try {
@@ -105,7 +102,7 @@ export class MLKitView extends MLKitViewBase {
105102 this . #camera. setOnTextRecognitionListener ( this . #onTextListener) ;
106103 }
107104
108- if ( ! this . #onBarcodeListener && ( this . dectectionType === DetectionType . Barcode || this . dectectionType === DetectionType . All ) ) {
105+ if ( ! this . #onBarcodeListener && ( this . detectionType . includes ( DetectionType . Barcode ) || this . detectionType . includes ( DetectionType . All ) ) ) {
109106 this . #onBarcodeListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
110107 onSuccess ( param0 : string ) {
111108 try {
@@ -120,7 +117,7 @@ export class MLKitView extends MLKitViewBase {
120117 }
121118
122119 // todo
123- if ( ! this . #onDigitalInkListener && ( this . dectectionType === DetectionType . DigitalInk || this . dectectionType === DetectionType . All ) ) {
120+ if ( ! this . #onDigitalInkListener && ( this . detectionType === DetectionType . DigitalInk || this . detectionType === DetectionType . All ) ) {
124121 /* this.#onDigitalInkListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
125122 onSuccess(param0: string) {
126123 try {
@@ -133,7 +130,7 @@ export class MLKitView extends MLKitViewBase {
133130 }); */
134131 }
135132
136- if ( ! this . #onFaceListener && ( this . dectectionType === DetectionType . Face || this . dectectionType === DetectionType . All ) ) {
133+ if ( ! this . #onFaceListener && ( this . detectionType === DetectionType . Face || this . detectionType === DetectionType . All ) ) {
137134 this . #faceDetectionOptions = new io . github . triniwiz . fancycamera . facedetection . FaceDetection . Options ( ) ;
138135 this . #onFaceListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
139136 onSuccess ( param0 : string ) {
@@ -148,7 +145,7 @@ export class MLKitView extends MLKitViewBase {
148145 this . #camera. setOnFacesDetectedListener ( this . #onFaceListener) ;
149146 }
150147
151- if ( ! this . #onImageListener && ( this . dectectionType === DetectionType . Image || this . dectectionType === DetectionType . All ) ) {
148+ if ( ! this . #onImageListener && ( this . detectionType === DetectionType . Image || this . detectionType === DetectionType . All ) ) {
152149 this . #onImageListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
153150 onSuccess ( param0 : string ) {
154151 try {
@@ -162,7 +159,7 @@ export class MLKitView extends MLKitViewBase {
162159 this . #camera. setOnImageLabelingListener ( this . #onImageListener) ;
163160 }
164161
165- if ( ! this . #onObjectListener && ( this . dectectionType === DetectionType . Object || this . dectectionType === DetectionType . All ) ) {
162+ if ( ! this . #onObjectListener && ( this . detectionType === DetectionType . Object || this . detectionType === DetectionType . All ) ) {
166163 this . #onObjectListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
167164 onSuccess ( param0 : string ) {
168165 try {
@@ -176,7 +173,7 @@ export class MLKitView extends MLKitViewBase {
176173 this . #camera. setOnObjectDetectedListener ( this . #onObjectListener) ;
177174 }
178175
179- if ( ! this . #onPoseListener && ( this . dectectionType === DetectionType . Pose || this . dectectionType === DetectionType . All ) ) {
176+ if ( ! this . #onPoseListener && ( this . detectionType === DetectionType . Pose || this . detectionType === DetectionType . All ) ) {
180177 this . #onPoseListener = new io . github . triniwiz . fancycamera . ImageAnalysisCallback ( {
181178 onSuccess ( param0 : string ) {
182179 try {
@@ -191,7 +188,7 @@ export class MLKitView extends MLKitViewBase {
191188 }
192189
193190 let type = DetectorType_None ( ) ;
194- switch ( this . dectectionType ) {
191+ switch ( this . detectionType ) {
195192 case DetectionType . All :
196193 type = DetectorType_All ( ) ;
197194 break ;
@@ -219,14 +216,8 @@ export class MLKitView extends MLKitViewBase {
219216 }
220217
221218 this . #camera. setDetectorType ( type ) ;
222-
223- }
224-
225- get onDetection ( ) {
226- return this . #onDetection;
227219 }
228220
229-
230221 [ barcodeFormatsProperty . setNative ] ( value : BarcodeFormats [ ] ) {
231222 if ( ! BARCODE_SCANNER_SUPPORTED ( ) ) {
232223 return ;
0 commit comments