Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ protected virtual BottomSheetDialog CreateMoreBottomSheet(Action<int, BottomShee

// handle the more tab
var items = ((IShellItemController)ShellItem).GetItems();
for (int i = _bottomView.MaxItemCount - 1; i < items.Count; i++)
var maxItems = Math.Min(_bottomView.MaxItemCount, BottomNavigationViewUtils.MaxBottomNavigationItems);
for (int i = maxItems - 1; i < items.Count; i++)
{
var closure_i = i;
var shellContent = items[i];
Expand Down Expand Up @@ -376,7 +377,7 @@ protected override void OnShellSectionPropertyChanged(object sender, PropertyCha
var index = ((IShellItemController)ShellItem).GetItems().IndexOf(shellSection);

var itemCount = ((IShellItemController)ShellItem).GetItems().Count;
var maxItems = _bottomView.MaxItemCount;
var maxItems = Math.Min(_bottomView.MaxItemCount, BottomNavigationViewUtils.MaxBottomNavigationItems);
IMenuItem menuItem = null;

if (!(itemCount > maxItems && index > maxItems - 2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public static class BottomNavigationViewUtils
{
internal const int MoreTabId = 99;

/// <summary>
/// Maximum number of items allowed in the bottom navigation bar.
/// Newer versions of the Xamarin.Google.Android.Material package report
/// <c>BottomNavigationView.MaxItemCount</c> as 6, whereas older versions returned 5.
/// Clamped to 5 for consistent behavior regardless of the Material library version.
/// See https://github.com/dotnet/maui/pull/33450
/// </summary>
internal const int MaxBottomNavigationItems = 5;

public static Drawable CreateItemBackgroundDrawable()
{
var stateList = ColorStateList.ValueOf(Colors.Black.MultiplyAlpha(0.2f).ToPlatform());
Expand Down Expand Up @@ -71,6 +80,7 @@ internal static async void SetupMenu(
BottomNavigationView bottomView,
IMauiContext mauiContext)
{
maxBottomItems = Math.Min(maxBottomItems, MaxBottomNavigationItems);
Context context = mauiContext.Context;

while (items.Count < menu.Size())
Expand Down Expand Up @@ -162,7 +172,7 @@ public static BottomSheetDialog CreateMoreBottomSheet(
IMauiContext mauiContext,
List<(string title, ImageSource icon, bool tabEnabled)> items)
{
return CreateMoreBottomSheet(selectCallback, mauiContext, items, 5);
return CreateMoreBottomSheet(selectCallback, mauiContext, items, MaxBottomNavigationItems);
}

internal static BottomSheetDialog CreateMoreBottomSheet(
Expand All @@ -171,6 +181,7 @@ internal static BottomSheetDialog CreateMoreBottomSheet(
List<(string title, ImageSource icon, bool tabEnabled)> items,
int maxItemCount)
{
maxItemCount = Math.Min(maxItemCount, MaxBottomNavigationItems);
var context = mauiContext.Context;
var bottomSheetDialog = new BottomSheetDialog(context);
var bottomSheetLayout = new LinearLayout(context);
Expand Down Expand Up @@ -300,4 +311,4 @@ public static void SetShiftMode(this BottomNavigationView bottomNavigationView,
}
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading