Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Working but NO Image #71

Open
mrzanirato opened this issue Jul 28, 2020 · 11 comments
Open

UI Working but NO Image #71

mrzanirato opened this issue Jul 28, 2020 · 11 comments

Comments

@mrzanirato
Copy link

Hello,

the plugin seems to work correctly but I receive some errors and no image in console.log

CONSOLE LOG file: node_modules/@nativescript/core/ui/frame/frame-common.js:581:0: topmost() is deprecated. Use Frame.topmost() instead.
CONSOLE LOG file: node_modules/@nativescript/core/image-source/image-source.ios.js:344:0: fromNativeSource() is deprecated. Use ImageSource constructor instead.
CONSOLE LOG file: node_modules/@nativescript/core/image-source/image-source.ios.js:314:0: fromAsset() is deprecated. Use ImageSource.fromAsset() instead.
CONSOLE LOG file: src/app/modals/image/image.component.ts:49:28: {
"response": "Success",
"image": {
"ios": {}
}

Can you help, please?
Thanks

Marco

@shiv19
Copy link
Collaborator

shiv19 commented Jul 29, 2020

Hi Marco,
that is the expected log output when you log the response from this plugin.
The image object can't be displayed in the console. And what you've sent there is exactly what is expected to be printed to console.

@shiv19
Copy link
Collaborator

shiv19 commented Jul 29, 2020

https://github.com/bthurlow/nativescript-imagecropper/blob/master/service-example/image-upload-service.js
this file has a good example of how the response from this plugin can be used.
I'm currently using the exact same code with the latest version of nativescript :)

@mrzanirato
Copy link
Author

Thanks for you super fast reply and the great plugin!

@mrzanirato
Copy link
Author

I am trying the code you suggested, but I get some errors
Can you help, please?
Schermata 2020-07-29 alle 09 07 51

@shiv19
Copy link
Collaborator

shiv19 commented Jul 29, 2020

since you're using typescript, you'll have to declare those variables outside the constructor before using them.

so below the line export class ImageUploadService...
you can add

static _instance: ImageUploadService;
_imageCropper: any;

@mrzanirato
Copy link
Author

Fantastic!
And the last one
Schermata 2020-07-29 alle 09 31 47

@shiv19
Copy link
Collaborator

shiv19 commented Jul 29, 2020

image
You can see here that I'm unboxing the selection before using it.

looking at your core you're doing const selection = await ...

so you can do

if (selection && selection[0]) {
 selection[0].getImageAsync(...

@mrzanirato
Copy link
Author

Thanks shiv19, I'm getting closer ... now I can open the gallery, choose an image, crop, and start uploading.
In console log I can see the image name , the folder.
Now I have a problem I think referencing the image reference on page.

I get this error:

CONSOLE LOG file: node_modules/@angular/core/fesm5/core.js:26256:0: TypeError: undefined is not an object (evaluating 'nativescript_core_ui_frame__WEBPACK_IMPORTED_MODULE_5_["Frame"].getFrameById('rootFrame').currentPage')

Schermata 2020-07-29 alle 12 21 36

Thanks again

@mrzanirato
Copy link
Author

OK I managed to upload the image on the server.
Now I have to figure out how to reference the image and change the src
shiv19, thanks again for your time, your work and your help!
Marco

@mrzanirato
Copy link
Author

It seems that in Angular I can't use getViewById but instead I should use something like

@ViewChild('profilePic',{static: false}) private profilePic: ElementRef

Any suggestion?

Thanks again
Marco

@shiv19
Copy link
Collaborator

shiv19 commented Sep 21, 2020

yes you can use view child method and then do something like this.profilePic.nativeElement to access the {N} widget :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants