Skip to content

Commit 37f7156

Browse files
committed
fix fluentconstraintset do two dp2px
1 parent 6297053 commit 37f7156

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

SharpConstraintLayout.Maui.Example/Pages/MainPage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,9 @@ private void BaseAlignTest(ConstraintLayout page)
524524
{
525525
(Button FirstButton, Button SecondButton, ContentView ThirdCanvas, Label FouthTextBlock, Entry FifthTextBox, Editor SixthRichTextBlock) = CreateControls();
526526

527-
FirstButton.Text = "CenterTo";
527+
FirstButton.Text = "CenterTo Width=100";
528528
SecondButton.Text = "RightToRight & TopToBottom";
529-
FouthTextBlock.Text = "CenterXTo & BottomToTop";
529+
FouthTextBlock.Text = "CenterXTo & BottomToTop(100)";
530530
FifthTextBox.Text = "CenterXTo & TopToBottom";
531531
SixthRichTextBlock.Text = "CenterXTo & TopToBottom";
532532
var layout = page;
@@ -540,7 +540,7 @@ private void BaseAlignTest(ConstraintLayout page)
540540
.Select(ThirdCanvas).Width(SizeBehavier.MatchConstraint).Height(SizeBehavier.MatchConstraint)
541541
.Select(SecondButton).RightToRight(FirstButton).TopToBottom(FirstButton)
542542
.Select(ThirdCanvas).LeftToRight(FirstButton).RightToRight().EdgesYTo()
543-
.Select(FouthTextBlock).CenterXTo().BottomToTop(FirstButton).Width(SizeBehavier.MatchConstraint)
543+
.Select(FouthTextBlock).CenterXTo().BottomToTop(FirstButton, 100).Width(SizeBehavier.MatchConstraint)
544544
.Select(FifthTextBox).CenterXTo().TopToBottom(SecondButton).Width(SizeBehavier.MatchConstraint)
545545
.Select(SixthRichTextBlock).CenterXTo().TopToBottom(FifthTextBox).Width(SizeBehavier.MatchConstraint);
546546
layoutSet.ApplyTo(layout);

SharpConstraintLayout.Maui.Example/Pages/MainPage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ protected override Size ArrangeOverride(Rect bounds)
113113
var FirstButton = new Button()
114114
{
115115
Text = "FirstButton",
116+
WidthRequest = 100
116117
//Background = new SolidColorBrush(Colors.Red)
117118
};
118119

SharpConstraintLayout.Maui/SharpConstraintLayout.Maui.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
1616
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
1717
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
18-
<Version>2.2.0</Version>
18+
<Version>2.2.1</Version>
1919
<Description>constraintlayout for maui</Description>
2020
<Copyright></Copyright>
2121
<PackageProjectUrl>https://github.com/xtuzy/SharpConstraintLayout</PackageProjectUrl>

SharpConstraintLayout.Maui/Widget/FluentConstraintSet.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ public Element LeftToLeft(UIElement secondView = null, float margin = 0)
261261
{
262262
if (secondView == null)
263263
{
264-
return this.LeftToLeft(ConstraintSet.ParentId, Dp2Px(margin));
264+
return this.LeftToLeft(ConstraintSet.ParentId, (margin));
265265
}
266-
return this.LeftToLeft(secondView.GetId(), Dp2Px(margin));
266+
return this.LeftToLeft(secondView.GetId(), (margin));
267267
}
268268

269269
protected Element LeftToRight(int secondView, float margin = 0)
@@ -278,9 +278,9 @@ public Element LeftToRight(UIElement secondView = null, float margin = 0)
278278
{
279279
if (secondView == null)
280280
{
281-
return this.LeftToRight(ConstraintSet.ParentId, Dp2Px(margin));
281+
return this.LeftToRight(ConstraintSet.ParentId, (margin));
282282
}
283-
return this.LeftToRight(secondView.GetId(), Dp2Px(margin));
283+
return this.LeftToRight(secondView.GetId(), (margin));
284284
}
285285

286286
protected Element TopToTop(int secondView, float margin = 0)
@@ -295,9 +295,9 @@ public Element TopToTop(UIElement secondView = null, float margin = 0)
295295
{
296296
if (secondView == null)
297297
{
298-
return this.TopToTop(ConstraintSet.ParentId, Dp2Px(margin));
298+
return this.TopToTop(ConstraintSet.ParentId, (margin));
299299
}
300-
return this.TopToTop(secondView.GetId(), Dp2Px(margin));
300+
return this.TopToTop(secondView.GetId(), (margin));
301301
}
302302

303303
protected Element TopToBottom(int secondView, float margin = 0)
@@ -312,9 +312,9 @@ public Element TopToBottom(UIElement secondView = null, float margin = 0)
312312
{
313313
if (secondView == null)
314314
{
315-
return this.TopToBottom(ConstraintSet.ParentId, Dp2Px(margin));
315+
return this.TopToBottom(ConstraintSet.ParentId, (margin));
316316
}
317-
return this.TopToBottom(secondView.GetId(), Dp2Px(margin));
317+
return this.TopToBottom(secondView.GetId(), (margin));
318318
}
319319

320320
protected Element RightToLeft(int secondView, float margin = 0)
@@ -329,9 +329,9 @@ public Element RightToLeft(UIElement secondView = null, float margin = 0)
329329
{
330330
if (secondView == null)
331331
{
332-
return this.RightToLeft(ConstraintSet.ParentId, Dp2Px(margin));
332+
return this.RightToLeft(ConstraintSet.ParentId, (margin));
333333
}
334-
return this.RightToLeft(secondView.GetId(), Dp2Px(margin));
334+
return this.RightToLeft(secondView.GetId(), (margin));
335335
}
336336

337337
protected Element RightToRight(int secondView, float margin = 0)
@@ -346,9 +346,9 @@ public Element RightToRight(UIElement secondView = null, float margin = 0)
346346
{
347347
if (secondView == null)
348348
{
349-
return this.RightToRight(ConstraintSet.ParentId, Dp2Px(margin));
349+
return this.RightToRight(ConstraintSet.ParentId, (margin));
350350
}
351-
return this.RightToRight(secondView.GetId(), Dp2Px(margin));
351+
return this.RightToRight(secondView.GetId(), (margin));
352352
}
353353

354354
protected Element BottomToTop(int secondView, float margin = 0)
@@ -363,9 +363,9 @@ public Element BottomToTop(UIElement secondView = null, float margin = 0)
363363
{
364364
if (secondView == null)
365365
{
366-
return this.BottomToTop(ConstraintSet.ParentId, Dp2Px(margin));
366+
return this.BottomToTop(ConstraintSet.ParentId, (margin));
367367
}
368-
return this.BottomToTop(secondView.GetId(), Dp2Px(margin));
368+
return this.BottomToTop(secondView.GetId(), (margin));
369369
}
370370

371371
protected Element BottomToBottom(int secondView, float margin = 0)
@@ -380,9 +380,9 @@ public Element BottomToBottom(UIElement secondView = null, float margin = 0)
380380
{
381381
if (secondView == null)
382382
{
383-
return this.BottomToBottom(ConstraintSet.ParentId, Dp2Px(margin));
383+
return this.BottomToBottom(ConstraintSet.ParentId, (margin));
384384
}
385-
return this.BottomToBottom(secondView.GetId(), Dp2Px(margin));
385+
return this.BottomToBottom(secondView.GetId(), (margin));
386386
}
387387

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

407407
public Element CenterTo(UIElement secondView = null)

0 commit comments

Comments
 (0)