FreshMvvm
FreshMvvm copied to clipboard
Open modal page from tab
Hello,
I'm trying to figure out how to open a modalpage from a tab in a tabbedpage using FreshTabbedNavigationContainer. what's the preferred way to override the default navigation to make support for this?
best regards
You should be able to do this directly from one of the page models, without touching a navigation container. Or did u want to do something different?
On Friday, 30 September 2016, rasmuschristensen [email protected] wrote:
Hello,
I'm trying to figure out how to open a modalpage from a tab in a tabbedpage using FreshTabbedNavigationContainer. what's the preferred way to override the default navigation to make support for this?
best regards
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rid00z/FreshMvvm/issues/109, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeXvYsKTG6_l8IwJxyJtUgLcF6joPfoks5qvRB_gaJpZM4KLF_0 .
Michael Ridland | Technical Director | Xamarin MVP
XAM Consulting - Mobile Technology Specialists
www.xam-consulting.com
Blog: www.michaelridland.com
I have 5 tabs, and I want one of them to open a modal page, meaning the tabbed navigation bar is hidden.
Just push a page model as modal, you can also push a new navigation container as modal.
Thanks
On Saturday, 1 October 2016, rasmuschristensen [email protected] wrote:
I have 5 tabs, and I want one of them to open a modal page, meaning the tabbed navigation bar is hidden.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rid00z/FreshMvvm/issues/109#issuecomment-250823394, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeXvVSygsi5KmlZjl8sB0qNOSGNlgSaks5qvVnWgaJpZM4KLF_0 .
Michael Ridland | Technical Director | Xamarin MVP
XAM Consulting - Mobile Technology Specialists
www.xam-consulting.com
Blog: www.michaelridland.com
Hi Michael,
How would you do that on the tab itself? I've added this image as an example from instagram. When the center button is tabbed, something different happens. I my case I want a modal page to appear. But as I'm currently using the FreshTabbed navigation container, I add the PageModels. I can see from the source there is a modal method, but not sure how to trigger it from the tab.
You call it from a PageModel that is a child of the tab container. Call CoreMethods.PushPageModel with modal.
There's some samples in the git repo.
On Sunday, 2 October 2016, rasmuschristensen [email protected] wrote:
Hi Michael,
How would you do that on the tab itself? I've added this image as an example from instagram. When the center button is tabbed, something different happens. I my case I want a modal page to appear. But as I'm currently using the FreshTabbed navigation container, I add the PageModels. I can see from the source there is a modal method, but not sure how to trigger it from the tab. [image: screen shot 2016-10-01 at 23 08 29] https://cloud.githubusercontent.com/assets/1743614/19017029/251f7afe-882c-11e6-8fbd-ab8049f0f3b7.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rid00z/FreshMvvm/issues/109#issuecomment-250937907, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeXvTlWNisgbV0nJ1WLIhEkgkdRwbzpks5qvsyWgaJpZM4KLF_0 .
Michael Ridland | Technical Director | Xamarin MVP
XAM Consulting - Mobile Technology Specialists
www.xam-consulting.com
Blog: www.michaelridland.com
Hi Michael,
I went through the samples. So far my best idea would be to inherit the tab container and do some check when navigation tabs. Is this what you mean?
Ok, so now I understand you want to push modal when one of the tabs are tapped, yes you would need to inherit the tab container. You could do this as a feature with a PR.
On Wednesday, 5 October 2016, rasmuschristensen [email protected] wrote:
Hi Michael,
I went through the samples. So far my best idea would be to inherit the tab container and do some check when navigation tabs. Is this what you mean?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rid00z/FreshMvvm/issues/109#issuecomment-251412204, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeXvUMLtXv7tM5QYD3Rco0pBZDxbANKks5qwmiQgaJpZM4KLF_0 .
Michael Ridland | Technical Director | Xamarin MVP
XAM Consulting - Mobile Technology Specialists
www.xam-consulting.com
Blog: www.michaelridland.com
Super, will look into it hopefully this week.
@rid00z I'd like to help out on this one as I have the same requirement. If I get something working I can do a pull request. I need the tabbed navigation container button to directly add a modal to the stack that in turn hides the tabs as well.
What would you envision the solution be here? Adding a method to FreshTabbedNavigationContainer named AddTabModal or something? Just looking for initial direction.
Ok I think I got this working actually. I had to create my own TabbedNavigationContainer, so for example MyAppTabbedNavigationContainer. The implementation can be essentially the same as the one provided by FreshMvvm (FreshTabbedNavigationContainer).
The main changes here are that you need to wire up the OnCurrentPageChanged in the constructor:
this.CurrentPageChanged += OnCurrentPageChanged;
and then in the handler put in your custom logic to launch a modal.
private void OnCurrentPageChanged(object sender, EventArgs e)
{
var navPage = CurrentPage as NavigationPage;
if (navPage?.Pages.FirstOrDefault() is CameraSearchPlaceholderPage)
{
var page = FreshPageModelResolver.ResolvePageModel<CameraSearchPageModel>();
page.GetModel().CurrentNavigationServiceName = NavigationServiceName;
Navigation.PushModalAsync(page, true)
.ConfigureAwait(false);
}
}
The handler isn't an async method but it seems the PushModalAsync gets executed immediately. Not sure if this is incorrect from a coding perspective but it seems to work. Perhaps it should be wrapped in some type of async anonymous method or something else. Not sure. Feedback appreciated.