unoplatform / uno.extensions

Libraries to ease common developer tasks associated with building multi-platform mobile, desktop and web applications using Uno Platform or WinAppSDK.
https://platform.uno/
Other
73 stars 47 forks source link

[iOS] [Reactive] [Navigation] Sending message to ListState won't update values after navigation #2123

Closed mcocaroUX closed 9 months ago

mcocaroUX commented 9 months ago

Current behavior

Currently I'm ussing IMessenger to update some values on my app. After navigating forward and then the ListState no longer reacts to the update messages.

Expected behavior

ListState should update values on ListState

How to reproduce it (as minimally and precisely as possible)

1 - Run app 2 - Press Update flag button and notice how Item 1 gets updated (red square visibility changes) 3 - Navigate to second page 4 - Go back 5 - Press Update flag button and notice how it now it wont update iosIssue.zip

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

Visual Studio:

Relevant plugins:

Anything else we need to know?

dr1rrb commented 9 months ago

Hey @mcocaroUX thanks for the report.

I investigated it, the issue is not about the ListState, it's actually an issue with the ItemsRepeater. Replacing it by an ItemsControl in your sample does fix the issue:

<ItemsControl ItemsSource="{Binding Data}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" />
                <Rectangle Height="20"
                                     Width="20"
                                     Visibility="{Binding Flag}"
                                     Fill="Red"/>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Will continue investigation on it, but it could be a viable workaround for the issue (it should also work with a ListView if you need virtualization).

johnkattenhorn commented 9 months ago

Hey @mcocaroUX - does this workaround work for us ?

nickrandolph commented 9 months ago

@dr1rrb can this be backported?

mcocaroUX commented 9 months ago

@johnkattenhorn It won't, we also need to be able to navigate when taping an item. ItemsControl doesn't seem to work with navigation extension

johnkattenhorn commented 9 months ago

@nickrandolph, @dr1rrb - do you know if we could run this as source from our project temporarily until the next release cycle ? /

dr1rrb commented 9 months ago

@johnkattenhorn I've backported it on 5.0 (https://github.com/unoplatform/uno/pull/15106), the build should available on nuget soon (BTW you can already test it by using any dev version published on nuget in the last 5 days)

johnkattenhorn commented 9 months ago

Thanks @dr1rrb - @mcocaroUX - does this give you what you need to move forward ?

mcocaroUX commented 9 months ago

@dr1rrb So I updated the package and I don't think its completley fixed. I see now it updates the item but only when you are on the same page as the ItemsRepeater. If you are in other page and send a message update, when you return to the page containing the ItemsRepeater item is not updated