Skip to content

Fix ShowOnShift #4877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2021
Merged
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
33 changes: 18 additions & 15 deletions Files/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,31 @@ public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyout
{
items = items.Where(x => Check(item: x, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, shiftPressed: shiftPressed)).ToList();
items.ForEach(x => x.Items = x.Items.Where(y => Check(item: y, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, shiftPressed: shiftPressed)).ToList());

var overflow = items.Where(x => x.ID == "ItemOverflow").FirstOrDefault();
if (overflow != null && !shiftPressed)
if (overflow != null)
{
var overflowItems = items.Where(x => x.ShowOnShift).ToList();

// Adds a separator between items already there and the new ones
if (overflow.Items.Count != 0 && overflow.Items.Last().ItemType != ItemType.Separator && overflowItems.Count > 0)
if (!shiftPressed && App.AppSettings.MoveOverflowMenuItemsToSubMenu) // items with ShowOnShift to overflow menu
{
overflow.Items.Add(new ContextMenuFlyoutItemViewModel()
var overflowItems = items.Where(x => x.ShowOnShift).ToList();

// Adds a separator between items already there and the new ones
if (overflow.Items.Count != 0 && overflow.Items.Last().ItemType != ItemType.Separator && overflowItems.Count > 0)
{
ItemType = ItemType.Separator,
});
overflow.Items.Add(new ContextMenuFlyoutItemViewModel{ ItemType = ItemType.Separator });
}

items = items.Except(overflowItems).ToList();
overflowItems.ForEach(x => overflow.Items.Add(x));
}
overflowItems.ForEach(x => overflow.Items.Add(x));
items = items.Except(overflowItems).ToList();
}

// remove the overflow if it has no child items
if (overflow != null && overflow.Items.Count == 0)
{
items.Remove(overflow);
// remove the overflow if it has no child items
if (overflow.Items.Count == 0)
{
items.Remove(overflow);
}
}

return items;
}

Expand Down