-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathPaddingBox.cs
35 lines (29 loc) · 1.01 KB
/
PaddingBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace UniMob.UI.Widgets
{
public class PaddingBox : SingleChildLayoutWidget
{
public PaddingBox(RectPadding padding)
{
Padding = padding;
}
public RectPadding Padding { get; }
public override State CreateState() => new PaddingBoxState();
}
internal class PaddingBoxState : SingleChildLayoutState<PaddingBox>, IPaddingBoxState
{
public override WidgetViewReference View { get; }
= WidgetViewReference.Resource("$$_PaddingBox");
public Alignment Alignment => Alignment.Center;
public RectPadding Padding => Widget.Padding;
public override WidgetSize CalculateSize()
{
var padding = Padding;
var (minW, minH, maxW, maxH) = base.CalculateSize();
minW += padding.Horizontal;
maxW += padding.Horizontal;
minH += padding.Vertical;
maxH += padding.Vertical;
return new WidgetSize(minW, minH, maxW, maxH);
}
}
}