/// <summary> /// Initializes a new instance of the <see cref="App"/> class. /// </summary> /// <param name="model"> /// The model. /// </param> public App(IApplicationModel model) { this.InitializeComponent(); ApplicationVm viewModel = new ApplicationVm(model); NavigationPage navigationPage = new NavigationPage(); this.MainPage = navigationPage; MasterDetailPage master = new MasterDetailPage() { Master = new SettingsView() { BindingContext = viewModel }, Detail = new DateView() { BindingContext = viewModel } }; master.SetBinding(Page.TitleProperty, "Title"); master.BindingContext = master.Detail; navigationPage.PushAsync(master); }
public static void NavigateToHomePage() { try { var detailPage = AppAutoFac.ResolvedIViewFactory.Resolve <MainPageViewModel>(); var masterDetails = new MasterDetailPage { Master = AppAutoFac.ResolvedIViewFactory.Resolve <MenuPageViewModel>(), Detail = new NavigationPage(detailPage) { BarTextColor = Color.Black } }; masterDetails.SetBinding(MasterDetailPage.IsPresentedProperty, "IsPresented", BindingMode.TwoWay); masterDetails.BindingContext = AppAutoFac.Resolve <MasterDetailPageViewModel>(); Application.Current.MainPage = masterDetails; } catch (Exception e) { } }
public App() { FlowListView.Init(); GatewayApi.Instance.ExpiredAccessToken += async(object sender, EventArgs e) => { var localEnvironments = await LocalDbHelper.Instance.GetAllSavedEnvironmentsAsync(); BlockchainEnvironment environment = localEnvironments[0]; var authService = ServiceContainer.Resolve <IAuthentication>(); var loginResponse = await authService.LoginAsync( $"https://login.windows.net/{environment.TenantId}", environment.ResourceId, environment.ClientId, environment.ReturnUrl, isRefresh : true); if (loginResponse != null) { AppCenterHelper.TrackEvent("Refreshed Token", new Dictionary <string, string>() { { "username", loginResponse.Profile.DisplayableId } }); Settings.AccessToken = loginResponse.AccessToken; GatewayApi.Instance.SetAuthToken(loginResponse.AccessToken); #if DEBUG Settings.AccessTokenExpiration = new DateTimeOffset(DateTime.Now.AddMinutes(2)); GatewayApi.Instance.AccessTokenExpiration = new DateTimeOffset(DateTime.Now.AddMinutes(2)); #else Settings.AccessTokenExpiration = loginResponse.ExpiresOn; GatewayApi.Instance.AccessTokenExpiration = loginResponse.ExpiresOn; #endif } else { App.Logout(false); } }; GatewayApi.Instance.ExceptionThrown += async(object sender, Exception e) => { AppCenterHelper.Report(e, new Dictionary <string, string>() { { "baseurl", GatewayApi.SiteUrl } }); }; ViewModel = new AppViewModel(); backgroundPage = new BackgroundPage(); var navPage = new Xamarin.Forms.NavigationPage(backgroundPage); var detailNavPage = new Xamarin.Forms.NavigationPage(new ApplicationsPage()); ContractsPage = new WorklfowInstanceListPage(); navPage.BarBackgroundColor = Constants.NavBarBackgroundColor; navPage.BarTextColor = Constants.NavBarTextColor; detailNavPage.BarBackgroundColor = Constants.NavBarBackgroundColor; detailNavPage.BarTextColor = Constants.NavBarTextColor; Master = new MasterDetailPage { BindingContext = ViewModel }; Master.IsPresentedChanged += (object sender, EventArgs e) => { var mdp = sender as MasterDetailPage; if (mdp.IsPresented) { ((Xamarin.Forms.NavigationPage)mdp.Detail) .On <iOS>() .SetStatusBarTextColorMode(StatusBarTextColorMode.DoNotAdjust); } else { ((Xamarin.Forms.NavigationPage)mdp.Detail) .On <iOS>() .SetStatusBarTextColorMode(StatusBarTextColorMode.MatchNavigationBarTextLuminosity); } }; Master.Master = new MasterPage { BindingContext = ViewModel }; Master.Detail = detailNavPage; Master.SetBinding(MasterDetailPage.IsPresentedProperty, nameof(AppViewModel.MenuPresented), BindingMode.TwoWay); Xamarin.Forms.NavigationPage.SetHasNavigationBar(detailNavPage, false); try { MainPage = navPage; } catch (Exception e) { AppCenterHelper.Report(e); } }