Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand_loose property for Control and all controls that have expand property #2561

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1057,7 +1057,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
Loading