From fad26898b435577c6a32c8a90333983f9c9cf34d Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 9 Dec 2024 01:13:34 +0100 Subject: [PATCH 1/5] avoid jsonDecoding `Segment` and `BarChartRod` tooltips --- packages/flet/lib/src/controls/barchart.dart | 5 ++--- packages/flet/lib/src/controls/segmented_button.dart | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/flet/lib/src/controls/barchart.dart b/packages/flet/lib/src/controls/barchart.dart index f3f3f2e01..ae585a451 100644 --- a/packages/flet/lib/src/controls/barchart.dart +++ b/packages/flet/lib/src/controls/barchart.dart @@ -263,9 +263,8 @@ class _BarChartControlState extends State { getTooltipItem: (group, groupIndex, rod, rodIndex) { var dp = viewModel.barGroups[groupIndex].barRods[rodIndex]; - var tooltip = dp.control.attrString("tooltip") != null - ? jsonDecode(dp.control.attrString("tooltip")!) - : dp.control.attrDouble("toY", 0)!.toString(); + var tooltip = dp.control.attrString("tooltip", + dp.control.attrDouble("toY", 0)!.toString())!; var tooltipStyle = parseTextStyle( Theme.of(context), dp.control, "tooltipStyle"); tooltipStyle ??= const TextStyle(); diff --git a/packages/flet/lib/src/controls/segmented_button.dart b/packages/flet/lib/src/controls/segmented_button.dart index 35763d530..c91fc9905 100644 --- a/packages/flet/lib/src/controls/segmented_button.dart +++ b/packages/flet/lib/src/controls/segmented_button.dart @@ -124,9 +124,7 @@ class _SegmentedButtonControlState extends State return ButtonSegment( value: segmentView.control.attrString("value")!, enabled: !segmentDisabled, - tooltip: !segmentDisabled && segmentTooltip != null - ? jsonDecode(segmentTooltip) - : null, + tooltip: segmentDisabled ? null : segmentTooltip, icon: iconCtrls.isNotEmpty ? createControl(segmentView.control, iconCtrls.first.id, segmentDisabled) From 6fb16940e143708430c51865b1e655d1306e5841 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 9 Dec 2024 01:18:37 +0100 Subject: [PATCH 2/5] avoid jsonEncoding `Segment` and `BarChartRod` tooltips --- .../packages/flet/src/flet/core/charts/bar_chart_rod.py | 2 +- sdk/python/packages/flet/src/flet/core/control.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/python/packages/flet/src/flet/core/charts/bar_chart_rod.py b/sdk/python/packages/flet/src/flet/core/charts/bar_chart_rod.py index d0728f25f..48c99f724 100644 --- a/sdk/python/packages/flet/src/flet/core/charts/bar_chart_rod.py +++ b/sdk/python/packages/flet/src/flet/core/charts/bar_chart_rod.py @@ -68,7 +68,7 @@ def __init__( self.tooltip_style = tooltip_style def _get_control_name(self): - return "rod" + return "bar_chart_rod" def before_update(self): super().before_update() diff --git a/sdk/python/packages/flet/src/flet/core/control.py b/sdk/python/packages/flet/src/flet/core/control.py index a7bd44323..46c392236 100644 --- a/sdk/python/packages/flet/src/flet/core/control.py +++ b/sdk/python/packages/flet/src/flet/core/control.py @@ -91,10 +91,12 @@ def before_update(self): pass def _before_build_command(self) -> None: - self._set_attr_json("col", self.__col) - self._set_attr_json("tooltip", self.tooltip) + if self._get_control_name() not in ["segment", "bar_chart_rod"]: + # see https://github.com/flet-dev/flet/pull/4525 + self._set_attr_json("tooltip", self.tooltip) if isinstance(self.badge, (Badge, str)): self._set_attr_json("badge", self.badge) + self._set_attr_json("col", self.__col) def did_mount(self): pass From c51c204cdef31bcce7add5daea2aff6ecba8c139 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 9 Dec 2024 01:50:23 +0100 Subject: [PATCH 3/5] Unset theme visual density default --- sdk/python/packages/flet/src/flet/core/theme.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/python/packages/flet/src/flet/core/theme.py b/sdk/python/packages/flet/src/flet/core/theme.py index e9a0711d4..f8ce4b0b8 100644 --- a/sdk/python/packages/flet/src/flet/core/theme.py +++ b/sdk/python/packages/flet/src/flet/core/theme.py @@ -888,6 +888,4 @@ class Theme: text_theme: Optional[TextTheme] = None time_picker_theme: Optional[TimePickerTheme] = None tooltip_theme: Optional[TooltipTheme] = None - visual_density: Union[VisualDensity, ThemeVisualDensity] = field( - default=VisualDensity.STANDARD - ) + visual_density: Union[VisualDensity, ThemeVisualDensity] = None From be971d9d07f51c83f60df3093804919694fb5816 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 9 Dec 2024 01:51:29 +0100 Subject: [PATCH 4/5] Unset `SegmentedButton` border side default --- packages/flet/lib/src/controls/segmented_button.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/flet/lib/src/controls/segmented_button.dart b/packages/flet/lib/src/controls/segmented_button.dart index c91fc9905..f838c9288 100644 --- a/packages/flet/lib/src/controls/segmented_button.dart +++ b/packages/flet/lib/src/controls/segmented_button.dart @@ -49,7 +49,6 @@ class _SegmentedButtonControlState extends State defaultSurfaceTintColor: theme.colorScheme.surfaceTint, defaultElevation: 1, defaultPadding: const EdgeInsets.symmetric(horizontal: 8), - defaultBorderSide: BorderSide.none, defaultShape: theme.useMaterial3 ? const StadiumBorder() : RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))); From 94a14adeb81c08ddd6a708e747b6ad86c24340e3 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 9 Dec 2024 02:02:05 +0100 Subject: [PATCH 5/5] `TextField.hint_text` should be displayed if `label` is not specified --- packages/flet/lib/src/utils/form_field.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/flet/lib/src/utils/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 720dc5816..b476ee1f1 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -154,7 +154,9 @@ InputDecoration buildInputDecoration(BuildContext context, Control control, label: label != null ? createControl(control, label.id, control.isDisabled, parentAdaptive: adaptive) - : Text(control.attrString("label", "")!), + : control.attrString("label") != null + ? Text(control.attrString("label")!) + : null, labelStyle: parseTextStyle(Theme.of(context), control, "labelStyle"), border: border, enabledBorder: border,