GiampaoloGabba / Xamarin.Plugin.SharedTransitions

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

Custom renderer for SharedTransitionShell #34

Closed conor-codes closed 2 years ago

conor-codes commented 4 years ago

Hello,

I've been working through the sample solution and have created a project that transitions between pages correctly, I need to create a custom renderer to alter the appearance of the app shell. Is it possible to extend the SharedTransitionShell? Everything I've tried has failed to recognise the custom renderer, works fine when extending the base shell component just not the SharedTransitionShell.

Any help would be appreciated, Thanks :)

GiampaoloGabba commented 3 years ago

hello, umm this is strange, you should be able to extend the SharedTransitionShellRenderer without issues.

Please note that SharedTransitionShell is not the renderer, it is the xamarin.forms class that enable the shared transitions on shell. This class, then, calls the renderer in the platform specific code.

For example, in iOS you should be able to extend the renderer like this:

using Plugin.SharedTransitions;
using Plugin.SharedTransitions.Platforms.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly:ExportRenderer(typeof(SharedTransitionShell), typeof(CustomShellRenderer))]
namespace Plugin.SharedTransitions.Platforms.iOS
{
    public class CustomShellRenderer: SharedTransitionShellRenderer
    {

           ..... your code here

    }
}

just be while overriding the CreateShellSectionRenderer, be sure to call the base.CreateShellSectionRenderer(shellSection) at the end of the method or transitions will not work.

RGBPlaza commented 3 years ago

I had the same problem but it works fine when setting the first parameter of ExportRendererAttribute to AppShell (or equivalent) which is good enough for me!

GiampaoloGabba commented 3 years ago

I had the same problem but it works fine when setting the first parameter of ExportRendererAttribute to AppShell (or equivalent) which is good enough for me!

Thanks! Yes, as long as you extend SharedTransitionShellRenderer in your custom renderer you can export to AppShell and should works!