From 7bcffdb2d2de8c2e0d330a7d2ba7e30d75ef0f07 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 20 Jul 2024 11:55:56 +0200 Subject: [PATCH 1/2] initial commit --- packages/flet/lib/src/controls/dropdown.dart | 23 +++++++++++-------- packages/flet/lib/src/controls/textfield.dart | 20 ++++++++-------- packages/flet/lib/src/utils/form_field.dart | 13 +++++++---- .../flet-core/src/flet_core/dropdown.py | 2 ++ .../src/flet_core/form_field_control.py | 14 +++++++++++ .../flet-core/src/flet_core/textfield.py | 2 ++ 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index b34e9e42f..768bba59d 100644 --- a/packages/flet/lib/src/controls/dropdown.dart +++ b/packages/flet/lib/src/controls/dropdown.dart @@ -147,6 +147,8 @@ class _DropdownControlState extends State with FletStoreMixin { .where((c) => c.control.name == "prefix" && c.control.isVisible); var suffixControls = itemsView.controlViews .where((c) => c.control.name == "suffix" && c.control.isVisible); + var counterControls = itemsView.controlViews + .where((c) => c.control.name == "counter" && c.control.isVisible); var focusValue = widget.control.attrString("focus"); if (focusValue != null && focusValue != _lastFocusValue) { @@ -179,15 +181,18 @@ class _DropdownControlState extends State with FletStoreMixin { hint: iconCtrl.isNotEmpty ? createControl(widget.control, hintCtrl.first.id, disabled) : null, - decoration: buildInputDecoration( - context, - widget.control, - prefixControls.isNotEmpty ? prefixControls.first.control : null, - suffixControls.isNotEmpty ? suffixControls.first.control : null, - null, - _focused, - disabled, - widget.parentAdaptive), + decoration: buildInputDecoration(context, widget.control, + prefix: + prefixControls.isNotEmpty ? prefixControls.first.control : null, + suffix: + suffixControls.isNotEmpty ? suffixControls.first.control : null, + counter: counterControls.isNotEmpty + ? counterControls.first.control + : null, + customSuffix: null, + focused: _focused, + disabled: disabled, + adaptive: widget.parentAdaptive), onTap: !disabled ? () { widget.backend.triggerControlEvent(widget.control.id, "click"); diff --git a/packages/flet/lib/src/controls/textfield.dart b/packages/flet/lib/src/controls/textfield.dart index 82ddeb6f0..5bd781e26 100644 --- a/packages/flet/lib/src/controls/textfield.dart +++ b/packages/flet/lib/src/controls/textfield.dart @@ -125,6 +125,8 @@ class _TextFieldControlState extends State widget.children.where((c) => c.name == "prefix" && c.isVisible); var suffixControls = widget.children.where((c) => c.name == "suffix" && c.isVisible); + var counterControls = + widget.children.where((c) => c.name == "counter" && c.isVisible); bool shiftEnter = widget.control.attrBool("shiftEnter", false)!; bool multiline = @@ -220,15 +222,15 @@ class _TextFieldControlState extends State .triggerControlEvent(widget.control.id, "submit", value); } : null, - decoration: buildInputDecoration( - context, - widget.control, - prefixControls.isNotEmpty ? prefixControls.first : null, - suffixControls.isNotEmpty ? suffixControls.first : null, - revealPasswordIcon, - _focused, - disabled, - adaptive), + decoration: buildInputDecoration(context, widget.control, + prefix: prefixControls.isNotEmpty ? prefixControls.first : null, + suffix: suffixControls.isNotEmpty ? suffixControls.first : null, + counter: + counterControls.isNotEmpty ? counterControls.first : null, + customSuffix: revealPasswordIcon, + focused: _focused, + disabled: disabled, + adaptive: adaptive), showCursor: widget.control.attrBool("showCursor"), textAlignVertical: textVerticalAlign != null ? TextAlignVertical(y: textVerticalAlign) diff --git a/packages/flet/lib/src/utils/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 7cc0fc103..109d52602 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -53,12 +53,13 @@ TextInputType? parseTextInputType(String? value, [TextInputType? defValue]) { InputDecoration buildInputDecoration( BuildContext context, Control control, - Control? prefix, + {Control? prefix, Control? suffix, + Control? counter, Widget? customSuffix, - bool focused, - bool disabled, - bool? adaptive) { + bool focused = false, + bool disabled = false, + bool? adaptive}) { String? label = control.attrString("label", "")!; FormFieldInputBorder inputBorder = parseFormFieldInputBorder( control.attrString("border"), @@ -141,6 +142,10 @@ InputDecoration buildInputDecoration( helperStyle: parseTextStyle(Theme.of(context), control, "helperStyle"), counterText: control.attrString("counterText"), counterStyle: parseTextStyle(Theme.of(context), control, "counterStyle"), + counter: counter != null + ? createControl(control, counter.id, control.isDisabled, + parentAdaptive: adaptive) + : null, errorText: control.attrString("errorText"), errorStyle: parseTextStyle(Theme.of(context), control, "errorStyle"), prefixIcon: prefixIcon != null ? Icon(prefixIcon) : null, diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown.py b/sdk/python/packages/flet-core/src/flet_core/dropdown.py index 99ecd06fb..dc286a8dc 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown.py @@ -197,6 +197,7 @@ def __init__( hint_style: Optional[TextStyle] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, @@ -287,6 +288,7 @@ def __init__( hint_style=hint_style, helper_text=helper_text, helper_style=helper_style, + counter=counter, counter_text=counter_text, counter_style=counter_style, error_text=error_text, diff --git a/sdk/python/packages/flet-core/src/flet_core/form_field_control.py b/sdk/python/packages/flet-core/src/flet_core/form_field_control.py index e9b658cca..79ad14f73 100644 --- a/sdk/python/packages/flet-core/src/flet_core/form_field_control.py +++ b/sdk/python/packages/flet-core/src/flet_core/form_field_control.py @@ -57,6 +57,7 @@ def __init__( hint_style: Optional[TextStyle] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, @@ -156,6 +157,7 @@ def __init__( self.hint_style = hint_style self.helper_text = helper_text self.helper_style = helper_style + self.counter = counter self.counter_text = counter_text self.counter_style = counter_style self.error_text = error_text @@ -192,6 +194,9 @@ def _get_children(self): if isinstance(self.__suffix, Control): self.__suffix._set_attr_internal("n", "suffix") children.append(self.__suffix) + if isinstance(self.__counter, Control): + self.__counter._set_attr_internal("n", "counter") + children.append(self.__counter) return children # text_size @@ -450,6 +455,15 @@ def prefix(self) -> Optional[Control]: def prefix(self, value: Optional[Control]): self.__prefix = value + # counter + @property + def counter(self) -> Optional[Control]: + return self.__counter + + @counter.setter + def counter(self, value: Optional[Control]): + self.__counter = value + # prefix_icon @property def prefix_icon(self) -> Optional[str]: diff --git a/sdk/python/packages/flet-core/src/flet_core/textfield.py b/sdk/python/packages/flet-core/src/flet_core/textfield.py index 90315ce42..51f4c29a4 100644 --- a/sdk/python/packages/flet-core/src/flet_core/textfield.py +++ b/sdk/python/packages/flet-core/src/flet_core/textfield.py @@ -156,6 +156,7 @@ def __init__( hint_style: Optional[TextStyle] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, @@ -251,6 +252,7 @@ def __init__( hint_style=hint_style, helper_text=helper_text, helper_style=helper_style, + counter=counter, counter_text=counter_text, counter_style=counter_style, error_text=error_text, From 671c94afe472e775bbdb73d77376530e7e60e944 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 20 Jul 2024 12:09:57 +0200 Subject: [PATCH 2/2] minor updates bug report template --- .github/ISSUE_TEMPLATE/01_bug_report.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/01_bug_report.yml b/.github/ISSUE_TEMPLATE/01_bug_report.yml index f41eb0794..35f49f364 100644 --- a/.github/ISSUE_TEMPLATE/01_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/01_bug_report.yml @@ -22,7 +22,7 @@ body: attributes: label: "Describe the bug" description: "A clear and concise description of the bug." - placeholder: Tell us what you see. + placeholder: Tell us in details what you see. validations: required: true - type: textarea @@ -41,7 +41,7 @@ body: Note: Please do not upload screenshots of text. Instead, use code blocks or the above mentioned ways to upload your code sample. value: | -
Logs +
Code ```python [Paste your code here] @@ -73,7 +73,7 @@ body: description: "One image is worth a thousand words. If you can, please provide screenshots or videos to help visually explain your issue." value: |
- Screenshots / Video demonstration + Captures [Upload media here] @@ -155,5 +155,3 @@ body: description: "Add any other detail about the issue here. Ex: happens only on specific conditions, etc." validations: required: false - -