Skip to content

Commit c7333dc

Browse files
Any control can be positioned absolutely inside Stack (#60)
All visible controls got 4 new properties: - left - top - right - bottom
1 parent b3763a6 commit c7333dc

27 files changed

+274
-4
lines changed

client/lib/controls/create_control.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ Widget baseControl(Widget widget, Control? parent, Control control) {
252252

253253
Widget constrainedControl(Widget widget, Control? parent, Control control) {
254254
return _expandable(
255-
_sizedControl(
256-
_tooltip(_opacity(widget, parent, control), parent, control),
255+
_positionedControl(
256+
_sizedControl(
257+
_tooltip(_opacity(widget, parent, control), parent, control),
258+
parent,
259+
control),
257260
parent,
258261
control),
259262
parent,
@@ -282,6 +285,25 @@ Widget _tooltip(Widget widget, Control? parent, Control control) {
282285
: widget;
283286
}
284287

288+
Widget _positionedControl(Widget widget, Control? parent, Control control) {
289+
var left = control.attrDouble("left", null);
290+
var top = control.attrDouble("top", null);
291+
var right = control.attrDouble("right", null);
292+
var bottom = control.attrDouble("bottom", null);
293+
294+
if (left != null || top != null || right != null || bottom != null) {
295+
debugPrint("Positioned");
296+
return Positioned(
297+
left: left,
298+
top: top,
299+
right: right,
300+
bottom: bottom,
301+
child: widget,
302+
);
303+
}
304+
return widget;
305+
}
306+
285307
Widget _sizedControl(Widget widget, Control? parent, Control control) {
286308
var width = control.attrDouble("width", null);
287309
var height = control.attrDouble("height", null);

sdk/python/flet/card.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(
1414
ref: Ref = None,
1515
width: OptionalNumber = None,
1616
height: OptionalNumber = None,
17+
left: OptionalNumber = None,
18+
top: OptionalNumber = None,
19+
right: OptionalNumber = None,
20+
bottom: OptionalNumber = None,
1721
expand: Union[bool, int] = None,
1822
opacity: OptionalNumber = None,
1923
tooltip: str = None,
@@ -32,6 +36,10 @@ def __init__(
3236
ref=ref,
3337
width=width,
3438
height=height,
39+
left=left,
40+
top=top,
41+
right=right,
42+
bottom=bottom,
3543
expand=expand,
3644
opacity=opacity,
3745
tooltip=tooltip,

sdk/python/flet/checkbox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def __init__(
2121
ref: Ref = None,
2222
width: OptionalNumber = None,
2323
height: OptionalNumber = None,
24+
left: OptionalNumber = None,
25+
top: OptionalNumber = None,
26+
right: OptionalNumber = None,
27+
bottom: OptionalNumber = None,
2428
expand: Union[bool, int] = None,
2529
opacity: OptionalNumber = None,
2630
tooltip: str = None,
@@ -44,6 +48,10 @@ def __init__(
4448
ref=ref,
4549
width=width,
4650
height=height,
51+
left=left,
52+
top=top,
53+
right=right,
54+
bottom=bottom,
4755
expand=expand,
4856
opacity=opacity,
4957
tooltip=tooltip,

sdk/python/flet/circle_avatar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(
1414
ref: Ref = None,
1515
width: OptionalNumber = None,
1616
height: OptionalNumber = None,
17+
left: OptionalNumber = None,
18+
top: OptionalNumber = None,
19+
right: OptionalNumber = None,
20+
bottom: OptionalNumber = None,
1721
expand: Union[bool, int] = None,
1822
opacity: OptionalNumber = None,
1923
tooltip: str = None,
@@ -37,6 +41,10 @@ def __init__(
3741
ref=ref,
3842
width=width,
3943
height=height,
44+
left=left,
45+
top=top,
46+
right=right,
47+
bottom=bottom,
4048
expand=expand,
4149
opacity=opacity,
4250
tooltip=tooltip,

sdk/python/flet/column.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def __init__(
2020
ref: Ref = None,
2121
width: OptionalNumber = None,
2222
height: OptionalNumber = None,
23+
left: OptionalNumber = None,
24+
top: OptionalNumber = None,
25+
right: OptionalNumber = None,
26+
bottom: OptionalNumber = None,
2327
expand: Union[bool, int] = None,
2428
opacity: OptionalNumber = None,
2529
visible: bool = None,
@@ -42,6 +46,10 @@ def __init__(
4246
ref=ref,
4347
width=width,
4448
height=height,
49+
left=left,
50+
top=top,
51+
right=right,
52+
bottom=bottom,
4553
expand=expand,
4654
opacity=opacity,
4755
visible=visible,

sdk/python/flet/constrained_control.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import Optional, Union
1+
from typing import Union
22

33
from beartype import beartype
44

5-
from flet.control import Control, InputBorder, OptionalNumber
5+
from flet.control import Control, OptionalNumber
66
from flet.ref import Ref
77

88

@@ -21,6 +21,10 @@ def __init__(
2121
#
2222
width: OptionalNumber = None,
2323
height: OptionalNumber = None,
24+
left: OptionalNumber = None,
25+
top: OptionalNumber = None,
26+
right: OptionalNumber = None,
27+
bottom: OptionalNumber = None,
2428
):
2529
Control.__init__(
2630
self,
@@ -35,6 +39,10 @@ def __init__(
3539

3640
self.width = width
3741
self.height = height
42+
self.left = left
43+
self.top = top
44+
self.right = right
45+
self.bottom = bottom
3846

3947
# width
4048
@property
@@ -55,3 +63,43 @@ def height(self) -> OptionalNumber:
5563
@beartype
5664
def height(self, value: OptionalNumber):
5765
self._set_attr("height", value)
66+
67+
# left
68+
@property
69+
def left(self) -> OptionalNumber:
70+
return self._get_attr("left")
71+
72+
@left.setter
73+
@beartype
74+
def left(self, value: OptionalNumber):
75+
self._set_attr("left", value)
76+
77+
# top
78+
@property
79+
def top(self) -> OptionalNumber:
80+
return self._get_attr("top")
81+
82+
@top.setter
83+
@beartype
84+
def top(self, value: OptionalNumber):
85+
self._set_attr("top", value)
86+
87+
# right
88+
@property
89+
def right(self) -> OptionalNumber:
90+
return self._get_attr("right")
91+
92+
@right.setter
93+
@beartype
94+
def right(self, value: OptionalNumber):
95+
self._set_attr("right", value)
96+
97+
# bottom
98+
@property
99+
def bottom(self) -> OptionalNumber:
100+
return self._get_attr("bottom")
101+
102+
@bottom.setter
103+
@beartype
104+
def bottom(self, value: OptionalNumber):
105+
self._set_attr("bottom", value)

sdk/python/flet/container.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def __init__(
2929
ref: Ref = None,
3030
width: OptionalNumber = None,
3131
height: OptionalNumber = None,
32+
left: OptionalNumber = None,
33+
top: OptionalNumber = None,
34+
right: OptionalNumber = None,
35+
bottom: OptionalNumber = None,
3236
expand: Union[bool, int] = None,
3337
opacity: OptionalNumber = None,
3438
tooltip: str = None,
@@ -52,6 +56,10 @@ def __init__(
5256
ref=ref,
5357
width=width,
5458
height=height,
59+
left=left,
60+
top=top,
61+
right=right,
62+
bottom=bottom,
5563
expand=expand,
5664
opacity=opacity,
5765
tooltip=tooltip,

sdk/python/flet/elevated_button.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(
1414
ref: Ref = None,
1515
width: OptionalNumber = None,
1616
height: OptionalNumber = None,
17+
left: OptionalNumber = None,
18+
top: OptionalNumber = None,
19+
right: OptionalNumber = None,
20+
bottom: OptionalNumber = None,
1721
expand: Union[bool, int] = None,
1822
opacity: OptionalNumber = None,
1923
tooltip: str = None,
@@ -37,6 +41,10 @@ def __init__(
3741
ref=ref,
3842
width=width,
3943
height=height,
44+
left=left,
45+
top=top,
46+
right=right,
47+
bottom=bottom,
4048
expand=expand,
4149
opacity=opacity,
4250
tooltip=tooltip,

sdk/python/flet/floating_action_button.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(
1414
ref: Ref = None,
1515
width: OptionalNumber = None,
1616
height: OptionalNumber = None,
17+
left: OptionalNumber = None,
18+
top: OptionalNumber = None,
19+
right: OptionalNumber = None,
20+
bottom: OptionalNumber = None,
1721
expand: Union[bool, int] = None,
1822
opacity: OptionalNumber = None,
1923
tooltip: str = None,
@@ -34,6 +38,10 @@ def __init__(
3438
ref=ref,
3539
width=width,
3640
height=height,
41+
left=left,
42+
top=top,
43+
right=right,
44+
bottom=bottom,
3745
expand=expand,
3846
opacity=opacity,
3947
tooltip=tooltip,

sdk/python/flet/form_field_control.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(
1414
ref: Ref = None,
1515
width: OptionalNumber = None,
1616
height: OptionalNumber = None,
17+
left: OptionalNumber = None,
18+
top: OptionalNumber = None,
19+
right: OptionalNumber = None,
20+
bottom: OptionalNumber = None,
1721
expand: Union[bool, int] = None,
1822
opacity: OptionalNumber = None,
1923
tooltip: str = None,
@@ -44,6 +48,10 @@ def __init__(
4448
ref=ref,
4549
width=width,
4650
height=height,
51+
left=left,
52+
top=top,
53+
right=right,
54+
bottom=bottom,
4755
expand=expand,
4856
opacity=opacity,
4957
tooltip=tooltip,

0 commit comments

Comments
 (0)