Skip to content
Merged
Changes from 1 commit
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
44 changes: 23 additions & 21 deletions src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,40 +735,42 @@ internal static void UpdateLayerBorder(this CoreAnimation.CALayer layer, IButton
return null;
}

internal static UIView? FindNextView(this UIView view, UIView superView, Func<UIView, bool> isValidType)
internal static UIView? FindNextView(this UIView view, UIView containerView, Func<UIView, bool> isValidType)
{
var passedOriginal = false;
UIView? nextView = null;

var nextView = superView.FindNextView(view, ref passedOriginal, isValidType);
while (view != containerView && view is not null)
{
var siblings = view.Superview.Subviews;
nextView = view.FindNextView(siblings.IndexOf(view) + 1, isValidType);

if (nextView is not null)
break;

view = view.Superview;
}

// if we did not find the next view, try to find the first one
nextView ??= superView.FindNextView(null, ref passedOriginal, isValidType);
nextView ??= containerView.Subviews[0].FindNextView(0, isValidType);
Comment thread
jonathanpeppers marked this conversation as resolved.
Outdated

return nextView;
}

static UIView? FindNextView(this UIView view, UIView? origView, ref bool passedOriginal, Func<UIView, bool> isValidType)
static UIView? FindNextView(this UIView view, int index, Func<UIView, bool> isValidType)
{
foreach (var child in view.Subviews)
// search through the view's siblings and traverse down their branches
var siblings = view.Superview.Subviews;
for (int i = index; i < siblings.Length; i++)
{
if (isValidType(child))
if (siblings[i].Subviews.Length > 0)
Comment thread
jonathanpeppers marked this conversation as resolved.
Outdated
{
if (origView is null)
return child;

if (passedOriginal)
return child;

if (child == origView)
passedOriginal = true;
var childVal = siblings[i].Subviews[0].FindNextView(0, isValidType);
if (childVal is not null)
return childVal;
}

else if (child.Subviews.Length > 0 && !child.Hidden && child.Alpha > 0f)
{
var nextLevel = child.FindNextView(origView, ref passedOriginal, isValidType);
if (nextLevel is not null)
return nextLevel;
}
if (isValidType(siblings[i]))
return siblings[i];
}

return null;
Expand Down