Skip to content
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

fix(autolayout): Horizontal padding issue when spacebetween and independant. #503

Merged
merged 1 commit into from
Mar 15, 2023
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
40 changes: 25 additions & 15 deletions src/Uno.Toolkit.RuntimeTests/Tests/AutoLayoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ public async Task When_Padding(bool isStretch, Orientation orientation, int[] pa

[TestMethod]
[RequiresFullWindow]
public async Task When_Space_between_With_AbsolutePosition()
[DataRow(Orientation.Vertical, 10, 340, 280)]
[DataRow(Orientation.Horizontal, 10, 240, 100)]
public async Task When_Space_between_With_AbsolutePosition(Orientation orientation, double expected1, double expected2, double expected3)
{
var SUT = new AutoLayout()
{
Expand All @@ -248,35 +250,36 @@ public async Task When_Space_between_With_AbsolutePosition()
Justify = AutoLayoutJustify.SpaceBetween,
Width = 300,
Height = 400,
Orientation = orientation,
};

var border1 = new Border()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
Width = 200,
Height = 50,
Width = SUT.Orientation == Orientation.Vertical ? 200 : 50,
Height = SUT.Orientation == Orientation.Vertical ? 50 : 200,
};

var border2 = new Border()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
Width = 200,
Height = 50,
Width = SUT.Orientation == Orientation.Vertical ? 200 : 50,
Height = SUT.Orientation == Orientation.Vertical ? 50 : 200,
};

var border3 = new Border()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
Width = 200,
Height = 50,
Width = SUT.Orientation == Orientation.Vertical ? 200 : 50,
Height = SUT.Orientation == Orientation.Vertical ? 50 : 200,
};

var border4 = new Border()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
Width = 200,
Height = 50,
Margin = new Thickness(10, 280,0 ,0),
Width = SUT.Orientation == Orientation.Vertical ? 200 : 50,
Height = SUT.Orientation == Orientation.Vertical ? 50 : 200,
Margin = SUT.Orientation == Orientation.Vertical ? new Thickness(10, 280,0 ,0) : new Thickness(100, 10, 0, 0),
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
};
Expand All @@ -294,10 +297,17 @@ public async Task When_Space_between_With_AbsolutePosition()
var border3Transform = (MatrixTransform)border3.TransformToVisual(SUT);
var border4Transform = (MatrixTransform)border4.TransformToVisual(SUT);


Assert.AreEqual(10, border1Transform!.Matrix.OffsetY!);
Assert.AreEqual(340, border3Transform!.Matrix.OffsetY!);
Assert.AreEqual(280, border4Transform!.Matrix.OffsetY!);
if (orientation == Orientation.Vertical)
{
Assert.AreEqual(expected1, border1Transform!.Matrix.OffsetY!);
Assert.AreEqual(expected2, border3Transform!.Matrix.OffsetY!);
Assert.AreEqual(expected3, border4Transform!.Matrix.OffsetY!);
}
else
{
Assert.AreEqual(expected1, border1Transform!.Matrix.OffsetX!);
Assert.AreEqual(expected2, border3Transform!.Matrix.OffsetX!);
Assert.AreEqual(expected3, border4Transform!.Matrix.OffsetX!);
}
}

}
2 changes: 1 addition & 1 deletion src/Uno.Toolkit.UI/Controls/AutoLayout/AutoLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ private void UpdateAutoLayout()
}
}

if (hasIndependentLayout && atLeastOneChildFillAvailableSpaceInPrimaryAxis is not true && PrimaryAxisAlignment != AutoLayoutAlignment.End)
if (hasIndependentLayout && atLeastOneChildFillAvailableSpaceInPrimaryAxis is not true && PrimaryAxisAlignment != AutoLayoutAlignment.End && !hasSpaceBetween)
{
//We need to make sure that the independent layout can span all across his parent
_grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
Expand Down