GiampaoloGabba / Xamarin.Plugin.SharedTransitions

Shared Element Transitions between pages in Xamarin.Forms (IOS/Android)
MIT License
414 stars 57 forks source link

Shell : PopToRootAsync crashes - No view found for id #51

Closed MakerMarty closed 3 years ago

MakerMarty commented 3 years ago

Hi,

I think I found an issue with your plugin. When I use the Shell with PopToRootAsync() method, an unhandled exception is thrown.

I use the sample project in your github repo and I only add a button on navigated page (ImageSampleTo.xaml). I call Navigation.PopToRootAsync() when I click on this button, I have the exception.

Please see the bug detailed bellow and let me know if you need more information.

Thanks for your help.

Bug Information

Version Number of Plugin: 2.30 Device Tested On: Simulator Tested On: Simulator Android Pixel 2 Pie 9.0 (API 28) Version of VS: Microsoft Visual Studio Professional 2019 - Version 16.7.2 Version of Xamarin: 4.6.0.1141

Steps to reproduce the Behavior

I use the defaut sample projet and into the ImageSampleTo.Xaml, I add button with click execute PopToRootAsync.

Expected Behavior

Go the the root page

Actual Behavior

Exception unhandled : Java.Lang.IllegalArgumentException: 'No view found for id 0x2 (unknown) for fragment ShellFragmentContainer{1fe5070 #0 id=0x2 android:switcher:2:664218702}'

Code snippet

ImageSampleTo.xaml

<ContentPage  xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:sharedTransitions="clr-namespace:Plugin.SharedTransitions;assembly=Plugin.SharedTransitions"
             x:Class="TransitionShellApp.Views.ImageSampleTo" Title="Image sample">
    <ScrollView>
        <StackLayout Spacing="20" Padding="10">
            <Image Source="what_the_dog.jpg" sharedTransitions:Transition.Name="WhatTheDog" HeightRequest="250" />
            <!-- Changed aspect proportion -->
            <Image Source="christmas_dog.jpg" sharedTransitions:Transition.Name="ChristmasDog" WidthRequest="330" HeightRequest="150" Aspect="Fill" />
            <Image Source="cute_dog.jpg" sharedTransitions:Transition.Name="CuteDog" />

            <Button Text="PopToRoot" Clicked="Button_Clicked"/>
        </StackLayout>
    </ScrollView>
</ContentPage>

ImageSampleTo.xaml.cs

namespace TransitionShellApp.Views
{
    public partial class ImageSampleTo : ContentPage
    {
        public ImageSampleTo()
        {
            InitializeComponent();
        }
        private async void Button_Clicked(object sender, EventArgs e)
        {
            await Navigation.PopToRootAsync();
        }
    }
}
GiampaoloGabba commented 3 years ago

Hello, this should be fixed in the next version wich is coming very soon. I just have to check it in the new code.

FYI the new versions of XF have broken hard my plugin with shell, expecially in ios, the new version has been delayed a bit because of this

MakerMarty commented 3 years ago

Ok. Great ! Thanks for you help. I'm looking forward to the latest version ☺️