//void InitTabItems(MainWindowViewModel mainWindow, params TabItemId[] topTabs) //{ // IEnumerable<TabItemId> topTabs_ = topTabs; // InitTabItems(mainWindow, topTabs_); //} //void InitTabItems(MainWindowViewModel mainWindow, IEnumerable<TabItemId>? topTabs = null) //{ // var tabItems = mainWindow.AllTabItems.Where(x => x.Id != TabItemId.GameList); // if (topTabs.Any_Nullable()) // { // tabItems = tabItems.Where(x => topTabs.Contains(x.Id)).Concat(tabItems.Where(x => !topTabs.Contains(x.Id))); // } // foreach (var item in tabItems) // { // InitTabItem(item); // } // void InitTabItem(TabItemViewModel tab) // { // if (pageRouteService?.IsUseNativePage(tab.Id) ?? false) // { // var tab_item = new MenuItem // { // IconImageSource = tab.IconKey, // BindingContext = tab, // }; // tab_item.Clicked += (_, _) => pageRouteService!.GoToNativePage(tab.Id); // tab_item.SetBinding(MenuItem.TextProperty, nameof(tab.Name), BindingMode.OneWay); // Items.Add(tab_item); // } // else // { // var tab_item = new FlyoutItem // { // Icon = tab.IconKey, // BindingContext = tab, // }; // tab_item.SetBinding(BaseShellItem.TitleProperty, nameof(tab.Name), BindingMode.OneWay); // tab_item.Items.Add(new ShellContent // { // Route = tab.IconKey!.TrimEnd("ViewModel"), // ContentTemplate = new DataTemplate(GetPageType(tab)), // }); // Items.Add(tab_item); // } // } //} void AddPage(ViewModelBase vm, bool isVisible = true, bool rSubscribe = true) { var data = GetShellItemData(vm); if (data == default) { return; } var tab_item = new FlyoutItem { BindingContext = vm, FlyoutItemIsVisible = isVisible, }; tab_item.SetBinding(BaseShellItem.TitleProperty, data.bindingPathName, BindingMode.OneWay); var pageType = GetPageType(vm); var content = new ShellContent { ContentTemplate = new DataTemplate(pageType), }; if (data.route != null) { content.Route = pageType.Name; } tab_item.Items.Add(content); Items.Add(tab_item); }
public TextQuestionViewModel(AppShell appShell, TextQuestion textQuestion) { this.Question = textQuestion.QuestionText; this.BaseObject = textQuestion; this.Title = "Otázka " + NumberOfQuestion; NumberOfQuestion++; this.AppShell = appShell; this.ConfirmQuestion = new Command(OnAnswerConfirmed); FlyOutItem = new FlyoutItem() { Title = this.Title, Icon = "icon_question.png", }; TextQuestionPage = new TextQuestionPage(this) { Title = this.Title }; ShellContent = new ShellContent { Content = TextQuestionPage }; FlyOutItem.Items.Add(ShellContent); }
protected override void Init() { _itemexpanderItems = new FlyoutItem() { Title = "Expando Magic", FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems }; ContentPage contentPage = new ContentPage() { Content = new StackLayout() { Children = { new Label() { Text = "Open the Flyout", AutomationId = "PageLoaded" } } } }; AddFlyoutItem(contentPage, "Top Item"); var flyoutItem = AddFlyoutItem("Click Me and You Should see 2 Items show up"); flyoutItem.Route = "ExpandMe"; flyoutItem.AutomationId = "ExpandMe"; Items.Add(_itemexpanderItems); }
public void AppearingOnCreate() { Shell shell = new Shell(); FlyoutItem flyoutItem = new FlyoutItem(); Tab tab = new Tab(); ShellContent content = new ShellContent() { Content = new ContentPage() }; bool flyoutAppearing = false; bool tabAppearing = false; bool contentAppearing = false; flyoutItem.Appearing += (_, __) => flyoutAppearing = true; tab.Appearing += (_, __) => tabAppearing = true; content.Appearing += (_, __) => contentAppearing = true; shell.Items.Add(flyoutItem); flyoutItem.Items.Add(tab); tab.Items.Add(content); Assert.True(flyoutAppearing, "Flyout appearing"); Assert.True(tabAppearing, "Tab Appearing"); Assert.True(contentAppearing, "Content Appearing"); }
public void AppearingOnlyForVisiblePage() { Shell shell = new Shell(); var pageAppearing = new ContentPage(); var pageNotAppearing = new ContentPage(); FlyoutItem flyoutItem = new FlyoutItem(); Tab tab = new Tab(); ShellContent content = new ShellContent() { Content = pageAppearing }; bool pageAppearingFired = false; bool pageNotAppearingFired = false; pageAppearing.Appearing += (_, __) => pageAppearingFired = true; pageNotAppearing.Appearing += (_, __) => { pageNotAppearingFired = true; }; shell.Items.Add(flyoutItem); flyoutItem.Items.Add(tab); tab.Items.Add(content); var notAppearingContent = new ShellContent(); tab.Items.Add(notAppearingContent); notAppearingContent.Content = pageNotAppearing; Assert.True(pageAppearingFired, "Correct Page Appearing Fired"); Assert.False(pageNotAppearingFired, "Incorrect Page Appearing Fired"); }
public async Task ShellWithOnlyFlyoutItems() { SetupBuilder(); var shell = await CreateShellAsync((shell) => { var shellItem1 = new FlyoutItem(); shellItem1.Items.Add(new ContentPage()); var shellItem2 = new FlyoutItem(); shellItem2.Items.Add(new ContentPage()); shell.Items.Add(shellItem1); shell.Items.Add(shellItem2); }); await CreateHandlerAndAddToWindow <ShellHandler>(shell, (handler) => { var rootNavView = (handler.PlatformView); var shellItemView = shell.CurrentItem.Handler.PlatformView as UI.Xaml.Controls.NavigationView; var expectedRoot = UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftMinimal; var expectedShellItems = UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftMinimal; Assert.True(rootNavView.IsPaneToggleButtonVisible); Assert.False(shellItemView.IsPaneToggleButtonVisible); Assert.Equal(expectedRoot, rootNavView.PaneDisplayMode); Assert.Equal(expectedShellItems, shellItemView.PaneDisplayMode); return(Task.CompletedTask); }); }
MenuItem CreateNonVisibleMenuItem() { MenuItem item = new MenuItem(); FlyoutItem.SetIsVisible(item, false); return(item); }
void Button_Clicked(object sender, EventArgs e) { var mainPage = new FlyoutItem { Title = "Main Page", Items = { new ShellContent { Content = new MainPage() } } }; var page1 = new FlyoutItem { Title = "Page 1", Items = { new ShellContent { Content = new Page1() } } }; Shell.Current.Items.Clear(); Shell.Current.Items.Add(page1); Shell.Current.Items.Add(mainPage); }
public MapViewModel(AppShell appShell) { this.Title = "Mapa"; this.AppShell = appShell; this.Pins = new List <PinViewModel>(); FlyOutItem = new FlyoutItem() { Title = this.Title, Icon = "icon_map.png", }; MapPage = new MapPage(this) { Title = this.Title }; ShellContent = new ShellContent { Content = MapPage }; FlyOutItem.Items.Add(ShellContent); AddToBar(); }
//protected override void OnDisappearing() //{ // MessagingCenter.Unsubscribe<MainPageViewModel, Host>(this, MessengerKeys.HostChanged); // base.OnDisappearing(); //} //protected override void OnAppearing() //{ // MessagingCenter.Subscribe<MainPageViewModel, Host>( // this, MessengerKeys.HostChanged, async (sender, arg) => // { // MainThread.BeginInvokeOnMainThread(() => { InitList(arg); }); // }); // base.OnAppearing(); //} /// <summary> /// </summary> public MyCustomShellApp() { var config = App.Container.Resolve <IConfiguration>(); var messagingCenter = App.Container.Resolve <IMessagingCenter>(); messagingCenter.Subscribe <IConnctionService, Host>( this, MessengerKeys.HostChanged, async(sender, arg) => { MainThread.BeginInvokeOnMainThread(() => { InitList(arg); }); }); if (!config.ModeOmvOnlyKey) { FlyoutHeader = new FlyoutHeader("MMS_graphic.png"); } else { FlyoutHeader = new FlyoutHeader("OMV_graphic.png"); } var homeItem = new FlyoutItem { Title = Title = openmediavault.Homepage, Items = { new ShellSection { Items = { new ShellContent { Title = openmediavault.Homepage, ContentTemplate = new DataTemplate(typeof(MainPage)) } } } } }; Items.AddRange(homeItem); //var commandsItem = CreateFlyoutItem(openmediavault.ExecuteCommand, // typeof(CustomCommandListPage)); var settingsItem = CreateFlyoutItem(openmediavault.Settings, typeof(SettingsPage)); var aboutItem = CreateFlyoutItem(openmediavault.About, typeof(AboutPage)); //Items.AddRange(commandsItem, settingsItem, aboutItem); Items.AddRange(settingsItem, aboutItem); BindingContext = App.Container.Resolve <AppShellViewModel>(); // Item => section => content //this.PropertyChanged += OnPropertyChanged; //this.CurrentItem.PropertyChanged += CurrentItemOnPropertyChanged; }
// // DON'T change this function unless you know what you are doing // WHAT: Read DPageDefinition and generate pages and insert to shell.item // WHY: To centralize page generation in shell implementation // private void GeneratePages(List <DPageDefinition> pageDefinitions, DisplayType displayType) { if (pageDefinitions == null) { Console.WriteLine("Error! Page definitions is null! Please insert it into DShell."); return; } switch (displayType) { case DisplayType.BOTH: //Flyout + tabbar //Hierarchy: One Flyout > Multiple Tab / ShellContent FlyoutItem flyoutItem = new FlyoutItem() { FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems }; foreach (DPageDefinition pageDefinition in pageDefinitions) { flyoutItem.Items.Add(GetShellSectionFromPageDefinition(pageDefinition)); } Items.Add(flyoutItem); break; case DisplayType.FLYOUT: //Flyout only //Hierarchy: Multiple Flyout > One ShellContent foreach (DPageDefinition pageDefinition in pageDefinitions) { flyoutItem = new FlyoutItem() { Title = pageDefinition.title, Icon = ImageSource.FromFile(pageDefinition.icon), }; flyoutItem.Items.Add(GetShellSectionFromPageDefinition(pageDefinition)); Items.Add(flyoutItem); } break; case DisplayType.TABBAR: //Tabbar only //Hierarchy: Tabber > Tab / ShellContent TabBar tabbarItem = new TabBar(); foreach (DPageDefinition pageDefinition in pageDefinitions) { tabbarItem.Items.Add(GetShellSectionFromPageDefinition(pageDefinition)); } Items.Add(tabbarItem); break; } }
public void BindingContextSetsCorrectlyWhenUsingAsMultipleItemAndImplicitlyGeneratedShellSections() { Shell shell = new Shell(); FlyoutItem item = new FlyoutItem() { FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems }; ShellContent shellContent1 = new ShellContent(); ShellContent shellContent2 = new ShellContent(); item.Items.Add(shellContent1); item.Items.Add(shellContent2); shell.Items.Add(item); var vm = new TestShellViewModel(); vm.SubViewModel = new TestShellViewModel() { Text = "Item1" }; vm.SubViewModel2 = new TestShellViewModel() { Text = "Item2" }; shell.BindingContext = vm; shellContent1.SetBinding(BindableObject.BindingContextProperty, "SubViewModel"); shellContent2.SetBinding(BindableObject.BindingContextProperty, "SubViewModel2"); shell.ItemTemplate = new DataTemplate(() => { Label label = new Label(); label.SetBinding(Label.TextProperty, "BindingContext.Text"); return(label); }); var flyoutItems = (shell as IShellController).GenerateFlyoutGrouping(); var label1 = GetFlyoutItemDataTemplateElement <Label>(shell, flyoutItems[0][0]); var label2 = GetFlyoutItemDataTemplateElement <Label>(shell, flyoutItems[0][1]); Assert.AreEqual(label1.BindingContext, shellContent1); Assert.AreEqual(label2.BindingContext, shellContent2); Assert.AreEqual("Item1", label1.Text); Assert.AreEqual("Item2", label2.Text); }
public AppShell() { InitializeComponent(); Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage)); Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage)); Routing.RegisterRoute(nameof(Register), typeof(Register)); _profil = Profil; _poruke = Poruke; _prijava = Prijava; _odjava = Odjava; _register = Register; _pregledi = Pregled; }
public async Task NavigatedFiresAfterContentIsCreatedWhenUsingTemplate() { Shell shell = new Shell(); FlyoutItem flyoutItem = new FlyoutItem(); Tab tab = new Tab(); ContentPage page = null; ShellContent content = new ShellContent() { Route = "destination", ContentTemplate = new DataTemplate(() => { page = new ContentPage(); return(page); }) }; flyoutItem.Items.Add(tab); tab.Items.Add(content); shell.Items.Add(CreateShellItem()); shell.Items.Add(flyoutItem); Assert.AreNotEqual(shell.CurrentItem.CurrentItem.CurrentItem, content); Assert.IsNull(page); bool navigated = false; shell.Navigated += (_, __) => { Assert.IsNotNull(page); Assert.IsNotNull((content as IShellContentController).Page); navigated = true; }; await shell.GoToAsync("///destination"); // content hasn't been created yet Assert.IsFalse(navigated); var createPage = (content as IShellContentController).GetOrCreateContent(); Assert.AreEqual(createPage, page); Assert.IsTrue(navigated); }
public AppShell() { InitializeComponent(); AuthenticationService = DependencyService.Get <AuthenticationService>(); _registerMenuEntry = new FlyoutItem() { FlyoutDisplayOptions = Xamarin.Forms.FlyoutDisplayOptions.AsMultipleItems }; _registerMenuEntry.Items.Add(new ShellContent() { Title = "Register", ContentTemplate = new DataTemplate(typeof(RegisterPage)) }); _loginMenuEntry = new FlyoutItem() { FlyoutDisplayOptions = Xamarin.Forms.FlyoutDisplayOptions.AsMultipleItems }; _loginMenuEntry.Items.Add(new ShellContent() { Title = "Login", ContentTemplate = new DataTemplate(typeof(LoginPage)) }); _logoutMenuEntry = new FlyoutItem() { FlyoutDisplayOptions = Xamarin.Forms.FlyoutDisplayOptions.AsMultipleItems }; _logoutMenuEntry.Items.Add(new ShellContent() { Title = "Logout", ContentTemplate = new DataTemplate(typeof(LogoutPage)) }); Items.Add(_registerMenuEntry); Items.Add(_loginMenuEntry); Routing.RegisterRoute(nameof(ProjectDetailPage), typeof(ProjectDetailPage)); Routing.RegisterRoute(nameof(NewProjectPage), typeof(NewProjectPage)); Routing.RegisterRoute(nameof(FirebasePage), typeof(FirebasePage)); Routing.RegisterRoute(nameof(LoginPage), typeof(LoginPage)); Routing.RegisterRoute(nameof(RegisterPage), typeof(RegisterPage)); AuthenticationService.LoggingStatusChanged += AuthenticationService_LoggingStatusChanged; }
public async Task FlyoutItemVisible() { var shell = new Shell(); var item1 = CreateShellItem <FlyoutItem>(shellItemRoute: "NotVisible"); var item2 = CreateShellItem(); shell.Items.Add(item1); shell.Items.Add(item2); FlyoutItem.SetIsVisible(item1, false); Assert.IsTrue(GetItems(shell).Contains(item1)); bool hasFlyoutItem = (shell as IShellController) .GenerateFlyoutGrouping() .SelectMany(i => i) .Contains(item1); Assert.IsFalse(hasFlyoutItem); }
public async Task DefaultRoutesMaintainedIfThatsAllThereIs() { Routing.RegisterRoute(nameof(DefaultRoutesMaintainedIfThatsAllThereIs), typeof(ContentPage)); var shell = new Shell(); var shellContent = new ShellContent(); FlyoutItem flyoutItem = new FlyoutItem() { Items = { shellContent } }; shell.Items.Add(flyoutItem); await shell.GoToAsync(nameof(DefaultRoutesMaintainedIfThatsAllThereIs)); Assume.That(shell.CurrentState.Location.ToString(), Is.EqualTo($"//{Routing.GetRoute(shellContent)}/{nameof(DefaultRoutesMaintainedIfThatsAllThereIs)}")); await shell.GoToAsync(".."); }
private void CheckoutPage(string title, ContentPage page) { FlyoutIsPresented = false; Items[currentItemIndex] = new FlyoutItem { IsVisible = false, Title = title, Items = { new Tab { Items ={ new ShellContent { Content = page } } } } }; CurrentItem = Items[currentItemIndex]; setLoginOrLoqoutMenuItemTitle(); }
public void AppearingOnCreateFromTemplate() { Shell shell = new Shell(); FlyoutItem flyoutItem = new FlyoutItem(); Tab tab = new Tab(); ContentPage page = new ContentPage(); ShellContent content = new ShellContent() { ContentTemplate = new DataTemplate(() => page) }; bool flyoutAppearing = false; bool tabAppearing = false; bool contentAppearing = false; bool pageAppearing = false; flyoutItem.Appearing += (_, __) => flyoutAppearing = true; tab.Appearing += (_, __) => tabAppearing = true; content.Appearing += (_, __) => contentAppearing = true; page.Appearing += (_, __) => pageAppearing = true; shell.Items.Add(flyoutItem); flyoutItem.Items.Add(tab); tab.Items.Add(content); Assert.True(flyoutAppearing, "Flyout appearing"); Assert.True(tabAppearing, "Tab Appearing"); // Because the is a page template the content appearing events won't fire until the page is created Assert.IsFalse(contentAppearing, "Content Appearing"); Assert.IsFalse(pageAppearing, "Page Appearing"); var createdContent = (content as IShellContentController).GetOrCreateContent(); Assert.AreEqual(createdContent, page); Assert.IsTrue(contentAppearing, "Content Appearing"); Assert.IsTrue(pageAppearing, "Page Appearing"); }
public FlyoutItem AddFlyoutItem(ContentPage page, string title) { var item = new FlyoutItem { Title = title, Items = { new Tab { Title = title, Items = { page } } } }; Items.Add(item); return(item); }
public AppShell() { InitializeComponent(); FlyoutItem item = new FlyoutItem() { Title = "Home" }; ShellContent content = new ShellContent(); //Home Page content.Title = "Home"; content.Content = navigationService.GetPageWithBindingContext(typeof(CategoryPageViewModel), "selectedCategory", string.Empty); item.Items.Add(content); this.Items.Add(item); //Aboutus Page item = new FlyoutItem() { Title = "About" }; content = new ShellContent(); content.Title = "About"; content.Content = navigationService.GetPageWithBindingContext(typeof(AboutUsViewModel), string.Empty, string.Empty); item.Items.Add(content); this.Items.Add(item); //Logout Menu MenuItem logout = new MenuItem() { Text = "Logout", Command = new Command(GoToLogout) }; this.Items.Add(logout); RegisterRoutes(); }
public void FlyOutItemShower( FlyoutItem homePage, MenuItem friendsPage, MenuItem addWorkoutPage, MenuItem logInPage, MenuItem logOutPage) { if (IsLoggedIn) { homePage.IsEnabled = true; friendsPage.IsEnabled = true; addWorkoutPage.IsEnabled = true; logInPage.IsEnabled = false; logOutPage.IsEnabled = true; } else { homePage.IsEnabled = false; friendsPage.IsEnabled = false; addWorkoutPage.IsEnabled = false; logInPage.IsEnabled = true; logOutPage.IsEnabled = false; } }
private void InitList(Host host) { Items.Clear(); if (host.IsSsh && !host.IsOmvServer) { var homeItem = new FlyoutItem { Title = Title = openmediavault.Homepage, Items = { new ShellSection { Items = { new ShellContent { Title = openmediavault.Homepage, ContentTemplate = new DataTemplate(typeof(MainPage)) } } } } }; Items.AddRange(homeItem); } if (!host.IsOmvServer && !host.IsSynoServer && host.IsSsh) { Items.AddRange(GetLinuxPages()); } if (host.IsWebminServer) { Items.AddRange(GetWebminPages()); } if (host.IsOmvServer) { Items.AddRange(GetOmvPages()); } if (host.IsSynoServer) { Items.AddRange(GetSynoPages()); } if (host.IsOmvServer) { Items.AddRange(GetNasPages()); } if (host.IsSynoServer) { Items.AddRange(GetNasPages()); } if (host.IsSynoServer || host.IsOmvServer || host.IsWebminServer || host.IsSsh) { Items.AddRange(GetPackageUpdatesPages()); } if (host.IsSsh) { var commandsItem = CreateFlyoutItem(openmediavault.ExecuteCommand, typeof(CustomCommandListPage)); Items.Add(commandsItem); } var settingsItem = CreateFlyoutItem(openmediavault.Settings, typeof(SettingsPage)); var aboutItem = CreateFlyoutItem(openmediavault.About, typeof(AboutPage)); Items.AddRange(settingsItem, aboutItem); CurrentItem = Items.First(); }
public async Task SelectedItemOnShellViewCorrectWithImplictFlyoutItem() { SetupBuilder(); var page1 = new ContentPage(); var page2 = new ContentPage(); var page3 = new ContentPage(); var flyoutItem1 = new FlyoutItem() { Items = { new ShellContent() { Content = page1, Title = "Content 1" }, } }; var flyoutItem2ShellSection = new ShellSection() { Items = { new ShellContent() { Content = page2, Title = "Content 2" }, } }; var flyoutItem3ShellContent = new ShellContent() { Content = page3, Title = "Content 3" }; var shell = await CreateShellAsync((shell) => { shell.Items.Add(flyoutItem1); shell.Items.Add(flyoutItem2ShellSection); }); await CreateHandlerAndAddToWindow <ShellHandler>(shell, async (handler) => { var navigationView = handler.PlatformView as MauiNavigationView; var menuItems = navigationView.MenuItemsSource as IList <NavigationViewItemViewModel>; Assert.Equal(flyoutItem1, navigationView.SelectedItem); // Switch to Shell Section shell.CurrentItem = flyoutItem2ShellSection; await OnLoadedAsync(page2); Assert.Equal(flyoutItem2ShellSection, navigationView.SelectedItem); // Switch to Shell Content shell.CurrentItem = flyoutItem3ShellContent; await OnLoadedAsync(page3); Assert.Equal(flyoutItem3ShellContent, navigationView.SelectedItem); }); }
public void AddFlyoutItem(FlyoutItem item) { Items.Add(item); }
public void AddFlyoutItemAtIndex(int index, FlyoutItem item) { Items.Insert(index, item); }
public void RemoveFlyoutItem(FlyoutItem item) { Items.Remove(item); }