public virtual void AddPage(string modelName, object data = null) { var viewModelType = Type.GetType(modelName); Page page = ViewModelResolver.ResolveViewModel(viewModelType, data); AddPagesToDictionary(page); }
private async void OnSyncCompleted() { IsBusy = false; try { AppSettings.ReloadSetting(); SyncHelper.Instance.StartAutoSync(15); } catch (Exception ex) { await CoreMethods.DisplayAlert(TranslateExtension.GetValue("error"), ex.Message, TranslateExtension.GetValue("error")); Debug.WriteLine("ERROR:" + ex.Message); } //TODO find out reason if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) { if (CrossDeviceInfo.Current.VersionNumber.Major >= 13) { Application.Current.MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Login.LoginViewModel>()) { BarBackgroundColor = Color.FromHex("#2196F3"), BarTextColor = Color.White }; return; } } Application.Current.MainPage = new MainPage(); }
public App() { InitializeComponent(); Init(); AppSettings.ReloadSetting(); AssetsExtension.InitAssetsExtension("AppResources.Assets", typeof(App).GetTypeInfo().Assembly); ImageResourceExtension.InitImageResourceExtension("AppResources.Assets", typeof(App).GetTypeInfo().Assembly); TranslateExtension.InitTranslateExtension("AppResources.Localization.Resources", CultureInfo.CurrentCulture, typeof(App).GetTypeInfo().Assembly); RegisterDependency(); if (Settings.LoggedIn) { MainPage = ViewModelResolver.ResolveViewModel <ViewModels.SyncViewModel>(); } else { MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Login.LoginViewModel>()) { BarBackgroundColor = Color.FromHex("#2196F3"), BarTextColor = Color.White }; } }
public App() { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("OTkzNTJAMzEzNzJlMzEyZTMwbHYrZmduam1yNHRhQUhjSlpPSUZJTmpvZXc4b0VpZVdQNzNWcFNaamQxaz0="); InitializeComponent(); Init(); AppSettings.ReloadSetting(); AssetsExtension.InitAssetsExtension("AppResources.Assets", typeof(App).GetTypeInfo().Assembly); ImageResourceExtension.InitImageResourceExtension("AppResources.Assets", typeof(App).GetTypeInfo().Assembly); TranslateExtension.InitTranslateExtension("AppResources.Localization.Resources", CultureInfo.CurrentCulture, typeof(App).GetTypeInfo().Assembly); RegisterDependency(); if (Settings.LoggedIn) { MainPage = ViewModelResolver.ResolveViewModel <ViewModels.SyncViewModel>(); } else { MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Login.LoginViewModel>()) { BarBackgroundColor = Color.FromHex("#2196F3"), BarTextColor = Color.White }; } }
private void SetStartPage() { //var masterDetailNav = new MasterDetailNavigationContainer(); //masterDetailNav.Init("Menu"); //masterDetailNav.AddPage<MainViewModel>("Home"); Page page = ViewModelResolver.ResolveViewModel <TimeLineViewModel>(); NavigationPageContainer navigationContainer = new NavigationPageContainer(page); MainPage = navigationContainer; }
public MainPage() { InitializeComponent(); Detail = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Interventions.InterventionsViewModel>()) { BarTextColor = Color.FromHex("#FFFFFF") }; lastPage = (int)MenuItemType.Interventions; }
public async Task <string> PushPageModelWithNewNavigation <T>(object data, bool animate = true) where T : ViewModelFoundation.BaseViewModel { var page = ViewModelResolver.ResolveViewModel <T>(data); var navigationName = Guid.NewGuid().ToString(); var naviationContainer = new NavigationPageContainer(page, navigationName); await PushNewNavigationServiceModal(naviationContainer, page.GetModel(), animate); return(navigationName); }
private async Task LogOut() { if (await DisplayAlert(TranslateExtension.GetValue("alert_title_log_out"), TranslateExtension.GetValue("alert_message_log_out_confirm"), TranslateExtension.GetValue("alert_message_yes"), TranslateExtension.GetValue("alert_message_no"))) { Settings.LoggedIn = false; Application.Current.MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <LoginViewModel>()) { BarBackgroundColor = Color.DodgerBlue, BarTextColor = Color.White }; } }
private void SetStartPage(string pageName = PageName) { if (!PageName.Equals(pageName)) { Page page = ViewModelResolver.ResolveViewModel <MainViewModel>(pageName); NavigationPageContainer navigationContainer = new NavigationPageContainer(page); MainPage = navigationContainer; } else { Page page = ViewModelResolver.ResolveViewModel <MainViewModel>(); NavigationPageContainer navigationContainer = new NavigationPageContainer(page); MainPage = navigationContainer; } }
public virtual Page AddTab <T>(string title, string icon, object data = null) where T : BaseViewModel { Page page = ViewModelResolver.ResolveViewModel <T>(data); page.GetModel().CurrentNavigationServiceName = NavigationServiceName; _tabs.Add(page); Page container = CreateContainerPageSafe(page); container.Title = title; if (!string.IsNullOrWhiteSpace(icon)) { container.IconImageSource = icon; } FirstTabbedPage.Children.Add(container); return(container); }
private async Task LogOut() { if (await DisplayAlert(TranslateExtension.GetValue("alert_title_log_out"), TranslateExtension.GetValue("alert_message_log_out_confirm"), TranslateExtension.GetValue("alert_message_yes"), TranslateExtension.GetValue("alert_message_no"))) { Settings.RemoveCurrentUserName(); Settings.RemoveCurrentPassword(); Settings.RemoveCurrentUser(); Settings.RemoveLoggedIn(); //Stupid changed. it should remove everything //Settings.ClearEverything(); Application.Current.MainPage = new NavigationContainer(ViewModelResolver.ResolveViewModel <ViewModels.Login.LoginViewModel>()) { BarBackgroundColor = Color.DodgerBlue, BarTextColor = Color.White }; } }
private void CreateMenuPage <T>(string masterListName) where T : BaseViewModel { var masterpage = ViewModelResolver.ResolveViewModel <T>(); var pagelist = masterpage.FindByName(masterListName); if (pagelist is ListView list) { list.ItemSelected += (sender, args) => { if (Pages.ContainsKey(((MenuItems)args.SelectedItem).Title)) { Detail = Pages[((MenuItems)args.SelectedItem).Title]; } IsPresented = false; } } ; else { throw new Exception("Master list navigation name not the same as xaml"); } Master = masterpage; }
public MainPage() { InitializeComponent(); Detail = new NavigationContainer(ViewModelResolver.ResolveViewModel <PostsAndReviewsViewModel>()); }
async Task PushPageModel(ViewModelFoundation.BaseViewModel pageModel, object data, bool modal = false, bool animate = true) { var page = ViewModelResolver.ResolveViewModel(data, pageModel); await PushPageModelWithPage(page, pageModel, data, modal, animate); }
public async Task NavigateFromMenu(HomeMenuItemType type) { Debug.WriteLine("ITEM SELECTED"); Page selectedPage = null; switch (type) { case HomeMenuItemType.Home: selectedPage = ViewModelResolver.ResolveViewModel <HomeViewModel>(); break; case HomeMenuItemType.CheckIn: selectedPage = string.IsNullOrWhiteSpace(Host.Url) ? selectedPage = ViewModelResolver.ResolveViewModel <CheckInNonFullUserViewModel>() : selectedPage = ViewModelResolver.ResolveViewModel <CheckInViewModel>(); break; case HomeMenuItemType.Bookings: selectedPage = ViewModelResolver.ResolveViewModel <BookingsViewModel>(); break; case HomeMenuItemType.CheckOut: selectedPage = ViewModelResolver.ResolveViewModel <CheckOutViewModel>(); break; case HomeMenuItemType.AddBooking: selectedPage = ViewModelResolver.ResolveViewModel <BookingCalendarViewModel>(); break; case HomeMenuItemType.GuestBook: selectedPage = ViewModelResolver.ResolveViewModel <GuestBookViewModel>(); break; case HomeMenuItemType.Stats: selectedPage = ViewModelResolver.ResolveViewModel <StatsViewModel>(); break; case HomeMenuItemType.Settings: selectedPage = ViewModelResolver.ResolveViewModel <SettingsViewModel>(); break; case HomeMenuItemType.PostsAndReviews: selectedPage = ViewModelResolver.ResolveViewModel <PostsAndReviewsViewModel>(); break; case HomeMenuItemType.LogOut: await LogOut(); break; default: selectedPage = ViewModelResolver.ResolveViewModel <PostsAndReviewsViewModel>(); break; } if (selectedPage == null || type == HomeMenuItemType.LogOut) { return; } if (Detail is NavigationPage detailPage) { detailPage.NotifyAllChildrenPopped(); } // Default [Works for iOS] Detail = new NavigationContainer(selectedPage) { BarBackgroundColor = (Color)Application.Current.Resources["colorPrimary"], BarTextColor = Color.White }; if (Device.RuntimePlatform == Device.Android) { await Task.Delay(100); } // Work around for nav drawer hide lag [Android] //var root = Detail.Navigation.NavigationStack[0]; //Detail.Navigation.InsertPageBefore(page, root); //await Detail.Navigation.PopToRootAsync(false); IsPresented = false; }
public virtual void AddPage <T>(object data = null) where T : BaseViewModel { var page = ViewModelResolver.ResolveViewModel <T>(data); AddPagesToDictionary(page); }
public async Task NavigateFromMenu(int id) { if (lastPage == id) { IsPresented = false; return; } try { Page newPage = null; switch (id) { case (int)MenuItemType.Interventions: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Interventions.InterventionsViewModel>(); break; case (int)MenuItemType.InterventionsNotAssigned: newPage = ViewModelResolver.ResolveViewModel <ViewModels.InterventionsNotAssigned.InterventionsNotAssignedViewModel>(); break; case (int)MenuItemType.Quote: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Quotes.QuotesViewModel>(); break; case (int)MenuItemType.Invoice: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Invoices.InvoicesViewModel>(); break; case (int)MenuItemType.Issue: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Issues.IssuesViewModel>(); break; case (int)MenuItemType.Messages: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Messages.MessagesViewModel>(); break; case (int)MenuItemType.Customers: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Customers.CustomersViewModel>(); break; case (int)MenuItemType.Addresses: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Addresses.AddressesViewModel>(); break; case (int)MenuItemType.Equipment: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Equipments.EquipmentsViewModel>(); break; case (int)MenuItemType.Products: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Products.ProductsViewModel>(); break; case (int)MenuItemType.Tracking: newPage = ViewModelResolver.ResolveViewModel <ViewModels.Tracking.TrackingViewModel>(); break; case (int)MenuItemType.Settings: newPage = ViewModelResolver.ResolveViewModel <ViewModels.SystemSettings.SettingsViewModel>(); break; case (int)MenuItemType.About: newPage = ViewModelResolver.ResolveViewModel <ViewModels.About.AboutViewModel>(); break; case (int)MenuItemType.LogOut: await LogOut(); break; } if (newPage != null) { if (Detail is NavigationPage) { ((NavigationPage)Detail).NotifyAllChildrenPopped(); } if (Detail is INavigationService) { ((INavigationService)Detail).NotifyChildrenPageWasPopped(); } Detail = new NavigationContainer(newPage) { BarBackgroundColor = Color.FromHex("#2196F3"), BarTextColor = Color.White }; lastPage = id; if (Device.RuntimePlatform == Device.Android) { await Task.Delay(100); } IsPresented = false; } } catch (Exception ex) { await DisplayAlert(TranslateExtension.GetValue("alert_title_error"), ex.GetBaseException().Message, TranslateExtension.GetValue("alert_message_ok")); } }
public void ResolveViewModelWithoutTypeUnitTest(object data, BaseViewModel baseViewModel) { Page page = ViewModelResolver.ResolveViewModel(data, baseViewModel); Assert.NotNull(page); }
public void ResolveViewModelWithoutViewModelUnitTest(Type type, object data) { Page page = ViewModelResolver.ResolveViewModel(type, data); Assert.NotNull(page); }
public void ResolveViewModelUnitTest(Type type, object data, BaseViewModel baseViewModel) { Page page = ViewModelResolver.ResolveViewModel(type, data, baseViewModel); Assert.NotNull(page); }
public void CreateMenuPage <T>() where T : BaseViewModel { var masterpage = ViewModelResolver.ResolveViewModel <T>(); Master = masterpage; }