-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[XF] Introduce a Behavior factory into the navigation service #1099
Comments
@powerdude I believe the functionality that you're looking for can already be accomplished by implementing a custom protected override void ApplyPageBehaviors(Page page)
{
base.ApplyPageBehaviors(page);
// Add any additional behaviors
} |
@dansiegel , yes, it is possible there, but thought it would be more explicit to call out the functionality separately. There's a lot going on in that class and it does more than navigation and should probably rely on other, more specialized services to help it do what it does. |
This is something that has been discussed in the past, but hasn't had any traction because it is not very common and can be accomplished by deriving from PageNavigationService like Dan suggested. If you would like to talk about a design and put a preliminary PR together for what you had in mind, that would be great. |
I worked on a branch with this new abstraction, but I'm not sure if it is worth it or not. If I pull this out into an IPageBehaviorFactory we will have to rely on reflection in order to determine if the page type is the target type or a derived type in order to properly apply the behaviors. Reflection means performance hit. This code would invoke for every page created. Essentially we would have this class
Then you can register your behaviors in the Prism Application:
Thoughts? |
I am closing this as there has not been a community response in a month. |
After thinking about this some more I believe that this would actually be a good addition. While you could override public interface IPageBehaviorsFactory
{
void ApplyPageBehaviors(Page page);
}
// this then simplifies registration
Container.Register<IPageBehaviorsFactory, PrismPageBehaviorsFactory>(Reuse.Singleton); With the addition of Dynamic Tab Creation, it will also be more common to generically register a TabbedPage as well as a NavigationPage. This means that there are going to be use cases where you simply want to add a PlatformSpecific. There shouldn't be a need to add a custom TabbedPage for example just to add some platform specific property. public void ApplyPageBehaviors(Page page)
{
// Apply Prism Behaviors
base.ApplyPageBehaviors(page);
switch(page)
{
case TabbedPage tabbed:
AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(tabbed, true);
macOSSpecific.TabbedPage.SetTabsStyle(tabbed, TabsStyle.Icons);
break;
case NavigationPage navPage:
iOSSpecific.NavigationPage.SetIsNavigationBarTranslucent(navPage, true);
macOSSpecific.NavigationPage.SetNavigationTransitionPushStyle(navPage, NavigationTransitionStyle.SlideUp);
}
} |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'd like to try to tease apart the behavior injection inside the navigation service and introduce an IBehaviorFactory, or IPageFactory, so that it can be a bit easier to override or add additional functionality when standard XF pages are created.
The text was updated successfully, but these errors were encountered: