11import { Component , NgZone } from "@angular/core" ;
22import { RouterExtensions } from "nativescript-angular" ;
3- import { ImageSource } from "tns-core-modules/image-source" ;
3+ import { fromFile , ImageSource } from "tns-core-modules/image-source" ;
4+ import * as fileSystemModule from "tns-core-modules/file-system" ;
45import { action } from "tns-core-modules/ui/dialogs" ;
56import { ImageAsset } from "tns-core-modules/image-asset" ;
67import { isIOS } from "tns-core-modules/platform" ;
@@ -81,6 +82,18 @@ export class MLKitComponent {
8182 } ) ;
8283 }
8384
85+ fromAppFolder ( ) : void {
86+ const folder = fileSystemModule . knownFolders . currentApp ( ) ;
87+ const path = fileSystemModule . path . join ( folder . path , "/images/puppy.jpg" ) ;
88+ const exists = fileSystemModule . File . exists ( path ) ;
89+ console . log ( `Does it exist: ${ exists } ` ) ;
90+
91+ const imageSource = fromFile ( path ) ;
92+ this . pickedImage = imageSource ;
93+ // give the user some time to to see the picture
94+ setTimeout ( ( ) => this . selectMLKitFeature ( imageSource ) , 500 ) ;
95+ }
96+
8497 fromCameraPicture ( ) : void {
8598 if ( ! isIOS ) {
8699 Camera . requestPermissions ( ) ;
@@ -94,7 +107,7 @@ export class MLKitComponent {
94107 } ) . then ( imageAsset => {
95108 new ImageSource ( ) . fromAsset ( imageAsset ) . then ( imageSource => {
96109 this . pickedImage = imageSource ;
97- // give the user some to to see the picture
110+ // give the user some time to to see the picture
98111 setTimeout ( ( ) => this . selectMLKitFeature ( imageSource ) , 500 ) ;
99112 } ) ;
100113 } ) ;
@@ -133,7 +146,7 @@ export class MLKitComponent {
133146 this . zone . run ( ( ) => {
134147 this . pickedImage = imageSource ;
135148 } ) ;
136- // give the user some to to see the picture
149+ // give the user some time to to see the picture
137150 setTimeout ( ( ) => this . selectMLKitFeature ( imageSource ) , 500 ) ;
138151 } ) ;
139152 } )
0 commit comments