From 391f00a952f55c3afa8112eee0f56e4f11d946e5 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Mon, 16 May 2022 19:06:47 -0700 Subject: [PATCH] Text max_lines --- client/lib/controls/list_tile.dart | 1 + client/lib/controls/text.dart | 3 +++ sdk/python/flet/text.py | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/client/lib/controls/list_tile.dart b/client/lib/controls/list_tile.dart index 0431e1a78..b651b3b36 100644 --- a/client/lib/controls/list_tile.dart +++ b/client/lib/controls/list_tile.dart @@ -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, diff --git a/client/lib/controls/text.dart b/client/lib/controls/text.dart index ac149efbc..4c6171091 100644 --- a/client/lib/controls/text.dart +++ b/client/lib/controls/text.dart @@ -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); @@ -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, diff --git a/sdk/python/flet/text.py b/sdk/python/flet/text.py index ddf2c0d64..3f73abef8 100644 --- a/sdk/python/flet/text.py +++ b/sdk/python/flet/text.py @@ -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, @@ -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 @@ -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):