Skip to content

Commit

Permalink
Minor edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbritch committed Jan 23, 2024
1 parent 2091039 commit 7591ff1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace CustomLayoutDemos.Layouts
{
public class HorizontalWrapLayout : StackLayout
public class HorizontalWrapLayout : HorizontalStackLayout
{
protected override ILayoutManager CreateLayoutManager()
{
return new HorizontalWrapLayoutManager(this);
}
}
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.Maui.Layouts;
using StackLayoutManager = Microsoft.Maui.Layouts.StackLayoutManager;
using HorizontalStackLayoutManager = Microsoft.Maui.Layouts.HorizontalStackLayoutManager;

namespace CustomLayoutDemos.Layouts
{
public class HorizontalWrapLayoutManager : StackLayoutManager
public class HorizontalWrapLayoutManager : HorizontalStackLayoutManager
{
HorizontalWrapLayout _layout;

Expand All @@ -26,7 +26,6 @@ public override Size Measure(double widthConstraint, double heightConstraint)
for (int n = 0; n < _layout.Count; n++)
{
var child = _layout[n];

if (child.Visibility == Visibility.Collapsed)
{
continue;
Expand Down Expand Up @@ -65,13 +64,13 @@ public override Size Measure(double widthConstraint, double heightConstraint)
totalWidth += padding.HorizontalThickness;
totalHeight += padding.VerticalThickness;

// Ensure that the total size of the layout fits within its constraints
var finalWidth = ResolveConstraints(widthConstraint, Stack.Width, totalWidth, Stack.MinimumWidth, Stack.MaximumWidth);
var finalHeight = ResolveConstraints(heightConstraint, Stack.Height, totalHeight, Stack.MinimumHeight, Stack.MaximumHeight);

return new Size(finalWidth, finalHeight);
}


public override Size ArrangeChildren(Rect bounds)
{
var padding = Stack.Padding;
Expand All @@ -87,7 +86,6 @@ public override Size ArrangeChildren(Rect bounds)
for (int n = 0; n < _layout.Count; n++)
{
var child = _layout[n];

if (child.Visibility == Visibility.Collapsed)
{
continue;
Expand All @@ -113,6 +111,7 @@ public override Size ArrangeChildren(Rect bounds)

var actual = new Size(maxStackWidth, currentRowTop + currentRowHeight);

// Adjust the size if the layout is set to fill its container
return actual.AdjustForFill(bounds, Stack);
}
}
Expand Down

0 comments on commit 7591ff1

Please sign in to comment.