triniwiz / nativescript-plugins

Apache License 2.0
80 stars 50 forks source link

Image is not showing #69

Open Whip opened 3 years ago

Whip commented 3 years ago

Which platform(s) does your issue occur on?

Android 11 real device

Please, provide the following version numbers that your issue occurs with:

I don't understand what's wrong with this. The URL is fine and I do see the image if I manually put the URL in the src field. But when using a viewModel or even setting it like on lIne 16, the image doesn't appear. This is in a modal if that makes a difference.

XML

<Page shownModally="onShowModally" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:ui="@triniwiz/nativescript-image-zoom">
  <StackLayout>
    <ui:ImageZoom  src="{{ image }}" id="imageEl" loaded="onLoaded" aspectFill="stretch" width="200" height="200" />
  </StackLayout>
</Page>

JS

import { fromObject } from '@nativescript/core';

var page,
    viewModel = new fromObject({
        image: null,
    }),
    closeCallback;

export function onShowModally(args) {
    page = args.object;
    closeCallback = args.closeCallback;
    viewModel.image = args.context[0].image;
        page.bindingContext = viewModel;

  let imageEl = page.getViewById('imageEl');
  imageEl.src = viewModel.image;
}

export function onLoaded(){
    console.log('image loaded'); //works
}
export function closeModal(){
    closeCallback();
}
triniwiz commented 3 years ago

Have you tried called using .set on the view model another thing what is src type you trying to set .eg image asset, string

Whip commented 3 years ago

Yes that doesn't work either. Its a URL string that goes in the viewModel. That is correctly being set because I tried outputting it into a Label and it works.

Whip commented 3 years ago

@triniwiz Are you looking into this? My app update is getting delayed because of this?