Skip to content

Commit

Permalink
Text max_lines
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed May 17, 2022
1 parent 6a6ae7f commit 391f00a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/lib/controls/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ListTileControl extends StatelessWidget {
selected: selected,
dense: dense,
onTap: onPressed,
enabled: !disabled,
leading: leadingCtrls.isNotEmpty
? createControl(control, leadingCtrls.first.id, disabled)
: null,
Expand Down
3 changes: 3 additions & 0 deletions client/lib/controls/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TextControl extends StatelessWidget {

String text = control.attrString("value", "")!;
bool noWrap = control.attrBool("noWrap", false)!;
int? maxLines = control.attrInt("maxLines");

TextStyle? style;
var styleName = control.attrString("style", null);
Expand Down Expand Up @@ -50,11 +51,13 @@ class TextControl extends StatelessWidget {
control.attrBool("selectable", false)!
? SelectableText(
text,
maxLines: maxLines,
style: style,
textAlign: textAlign,
)
: Text(
text,
maxLines: maxLines,
softWrap: !noWrap,
style: style,
textAlign: textAlign,
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/flet/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
weight: FontWeight = None,
italic: bool = None,
style: str = None,
max_lines: int = None,
overflow: TextOverflow = None,
selectable: bool = None,
no_wrap: bool = None,
Expand Down Expand Up @@ -79,6 +80,7 @@ def __init__(
self.italic = italic
self.no_wrap = no_wrap
self.style = style
self.max_lines = max_lines
self.overflow = overflow
self.selectable = selectable
self.color = color
Expand Down Expand Up @@ -166,6 +168,16 @@ def selectable(self):
def selectable(self, value: Optional[bool]):
self._set_attr("selectable", value)

# max_lines
@property
def max_lines(self):
return self._get_attr("maxLines")

@max_lines.setter
@beartype
def max_lines(self, value: Optional[int]):
self._set_attr("maxLines", value)

# overflow
@property
def overflow(self):
Expand Down

0 comments on commit 391f00a

Please sign in to comment.