private static void InitNavigation() { var navigation = RootPage.Navigation; RootPage.Subscribe <NavigateBackMessage>(async delegate { await navigation.PopAsync(); }); RootPage.Subscribe <NavigateToPageMessage>( message => { navigation.PushAsync(message.Page, true); }); RootPage.Subscribe <LoginSuccess>(async message => { var pageToNaviagte = message.FirstTimeLogin ? ViewFactory <PreferencesPage, PreferencesViewModel> .CreatePage() as Page : ViewFactory <HomePage, HomeViewModel> .CreatePage(); await navigation.PopToRootAsync(); await navigation.PushAsync(pageToNaviagte, true); }); RootPage.Subscribe <LoginCanceled>(async message => { await navigation.PushAsync(new WelcomePage()); }); RootPage.Subscribe <LoginFailed>( async(x) => { await RootPage.DisplayAlert("Login failed", "Login failed !", "Ok"); }); RootPage.Subscribe <LogoutSuccess>(message => { navigation.PopToRootAsync(true); }); }
private static void InitNavigation() { var navigation = RootPage.Navigation; RootPage.Subscribe <NavigateBackMessage>(async delegate { await navigation.PopAsync(); }); RootPage.Subscribe <NavigateToPageMessage>( async message => { if (message.IsModal) { await navigation.PushModalAsync(message.Page, true); return; } await navigation.PushAsync(message.Page, true); }); RootPage.Subscribe <NavigateToSettingsPage>(async message => await navigation.PushAsync(message.Page, true)); RootPage.Subscribe <LoginSuccess>(async message => { if (CurrentUserProfile == null) { await navigation.PopToRootAsync(); RootPage.Publish(new NavigateToSettingsPage()); return; } await navigation.NavigateToPage <HomePage, HomeViewModel>(); }); RootPage.Subscribe <LoginCanceled>(async message => { await navigation.PushAsync(new WelcomePage()); }); RootPage.Subscribe <LoginFailed>( async(x) => { await RootPage.DisplayAlert("Login failed", "Login failed !", "Ok"); }); RootPage.Subscribe <LogoutSuccess>(async message => { await navigation.NavigateToPage <WelcomePage, WelcomeViewModel>(); }); RootPage.Subscribe <CloseModal>(async message => { await navigation.PopModalAsync(true); }); RootPage.Subscribe <NavigateToHomePage>(async message => { await navigation.NavigateToPage <HomePage, HomeViewModel>(); }); RootPage.Subscribe <ShowLoading>(async message => { var loadingPage = new Loading(); await navigation.PushModalAsync(loadingPage, true); }); RootPage.Subscribe <HideLoading>(async message => { await navigation.PopToRootAsync(true); }); }