Hi All!
I use Xamarin Forms and freshmvvm. I have a login page, after login I push next page, let's say Page1, which I'd like to be root from now on. So after navigation to a few other pages I'd like to be able to get back to Page1, calling CoreMethods.PopToRoot. When logging out, I'd like to go back to login page and clear all the navigations stacks. This is what I tried so far:
public class NavigationStacks
{
public static string LoginNavigationStack = "LoginNavigationStack";
public static string MainAppStack = "MainAppStack";
}
public App()
{
var page = FreshPageModelResolver.ResolvePageModel();
var basicNavContainer = new FreshNavigationContainer(page, NavigationStacks.LoginNavigationStack);
var page2 = FreshPageModelResolver.ResolvePageModel<CustomerSearchPageModel>(); var appNavContainer = new FreshNavigationContainer(page2, NavigationStacks.MainAppStack); MainPage = basicNavContainer;
}
After login, I call:
CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
await CoreMethods.PushPageModel();
And it works. I'm back on Page1 and can't get back to login page.
On logout I call:
CoreMethods.SwitchOutRootNavigation(NavigationStacks.LoginNavigationStack);
But nothing happens. I'd like to be navigates back to login page with navigation stack cleared. I believe I miss something. Can anyone help? Thanks in advance!!
Krzysztof