Skip to content

Commit

Permalink
expand_loose property for Control and all controls that have `expan…
Browse files Browse the repository at this point in the history
…d` property (#2561)

* check for expandLoose in create_control.dart

* expand_loose property for Control, ConstrainedControl, Container

* expand_loose property for controls up to FloatingActionButton

* expand_loose property for controls up to ShaderMask

* expand_loose property for all controls that have expand property

* removed a comment
  • Loading branch information
InesaFitsner committed Feb 5, 2024
1 parent f46f407 commit a9cbed4
Show file tree
Hide file tree
Showing 74 changed files with 176 additions and 16 deletions.
7 changes: 6 additions & 1 deletion package/lib/src/controls/create_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,12 @@ Widget _expandable(Widget widget, Control? parent, Control control) {
parent.type == "row")) {
//debugPrint("Expandable ${control.id}");
int? expand = control.attrInt("expand");
return expand != null ? Expanded(flex: expand, child: widget) : widget;
var expandLoose = control.attrBool("expandLoose");
return expand != null
? (expandLoose == true)
? Flexible(flex: expand, child: widget)
: Expanded(flex: expand, child: widget)
: widget;
}
return widget;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -124,6 +125,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
12 changes: 7 additions & 5 deletions sdk/python/packages/flet-core/src/flet_core/bottom_app_bar.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import List, Optional, Union, Any
from typing import Any, List, Optional, Union

from flet_core.constrained_control import ConstrainedControl
from flet_core.control import Control, OptionalNumber
from flet_core.ref import Ref
from flet_core.types import (
AnimationValue,
ClipBehavior,
ClipBehaviorString,
NotchShape,
OffsetValue,
PaddingValue,
ResponsiveNumber,
RotateValue,
ScaleValue,
OffsetValue,
PaddingValue,
AnimationValue,
NotchShape,
)


Expand All @@ -36,6 +36,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -74,6 +75,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/canvas/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -61,6 +62,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -112,6 +113,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -68,7 +69,6 @@ def __init__(
max_y: OptionalNumber = None,
on_chart_event=None,
):

ConstrainedControl.__init__(
self,
ref=ref,
Expand All @@ -79,6 +79,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -72,7 +73,6 @@ def __init__(
max_y: OptionalNumber = None,
on_chart_event=None,
):

ConstrainedControl.__init__(
self,
ref=ref,
Expand All @@ -83,6 +83,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -55,7 +56,6 @@ def __init__(
animate: AnimationValue = None,
on_chart_event=None,
):

ConstrainedControl.__init__(
self,
ref=ref,
Expand All @@ -66,6 +66,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -108,6 +109,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
9 changes: 5 additions & 4 deletions sdk/python/packages/flet-core/src/flet_core/chip.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from typing import Any, Optional, Union

from flet_core.buttons import OutlinedBorder
from flet_core.constrained_control import ConstrainedControl
from flet_core.control import Control, OptionalNumber
from flet_core.ref import Ref
from flet_core.text_style import TextStyle
from flet_core.types import (
AnimationValue,
OffsetValue,
PaddingValue,
ResponsiveNumber,
RotateValue,
ScaleValue,
PaddingValue,
)

from flet_core.text_style import TextStyle
from flet_core.buttons import OutlinedBorder


class Chip(ConstrainedControl):
"""
Expand Down Expand Up @@ -73,6 +72,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -129,6 +129,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/circle_avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -119,6 +120,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -115,6 +116,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
self,
ref: Optional[Ref] = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
tooltip: Optional[str] = None,
Expand Down Expand Up @@ -48,6 +49,7 @@ def __init__(
self,
ref=ref,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
tooltip=tooltip,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -138,6 +139,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
11 changes: 11 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
self,
ref: Optional[Ref] = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
tooltip: Optional[str] = None,
Expand All @@ -39,6 +40,7 @@ def __init__(
self._id = None
self.__uid: Optional[str] = None
self.expand = expand
self.expand_loose = expand_loose
self.col = col
self.opacity = opacity
self.tooltip = tooltip
Expand Down Expand Up @@ -211,6 +213,15 @@ def expand(self, value: Union[None, bool, int]):
value = 1
self._set_attr("expand", value if value else None)

# expand_loose
@property
def expand_loose(self) -> Optional[bool]:
return self._get_attr("expandLoose", data_type="bool", def_value=False)

@expand_loose.setter
def expand_loose(self, value: Optional[bool]):
self._set_attr("expandLoose", value)

# col
@property
def col(self) -> Optional[ResponsiveNumber]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -79,6 +80,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -93,6 +94,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(
right: OptionalNumber = None,
bottom: OptionalNumber = None,
expand: Union[None, bool, int] = None,
expand_loose: Optional[bool] = None,
col: Optional[ResponsiveNumber] = None,
opacity: OptionalNumber = None,
rotate: RotateValue = None,
Expand Down Expand Up @@ -101,6 +102,7 @@ def __init__(
right=right,
bottom=bottom,
expand=expand,
expand_loose=expand_loose,
col=col,
opacity=opacity,
rotate=rotate,
Expand Down

0 comments on commit a9cbed4

Please sign in to comment.