xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Enhancement] Open up the ShellSection Implementation on iOS #8428

Open ChasakisD opened 4 years ago

ChasakisD commented 4 years ago

Summary

There are a lot of cases where you want to use a custom NavigationViewController just like MaterialComponents one (MDCAppBarNavigationController) or AMScrollingNavbar's ScrollingViewController. Write now, to solve the problem, you have to copy the ShellSectionRenderer class with some other internal extension methods and just change 1 line of code, the base class. This should be done just like the other Renderers where on CreateNativeControl() you specify the the class of the control.

API Changes

Maybe a wrapper class or a factory in order to be able to create another implementations of UINavigationController.

Intended Use Case

There are a lot of goodies in MDCAppBarNavigationController, like the scrolling behavior that are missing from UINavigationController. By opening up the creation of UINavigationController, developers will be able to easily integrate a custom UINavigationController to their apps.

PureWeen commented 4 years ago

@ChasakisD does this PR address what you need?

https://github.com/xamarin/Xamarin.Forms/pull/8441

ChasakisD commented 4 years ago

@PureWeen I am not saying about the creation of the ShellSectionRootRenderer, but for changing the inheritance of ShellSectionRenderer from UINavigationController to lets say Material's AppBarNavigationController. Right now, if you want to change to another navigation controller, you have to copy and paste the ShellSectionRenderer and just replace the UINavigationController with AppBarNavigationController.

PureWeen commented 4 years ago

@ChasakisD aw ok I see what you're getting at

Yea, this will definitely become relevant as we ramp up Material Shell

This should be done just like the other Renderers where on CreateNativeControl() you specify the the class of the control.

The tricky part here is that on iOS all the normal renderers are wrapped by a parented UIView whereas ShellSectionRenderer inherits directly from UINavigationController so we'd need to move all the behavior out of the class into something that's reusable.

We do this on Android for all the renderers that inherit directly from components opposed to being wrapped by ViewGroups

I wish this was legal :-)

ShellSectionRendererBase : T where T is UINavigationController

ChasakisD commented 4 years ago

@PureWeen Didn't know about any plans for MaterialShell. Sorry for that. I am starting playing with MaterialComponents on iOS and they are pretty awesome. That's why I opened this issue.

Yeah that pattern that was applied on Android Renderers is going to make it very easy to integrate with other NavigationControllers, and as far the ShellNavBarAppearanceTracker is also open, it will be very easy to customize the MaterialComponents' AppBar!

PureWeen commented 4 years ago

@ChasakisD

Didn't about any plans for MaterialShell. Sorry for that. I am starting playing with MaterialComponents on iOS and they are pretty awesome. That's why I opened this issue.

We haven't started work on it but it's on the road map. I'm going to elevate this issue here on my queue of things though see if I can get this exposed how you want

If you're working on integrating Material things into Shell I'd really like to make that as easy as I can for you!!

PureWeen commented 4 years ago

@ChasakisD have you done an implementation with Shell and MDCAppBarNavigationController ?