Skip to content

Commit

Permalink
Merge pull request #2345 from unoplatform/dev/erli/2300-include-foote…
Browse files Browse the repository at this point in the history
…r-menu-item

fix: Include FooterMenuItems to NavigationMenuItems
  • Loading branch information
nickrandolph authored Jun 20, 2024
2 parents bbf5dcc + d041029 commit 76c3d64
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override void ControlInitialize()
// Make sure selectionchanged event handlers are wired up
base.ControlInitialize();

if(Control?.SelectedItem is not null)
if (Control?.SelectedItem is not null)
{
_ = SelectionChanged(Control, MenuItemToFrameworkElement(Control.SelectedItem));
}
Expand Down Expand Up @@ -71,13 +71,17 @@ private object[] NavigationMenuItems
return Array.Empty<object>();
}

static IEnumerable<object> GetItems(object source, IEnumerable items) =>
(source as IEnumerable)?.OfType<object>() ??
items?.OfType<object>() ??
Array.Empty<object>();

if (Control.MenuItemsSource is IEnumerable items)
{
return items.OfType<object>().ToArray();
}
var allitems = Enumerable.Concat(
GetItems(Control.MenuItemsSource, Control.MenuItems),
GetItems(Control.FooterMenuItemsSource, Control.FooterMenuItems)
).ToArray();

return Control.MenuItems.ToArray();
return allitems;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Background="LightBlue">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -38,6 +37,7 @@
SelectedItem="{Binding SelectedNavigationItem, Mode=TwoWay}"
ItemInvoked="NavigationItemInvoked"
MenuItemsSource="{Binding NavigationItems}"
FooterMenuItemsSource="{Binding FooterItems}"
IsSettingsVisible="True">
<muxc:NavigationView.MenuItemTemplate>
<DataTemplate x:Key="NavigationViewMenuItemDataTemplate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public NavigationViewDataBoundPage()

public void NavigationItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs e)
{
if(e.InvokedItemContainer == sender.SettingsItem as Microsoft.UI.Xaml.Controls.NavigationViewItem)
if (e.InvokedItemContainer == sender.SettingsItem as Microsoft.UI.Xaml.Controls.NavigationViewItem)
{
this.Navigator()!.NavigateViewModelAsync<NavigationViewSettingsViewModel>(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
namespace TestHarness.Ext.Navigation.NavigationView;

[ReactiveBindable(false)]
public partial class NavigationViewDataBoundViewModel : ObservableObject
{
[ObservableProperty]
private string selectedNavigationItem = "Deals";

public string[] NavigationItems { get; } = new string[] { "Products", "Deals", "Profile" };
public string[] NavigationItems { get; } = ["Products", "Deals"];
public string[] FooterItems { get; } = ["Profile"];

public void SelectProfile()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@
<muxc:NavigationViewItem AutomationProperties.AutomationId="DealsNavigationViewItem"
Content="Deals"
uen:Region.Name="Deals" />
</muxc:NavigationView.MenuItems>
<muxc:NavigationView.FooterMenuItems>

<muxc:NavigationViewItem AutomationProperties.AutomationId="ProfileNavigationViewItem"
Content="Profile"
uen:Region.Name="Profile" />
</muxc:NavigationView.MenuItems>
</muxc:NavigationView.FooterMenuItems>
<Grid uen:Region.Attached="True"
uen:Region.Navigator="Visibility">
<StackPanel uen:Region.Name="Products"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace TestHarness.Ext.Navigation.TabBar;

[ReactiveBindable(false)]
public partial class TabBarHomeViewModel : ObservableObject
{
private RouteResolverDefault routeResolver;
Expand Down

0 comments on commit 76c3d64

Please sign in to comment.