Skip to content

Commit

Permalink
Cleanup HandlerCleanupHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Galliker committed Sep 10, 2024
1 parent 3a7d1c9 commit 7e47ac9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Plugin.SegmentedControl.Maui/Utils/HandlerCleanUpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private static bool CheckIfPageIsUsed(Page targetPage)
// is still used in Shell.Current or one of its children.
if (Shell.Current is Shell shell)
{
var currentPage = WalkToPage(shell);
var pages = GetActivePages(shell);
var pageExists = pages.Any(p => p == targetPage);
return pageExists;
Expand All @@ -79,8 +78,7 @@ private static IEnumerable<Page> GetActivePages(Shell shell)
{
var hashSet = new HashSet<Page>();

var items = shell.Items.ToArray();
foreach (var shellItem in items)
foreach (var shellItem in shell.Items)
{
foreach (var page in WalkToPage(shellItem))
{
Expand All @@ -89,7 +87,7 @@ private static IEnumerable<Page> GetActivePages(Shell shell)

foreach (var shellSection in shellItem.Items)
{
foreach (var page in WalkToPage(shellItem))
foreach (var page in WalkToPage(shellSection))
{
hashSet.Add(page);
}
Expand All @@ -110,9 +108,8 @@ private static IEnumerable<Page> WalkToPage(Element element)
return WalkToPage(shellItem.CurrentItem);

case ShellSection shellSection:

var controller = (IShellSectionController)element;
var children = controller.LogicalChildren.OfType<IShellContentController>();
IShellSectionController controller = shellSection;
var children = controller.GetItems().OfType<IShellContentController>();
return children.Select(c => c.Page);
}

Expand Down

0 comments on commit 7e47ac9

Please sign in to comment.