diff --git a/Aurora/Frontend/Components/NavigationMenu/NavigationGroupItem.cs b/Aurora/Frontend/Components/NavigationMenu/NavigationGroupItem.cs new file mode 100644 index 0000000..2688b8d --- /dev/null +++ b/Aurora/Frontend/Components/NavigationMenu/NavigationGroupItem.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Aurora.Frontend.Components.NavigationMenu +{ + public class NavigationGroupItem : List + { + public NavigationGroupItem() + { + } + + public NavigationGroupItem(string heading) + { + GroupHeading = heading; + } + + public List Items => this; + public string GroupHeading { get; set; } + } +} diff --git a/Aurora/Frontend/Components/NavigationMenu/NavigationItem.cs b/Aurora/Frontend/Components/NavigationMenu/NavigationItem.cs index 27933f7..c7107ed 100644 --- a/Aurora/Frontend/Components/NavigationMenu/NavigationItem.cs +++ b/Aurora/Frontend/Components/NavigationMenu/NavigationItem.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Aurora.Frontend.Views.Main; -namespace Aurora.Frontend.Views.Components.NavigationMenu +namespace Aurora.Frontend.Components.NavigationMenu { public class NavigationItem { diff --git a/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml b/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml index fc4032a..f247cfa 100644 --- a/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml +++ b/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml @@ -9,6 +9,7 @@ SeparatorVisibility="None" HasUnevenRows="true" BackgroundColor="{StaticResource MenuBackgroundColor}" + IsGroupingEnabled="true" CachingStrategy="RecycleElement"> @@ -27,6 +28,14 @@ + + + + + + + diff --git a/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml.cs b/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml.cs index c5c0426..98f4124 100644 --- a/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml.cs +++ b/Aurora/Frontend/Components/NavigationMenu/NavigationMenu.xaml.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using Aurora.Frontend.Views.Components.NavigationMenu; using Xamarin.Forms; namespace Aurora.Frontend.Components.NavigationMenu @@ -38,7 +37,34 @@ namespace Aurora.Frontend.Components.NavigationMenu private static void OnItemsChanged(BindableObject bindable, object oldValue, object newValue) { var control = (NavigationMenu)bindable; - control.MenuItemsListView.ItemsSource = (ObservableCollection)newValue; + ObservableCollection items = (ObservableCollection)newValue; + Dictionary groupDictioanry = new Dictionary(); + + //Populate dictionary where group heading is the key + foreach(NavigationItem item in items) + { + if(groupDictioanry.ContainsKey(item.Group)) + { + groupDictioanry.TryGetValue(item.Group, out var groupItem); + groupItem.Items.Add(item); + } + else + { + NavigationGroupItem groupItem = new NavigationGroupItem(item.Group); + groupItem.Add(item); + + groupDictioanry.Add(item.Group, groupItem); + } + } + + ObservableCollection groups = new ObservableCollection(); + foreach(string groupHeading in groupDictioanry.Keys) + { + groupDictioanry.TryGetValue(groupHeading, out var groupItem); + groups.Add(groupItem); + } + + control.MenuItemsListView.ItemsSource = groups; } } diff --git a/Aurora/Frontend/Views/MainView/MainView.xaml.cs b/Aurora/Frontend/Views/MainView/MainView.xaml.cs index 686cff4..309a97a 100644 --- a/Aurora/Frontend/Views/MainView/MainView.xaml.cs +++ b/Aurora/Frontend/Views/MainView/MainView.xaml.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using Aurora.Frontend.Views.Components.NavigationMenu; +using Aurora.Frontend.Components.NavigationMenu; using Aurora.Frontend.Views.MainView; using Xamarin.Forms; using Xamarin.Forms.Xaml; diff --git a/Aurora/Frontend/Views/MainView/MainViewModel.cs b/Aurora/Frontend/Views/MainView/MainViewModel.cs index af90e05..ff0e0a1 100644 --- a/Aurora/Frontend/Views/MainView/MainViewModel.cs +++ b/Aurora/Frontend/Views/MainView/MainViewModel.cs @@ -2,9 +2,9 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; +using Aurora.Frontend.Components.NavigationMenu; using Aurora.Frontend.Views.Albums; using Aurora.Frontend.Views.Artists; -using Aurora.Frontend.Views.Components.NavigationMenu; using Aurora.Frontend.Views.Songs; using Aurora.Frontend.Views.Stations;