GiampaoloGabba / Xamarin.Plugin.SharedTransitions

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

SharedTransition Tabbed page within MasterDetail page #30

Closed alexgg94 closed 4 years ago

alexgg94 commented 4 years ago

Hi, I'm using the sample app (TransitionApp) to try out different scenarios. Now I'm trying to work with a Tabbed page within a MasterDetail page. I have modified the MainMasterDetailPage file changing the Detail page:

`<?xml version="1.0" encoding="utf-8" ?> <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:prism="http://prismlibrary.com" xmlns:sharedTransitions="clr-namespace:Plugin.SharedTransitions;assembly=Plugin.SharedTransitions" xmlns:views="clr-namespace:TransitionApp.Views;assembly=TransitionApp" xmlns:image="clr-namespace:TransitionApp.Views.Image;assembly=TransitionApp" xmlns:main="clr-namespace:TransitionApp.Views.Main;assembly=TransitionApp" x:Class="TransitionApp.Views.Main.MainMasterDetailPage">

<MasterDetailPage.Master>
    <ContentPage Title="Menu">
        <StackLayout Padding="20" VerticalOptions="Center">

            <Button Text="Images" Command="{prism:NavigateTo 'SharedTransitionNavigationPage/ImageFromPage'}" />
            <Button Text="Layouts" Command="{prism:NavigateTo 'SharedTransitionNavigationPage/LayoutFromPage'}" />
            <Button Text="Listview" Command="{prism:NavigateTo 'SharedTransitionNavigationPage/ListViewFromPage'}" />
            <Button Text="Collectionview" Command="{prism:NavigateTo 'SharedTransitionNavigationPage/CollectionviewFromPage'}" />
            <Button Text="Back to main Home" Command="{prism:NavigateTo '/HomePage'}" />
        </StackLayout>
    </ContentPage>
</MasterDetailPage.Master>

<!--<MasterDetailPage.Detail>
    <main:MainTabbedPage/>
</MasterDetailPage.Detail>-->

<MasterDetailPage.Detail>
    <sharedTransitions:SharedTransitionNavigationPage>
        <x:Arguments>
            <main:MainTabbedPage/>
        </x:Arguments>
    </sharedTransitions:SharedTransitionNavigationPage>
</MasterDetailPage.Detail>

`

(MainTabbedPage has not been modified) But this is not working even if I put the MainTabbedPage within a SharedTransitionNavigationPage. Am I doing something wrong?

Thanks

GiampaoloGabba commented 4 years ago

For this to work, you have to put the tabbedpage's tabs inside a SharedTransitionNavigationPage, just like in the Tab example in the Sample App.

A TabbedPage is only a container of pages and the navigation occour inside tabs.

In conclusion, you should modify your <main:MainTabbedPage/> to encapsulate the tabs that need transitions inside a SharedTransitionNavigationPage, something like this

alexgg94 commented 4 years ago

Yes, that's what I'm doing.

<> refrences https://github.com/GiampaoloGabba/Xamarin.Plugin.SharedTransitions/blob/master/src/Sample/TransitionApp/TransitionApp/Views/Main/MainTabbedPage.xaml

It's exactly the same project but I only modified the MasterDetailPage as I stated above

GiampaoloGabba commented 4 years ago

awww sorry, didn't recognize that the example you posted is from my SampleApp :)

Well, i never tried to put a TabbedPage inside a MasterDetails, in theory this should works:

<MasterDetailPage.Detail>
    <main:MainTabbedPage/>
</MasterDetailPage.Detail>

i will try to diagnose whats going on here

GiampaoloGabba commented 4 years ago

Ok i found the culprit: in iOS TabbedPage inside MasterDetail is working. In Android the issue is the FragmentManager and relative ChildFragmentManager. Using TabbedPage inside MasterDetail create another level of ChildFragmentManager and the plugin is unable to read it for now.

I need a new way to find the right FragmentManager for the current page