Skip to content

Commit

Permalink
fix fluentconstraintset do two dp2px
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuzy committed May 10, 2023
1 parent 6297053 commit 37f7156
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
6 changes: 3 additions & 3 deletions SharpConstraintLayout.Maui.Example/Pages/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ private void BaseAlignTest(ConstraintLayout page)
{
(Button FirstButton, Button SecondButton, ContentView ThirdCanvas, Label FouthTextBlock, Entry FifthTextBox, Editor SixthRichTextBlock) = CreateControls();

FirstButton.Text = "CenterTo";
FirstButton.Text = "CenterTo Width=100";
SecondButton.Text = "RightToRight & TopToBottom";
FouthTextBlock.Text = "CenterXTo & BottomToTop";
FouthTextBlock.Text = "CenterXTo & BottomToTop(100)";
FifthTextBox.Text = "CenterXTo & TopToBottom";
SixthRichTextBlock.Text = "CenterXTo & TopToBottom";
var layout = page;
Expand All @@ -540,7 +540,7 @@ private void BaseAlignTest(ConstraintLayout page)
.Select(ThirdCanvas).Width(SizeBehavier.MatchConstraint).Height(SizeBehavier.MatchConstraint)
.Select(SecondButton).RightToRight(FirstButton).TopToBottom(FirstButton)
.Select(ThirdCanvas).LeftToRight(FirstButton).RightToRight().EdgesYTo()
.Select(FouthTextBlock).CenterXTo().BottomToTop(FirstButton).Width(SizeBehavier.MatchConstraint)
.Select(FouthTextBlock).CenterXTo().BottomToTop(FirstButton, 100).Width(SizeBehavier.MatchConstraint)
.Select(FifthTextBox).CenterXTo().TopToBottom(SecondButton).Width(SizeBehavier.MatchConstraint)
.Select(SixthRichTextBlock).CenterXTo().TopToBottom(FifthTextBox).Width(SizeBehavier.MatchConstraint);
layoutSet.ApplyTo(layout);
Expand Down
1 change: 1 addition & 0 deletions SharpConstraintLayout.Maui.Example/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected override Size ArrangeOverride(Rect bounds)
var FirstButton = new Button()
{
Text = "FirstButton",
WidthRequest = 100
//Background = new SolidColorBrush(Colors.Red)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<Description>constraintlayout for maui</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/xtuzy/SharpConstraintLayout</PackageProjectUrl>
Expand Down
36 changes: 18 additions & 18 deletions SharpConstraintLayout.Maui/Widget/FluentConstraintSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ public Element LeftToLeft(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.LeftToLeft(ConstraintSet.ParentId, Dp2Px(margin));
return this.LeftToLeft(ConstraintSet.ParentId, (margin));
}
return this.LeftToLeft(secondView.GetId(), Dp2Px(margin));
return this.LeftToLeft(secondView.GetId(), (margin));
}

protected Element LeftToRight(int secondView, float margin = 0)
Expand All @@ -278,9 +278,9 @@ public Element LeftToRight(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.LeftToRight(ConstraintSet.ParentId, Dp2Px(margin));
return this.LeftToRight(ConstraintSet.ParentId, (margin));
}
return this.LeftToRight(secondView.GetId(), Dp2Px(margin));
return this.LeftToRight(secondView.GetId(), (margin));
}

protected Element TopToTop(int secondView, float margin = 0)
Expand All @@ -295,9 +295,9 @@ public Element TopToTop(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.TopToTop(ConstraintSet.ParentId, Dp2Px(margin));
return this.TopToTop(ConstraintSet.ParentId, (margin));
}
return this.TopToTop(secondView.GetId(), Dp2Px(margin));
return this.TopToTop(secondView.GetId(), (margin));
}

protected Element TopToBottom(int secondView, float margin = 0)
Expand All @@ -312,9 +312,9 @@ public Element TopToBottom(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.TopToBottom(ConstraintSet.ParentId, Dp2Px(margin));
return this.TopToBottom(ConstraintSet.ParentId, (margin));
}
return this.TopToBottom(secondView.GetId(), Dp2Px(margin));
return this.TopToBottom(secondView.GetId(), (margin));
}

protected Element RightToLeft(int secondView, float margin = 0)
Expand All @@ -329,9 +329,9 @@ public Element RightToLeft(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.RightToLeft(ConstraintSet.ParentId, Dp2Px(margin));
return this.RightToLeft(ConstraintSet.ParentId, (margin));
}
return this.RightToLeft(secondView.GetId(), Dp2Px(margin));
return this.RightToLeft(secondView.GetId(), (margin));
}

protected Element RightToRight(int secondView, float margin = 0)
Expand All @@ -346,9 +346,9 @@ public Element RightToRight(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.RightToRight(ConstraintSet.ParentId, Dp2Px(margin));
return this.RightToRight(ConstraintSet.ParentId, (margin));
}
return this.RightToRight(secondView.GetId(), Dp2Px(margin));
return this.RightToRight(secondView.GetId(), (margin));
}

protected Element BottomToTop(int secondView, float margin = 0)
Expand All @@ -363,9 +363,9 @@ public Element BottomToTop(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.BottomToTop(ConstraintSet.ParentId, Dp2Px(margin));
return this.BottomToTop(ConstraintSet.ParentId, (margin));
}
return this.BottomToTop(secondView.GetId(), Dp2Px(margin));
return this.BottomToTop(secondView.GetId(), (margin));
}

protected Element BottomToBottom(int secondView, float margin = 0)
Expand All @@ -380,9 +380,9 @@ public Element BottomToBottom(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.BottomToBottom(ConstraintSet.ParentId, Dp2Px(margin));
return this.BottomToBottom(ConstraintSet.ParentId, (margin));
}
return this.BottomToBottom(secondView.GetId(), Dp2Px(margin));
return this.BottomToBottom(secondView.GetId(), (margin));
}

[Obsolete("Maui have a complex text align, generate bug easily, so i avoid use baseline")]
Expand All @@ -399,9 +399,9 @@ public Element BaselineToBaseline(UIElement secondView = null, float margin = 0)
{
if (secondView == null)
{
return this.BaselineToBaseline(ConstraintSet.ParentId, Dp2Px(margin));
return this.BaselineToBaseline(ConstraintSet.ParentId, (margin));
}
return this.BaselineToBaseline(secondView.GetId(), Dp2Px(margin));
return this.BaselineToBaseline(secondView.GetId(), (margin));
}

public Element CenterTo(UIElement secondView = null)
Expand Down

0 comments on commit 37f7156

Please sign in to comment.