From a999ab1e53b19f36db4638177da96bbac4f5070a Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 13 Jul 2024 08:27:45 +0200 Subject: [PATCH 01/10] make ButtonStyle args optional --- packages/flet/lib/src/utils/buttons.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/flet/lib/src/utils/buttons.dart b/packages/flet/lib/src/utils/buttons.dart index f35f27722..85474cf63 100644 --- a/packages/flet/lib/src/utils/buttons.dart +++ b/packages/flet/lib/src/utils/buttons.dart @@ -15,15 +15,15 @@ import 'text.dart'; import 'theme.dart'; ButtonStyle? parseButtonStyle(ThemeData theme, Control control, String propName, - {required Color defaultForegroundColor, - required Color defaultBackgroundColor, - required Color defaultOverlayColor, - required Color defaultShadowColor, - required Color defaultSurfaceTintColor, - required double defaultElevation, - required EdgeInsets defaultPadding, - required BorderSide defaultBorderSide, - required OutlinedBorder defaultShape}) { + {Color? defaultForegroundColor, + Color? defaultBackgroundColor, + Color? defaultOverlayColor, + Color? defaultShadowColor, + Color? defaultSurfaceTintColor, + double? defaultElevation, + EdgeInsets? defaultPadding, + BorderSide? defaultBorderSide, + OutlinedBorder? defaultShape}) { var v = control.attrString(propName, null); if (v == null) { return null; From 029eb750071501b5042d78a59a5853e93f705d28 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 13 Jul 2024 08:28:07 +0200 Subject: [PATCH 02/10] parseDuration --- packages/flet/lib/src/utils/time.dart | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/flet/lib/src/utils/time.dart diff --git a/packages/flet/lib/src/utils/time.dart b/packages/flet/lib/src/utils/time.dart new file mode 100644 index 000000000..844ef1b72 --- /dev/null +++ b/packages/flet/lib/src/utils/time.dart @@ -0,0 +1,25 @@ +import 'dart:convert'; + +import '../models/control.dart'; +import 'numbers.dart'; + +Duration? parseDuration(Control control, String propName, + {Duration? defaultValue}) { + var v = control.attrString(propName, null); + if (v == null) { + return null; + } + + final j1 = json.decode(v); + return durationFromJSON(j1); +} + +Duration? durationFromJSON(Map json) { + return Duration( + days: parseInt(json["days"], 0)!, + hours: parseInt(json["hours"], 0)!, + minutes: parseInt(json["minutes"], 0)!, + seconds: parseInt(json["seconds"], 0)!, + milliseconds: parseInt(json["milliseconds"], 0)!, + microseconds: parseInt(json["microseconds"], 0)!); +} From a921b2fcbb003f8e9260eb91295bc71f4da7bc8d Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 13 Jul 2024 08:28:52 +0200 Subject: [PATCH 03/10] buildInputDecorationTheme --- packages/flet/lib/src/utils/form_field.dart | 117 ++++++++++++++++++-- 1 file changed, 108 insertions(+), 9 deletions(-) diff --git a/packages/flet/lib/src/utils/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 7cc0fc103..7b0f42a48 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -8,6 +8,7 @@ import 'borders.dart'; import 'edge_insets.dart'; import 'icons.dart'; import 'text.dart'; +import 'time.dart'; enum FormFieldInputBorder { outline, underline, none } @@ -64,6 +65,7 @@ InputDecoration buildInputDecoration( control.attrString("border"), FormFieldInputBorder.outline, )!; + var theme = Theme.of(context); var icon = parseIcon(control.attrString("icon")); var prefixIcon = parseIcon(control.attrString("prefixIcon")); @@ -102,7 +104,7 @@ InputDecoration buildInputDecoration( ? BorderSide.none : BorderSide( color: borderColor ?? - Theme.of(context).colorScheme.onSurface.withOpacity(0.38), + theme.colorScheme.onSurface.withOpacity(0.38), width: borderWidth ?? 1.0)); } } @@ -118,7 +120,7 @@ InputDecoration buildInputDecoration( : BorderSide( color: focusedBorderColor ?? borderColor ?? - Theme.of(context).colorScheme.primary, + theme.colorScheme.primary, width: focusedBorderWidth ?? borderWidth ?? 2.0)); } @@ -127,7 +129,7 @@ InputDecoration buildInputDecoration( contentPadding: parseEdgeInsets(control, "contentPadding"), isDense: control.attrBool("dense"), label: label != "" ? Text(label) : null, - labelStyle: parseTextStyle(Theme.of(context), control, "labelStyle"), + labelStyle: parseTextStyle(theme, control, "labelStyle"), border: border, enabledBorder: border, focusedBorder: focusedBorder, @@ -136,16 +138,16 @@ InputDecoration buildInputDecoration( filled: control.attrBool("filled", false)!, fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), hintText: control.attrString("hintText"), - hintStyle: parseTextStyle(Theme.of(context), control, "hintStyle"), + hintStyle: parseTextStyle(theme, control, "hintStyle"), helperText: control.attrString("helperText"), - helperStyle: parseTextStyle(Theme.of(context), control, "helperStyle"), + helperStyle: parseTextStyle(theme, control, "helperStyle"), counterText: control.attrString("counterText"), - counterStyle: parseTextStyle(Theme.of(context), control, "counterStyle"), + counterStyle: parseTextStyle(theme, control, "counterStyle"), errorText: control.attrString("errorText"), - errorStyle: parseTextStyle(Theme.of(context), control, "errorStyle"), + errorStyle: parseTextStyle(theme, control, "errorStyle"), prefixIcon: prefixIcon != null ? Icon(prefixIcon) : null, prefixText: prefixText, - prefixStyle: parseTextStyle(Theme.of(context), control, "prefixStyle"), + prefixStyle: parseTextStyle(theme, control, "prefixStyle"), prefix: prefix != null ? createControl(control, prefix.id, control.isDisabled, parentAdaptive: adaptive) @@ -156,7 +158,104 @@ InputDecoration buildInputDecoration( : null, suffixIcon: suffixIcon != null ? Icon(suffixIcon) : customSuffix, suffixText: suffixText, - suffixStyle: parseTextStyle(Theme.of(context), control, "suffixStyle")); + suffixStyle: parseTextStyle(theme, control, "suffixStyle")); +} + +InputDecorationTheme buildInputDecorationTheme( + BuildContext context, + Control control, + Control? prefix, + Control? suffix, + Widget? customSuffix, + bool focused, + bool disabled, + bool? adaptive) { + FormFieldInputBorder inputBorder = parseFormFieldInputBorder( + control.attrString("border"), + FormFieldInputBorder.outline, + )!; + var theme = Theme.of(context); + + var bgcolor = control.attrColor("bgcolor", context); + var focusedBgcolor = control.attrColor("focusedBgcolor", context); + var fillColor = control.attrColor("fillColor", context); + var hoverColor = control.attrColor("hoverColor", context); + var borderColor = control.attrColor("borderColor", context); + + var borderRadius = parseBorderRadius(control, "borderRadius"); + var focusedBorderColor = control.attrColor("focusedBorderColor", context); + var borderWidth = control.attrDouble("borderWidth"); + var focusedBorderWidth = control.attrDouble("focusedBorderWidth"); + + InputBorder? border; + if (inputBorder == FormFieldInputBorder.underline) { + border = const UnderlineInputBorder(); + } else if (inputBorder == FormFieldInputBorder.none) { + border = InputBorder.none; + } else if (inputBorder == FormFieldInputBorder.outline || + borderRadius != null || + borderColor != null || + borderWidth != null) { + border = const OutlineInputBorder(); + if (borderRadius != null) { + border = + (border as OutlineInputBorder).copyWith(borderRadius: borderRadius); + } + if (borderColor != null || borderWidth != null) { + border = (border as OutlineInputBorder).copyWith( + borderSide: borderWidth == 0 + ? BorderSide.none + : BorderSide( + color: borderColor ?? + theme.colorScheme.onSurface.withOpacity(0.38), + width: borderWidth ?? 1.0)); + } + } + + InputBorder? focusedBorder; + if (borderColor != null || + borderWidth != null || + focusedBorderColor != null || + focusedBorderWidth != null) { + focusedBorder = border?.copyWith( + borderSide: borderWidth == 0 + ? BorderSide.none + : BorderSide( + color: focusedBorderColor ?? + borderColor ?? + theme.colorScheme.primary, + width: focusedBorderWidth ?? borderWidth ?? 2.0)); + } + + return InputDecorationTheme( + contentPadding: parseEdgeInsets(control, "contentPadding"), + isDense: control.attrBool("dense", false)!, + labelStyle: parseTextStyle(theme, control, "labelStyle"), + border: border, + enabledBorder: border, + focusedBorder: focusedBorder, + hoverColor: hoverColor, + filled: control.attrBool("filled", false)!, + fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), + hintStyle: parseTextStyle(theme, control, "hintStyle"), + helperStyle: parseTextStyle(theme, control, "helperStyle"), + counterStyle: parseTextStyle(theme, control, "counterStyle"), + errorStyle: parseTextStyle(theme, control, "errorStyle"), + prefixStyle: parseTextStyle(theme, control, "prefixStyle"), + suffixStyle: parseTextStyle(theme, control, "suffixStyle"), + iconColor: control.attrColor("iconColor", context), + alignLabelWithHint: control.attrBool("alignLabelWithHint", false)!, + prefixIconColor: control.attrColor("prefixIconColor", context), + suffixIconColor: control.attrColor("suffixIconColor", context), + errorMaxLines: control.attrInt("errorMaxLines"), + helperMaxLines: control.attrInt("helperMaxLines"), + focusColor: control.attrColor("focusColor", context), + floatingLabelStyle: + parseTextStyle(theme, control, "floatingLabelTextStyle"), + activeIndicatorBorder: + parseBorderSide(theme, control, "activeIndicatorBorderSide"), + hintFadeDuration: parseDuration(control, "hintFadeDuration"), + ); } OverlayVisibilityMode parseVisibilityMode(String type) { From 6ff0d6ce4b93f7f16c0a90bd9d4000e0e9181564 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 13 Jul 2024 08:34:10 +0200 Subject: [PATCH 04/10] DropdownMenu --- .../flet/lib/src/controls/create_control.dart | 27 +- packages/flet/lib/src/controls/dropdown.dart | 2 +- .../flet/lib/src/controls/dropdown_menu.dart | 232 +++++++++ .../flet-core/src/flet_core/__init__.py | 3 + .../flet-core/src/flet_core/dropdown_menu.py | 475 ++++++++++++++++++ .../src/flet_core/form_field_control.py | 122 ++++- .../packages/flet-core/src/flet_core/types.py | 11 + 7 files changed, 861 insertions(+), 11 deletions(-) create mode 100644 packages/flet/lib/src/controls/dropdown_menu.dart create mode 100644 sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py diff --git a/packages/flet/lib/src/controls/create_control.dart b/packages/flet/lib/src/controls/create_control.dart index 4342604ce..6b88728b8 100644 --- a/packages/flet/lib/src/controls/create_control.dart +++ b/packages/flet/lib/src/controls/create_control.dart @@ -58,6 +58,7 @@ import 'divider.dart'; import 'drag_target.dart'; import 'draggable.dart'; import 'dropdown.dart'; +import 'dropdown_menu.dart'; import 'elevated_button.dart'; import 'error.dart'; import 'expansion_panel.dart'; @@ -820,6 +821,15 @@ Widget createWidget( control: controlView.control, parentDisabled: parentDisabled, backend: backend); + case "dropdownmenu": + return DropdownMenuControl( + key: key, + parent: parent, + control: controlView.control, + children: controlView.children, + parentDisabled: parentDisabled, + parentAdaptive: parentAdaptive, + backend: backend); case "dropdown": return DropdownControl( key: key, @@ -1218,15 +1228,14 @@ Widget _positionedControl( } Widget _sizedControl(Widget widget, Control? parent, Control control) { - var width = control.attrDouble("width", null); - var height = control.attrDouble("height", null); - if (width != null || height != null) { - if (control.type != "container" && control.type != "image") { - widget = ConstrainedBox( - constraints: BoxConstraints.tightFor(width: width, height: height), - child: widget, - ); - } + var width = control.attrDouble("width"); + var height = control.attrDouble("height"); + if ((width != null || height != null) && + !["container", "image"].contains(control.type)) { + widget = ConstrainedBox( + constraints: BoxConstraints.tightFor(width: width, height: height), + child: widget, + ); } var animation = parseAnimation(control, "animateSize"); if (animation != null) { diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index b34e9e42f..7b890ee9d 100644 --- a/packages/flet/lib/src/controls/dropdown.dart +++ b/packages/flet/lib/src/controls/dropdown.dart @@ -176,7 +176,7 @@ class _DropdownControlState extends State with FletStoreMixin { icon: iconCtrl.isNotEmpty ? createControl(widget.control, iconCtrl.first.id, disabled) : null, - hint: iconCtrl.isNotEmpty + hint: hintCtrl.isNotEmpty ? createControl(widget.control, hintCtrl.first.id, disabled) : null, decoration: buildInputDecoration( diff --git a/packages/flet/lib/src/controls/dropdown_menu.dart b/packages/flet/lib/src/controls/dropdown_menu.dart new file mode 100644 index 000000000..2043475fa --- /dev/null +++ b/packages/flet/lib/src/controls/dropdown_menu.dart @@ -0,0 +1,232 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../flet_control_backend.dart'; +import '../models/control.dart'; +import '../models/control_view_model.dart'; +import '../utils/buttons.dart'; +import '../utils/edge_insets.dart'; +import '../utils/icons.dart'; +import '../utils/menu.dart'; +import '../utils/text.dart'; +import '../utils/textfield.dart'; +import 'create_control.dart'; +import 'flet_store_mixin.dart'; +import 'textfield.dart'; + +class DropdownMenuControl extends StatefulWidget { + final Control? parent; + final Control control; + final List children; + final bool parentDisabled; + final bool? parentAdaptive; + final FletControlBackend backend; + + const DropdownMenuControl( + {super.key, + this.parent, + required this.control, + required this.children, + required this.parentDisabled, + required this.parentAdaptive, + required this.backend}); + + @override + State createState() => _DropdownMenuControlState(); +} + +class _DropdownMenuControlState extends State + with FletStoreMixin { + String? _value; + bool _focused = false; + late final FocusNode _focusNode; + String? _lastFocusValue; + + @override + void initState() { + super.initState(); + _focusNode = FocusNode(); + _focusNode.addListener(_onFocusChange); + } + + void _onFocusChange() { + setState(() { + _focused = _focusNode.hasFocus; + }); + widget.backend.triggerControlEvent( + widget.control.id, _focusNode.hasFocus ? "focus" : "blur"); + } + + @override + void dispose() { + _focusNode.removeListener(_onFocusChange); + _focusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + debugPrint("DropdownMenu build: ${widget.control.id}"); + return withControls(widget.control.childIds, (context, itemsView) { + debugPrint("DropdownMenuFletControlState build: ${widget.control.id}"); + + bool disabled = widget.control.isDisabled || widget.parentDisabled; + + var textSize = widget.control.attrDouble("textSize"); + var label = widget.control.attrString("label"); + var suffixCtrl = + widget.children.where((c) => c.name == "suffix" && c.isVisible); + var selectedSuffixCtrl = widget.children + .where((c) => c.name == "selectedSuffix" && c.isVisible); + var prefixCtrl = + widget.children.where((c) => c.name == "prefix" && c.isVisible); + var labelCtrl = + widget.children.where((c) => c.name == "label" && c.isVisible); + var selectedSuffixIcon = widget.control.attrString("selectedSuffixIcon"); + var prefixIcon = widget.control.attrString("prefixIcon"); + var suffixIcon = widget.control.attrString("suffixIcon"); + var color = widget.control.attrColor("color", context); + var focusedColor = widget.control.attrColor("focusedColor", context); + + TextStyle? textStyle = + parseTextStyle(Theme.of(context), widget.control, "textStyle"); + if (textSize != null || color != null || focusedColor != null) { + textStyle = (textStyle ?? const TextStyle()).copyWith( + fontSize: textSize, + color: (_focused ? focusedColor ?? color : color) ?? + Theme.of(context).colorScheme.onSurface); + } + + var items = itemsView.controlViews + .where((c) => + c.control.name == null && + c.control.type == "dropdownmenuoption" && + c.control.isVisible) + .map>((ControlViewModel itemCtrlView) { + var itemCtrl = itemCtrlView.control; + bool itemDisabled = disabled || itemCtrl.isDisabled; + ButtonStyle? style = + parseButtonStyle(Theme.of(context), itemCtrl, "style"); + + var contentCtrls = itemCtrlView.children + .where((c) => c.name == "content" && c.isVisible); + + var prefixIconCtrls = itemCtrlView.children + .where((c) => c.name == "prefix" && c.isVisible); + var suffixIconCtrls = itemCtrlView.children + .where((c) => c.name == "suffix" && c.isVisible); + + return DropdownMenuEntry( + enabled: !itemDisabled, + value: itemCtrl.attrs["key"] ?? itemCtrl.attrs["text"] ?? itemCtrl.id, + label: itemCtrl.attrs["text"] ?? itemCtrl.attrs["key"] ?? itemCtrl.id, + labelWidget: contentCtrls.isNotEmpty + ? createControl( + itemCtrlView.control, contentCtrls.first.id, itemDisabled) + : null, + leadingIcon: prefixIconCtrls.isNotEmpty + ? createControl( + itemCtrlView.control, prefixIconCtrls.first.id, itemDisabled) + : itemCtrlView.control.attrString("prefixIcon") != null + ? Icon( + parseIcon(itemCtrlView.control.attrString("prefixIcon"))) + : null, + trailingIcon: suffixIconCtrls.isNotEmpty + ? createControl( + itemCtrlView.control, suffixIconCtrls.first.id, itemDisabled) + : itemCtrlView.control.attrString("suffixIcon") != null + ? Icon( + parseIcon(itemCtrlView.control.attrString("suffixIcon"))) + : null, + style: style, + ); + }).toList(); + + String? value = widget.control.attrString("value"); + if (_value != value) { + _value = value; + } + + if (items.where((item) => item.value == value).isEmpty) { + _value = null; + } + + var focusValue = widget.control.attrString("focus"); + if (focusValue != null && focusValue != _lastFocusValue) { + _lastFocusValue = focusValue; + _focusNode.requestFocus(); + } + + TextCapitalization textCapitalization = parseTextCapitalization( + widget.control.attrString("capitalization"), + TextCapitalization.none)!; + + FilteringTextInputFormatter? inputFilter = + parseInputFilter(widget.control, "inputFilter"); + + List? inputFormatters = []; + // add non-null input formatters + if (inputFilter != null) { + inputFormatters.add(inputFilter); + } + if (textCapitalization != TextCapitalization.none) { + inputFormatters.add(TextCapitalizationFormatter(textCapitalization)); + } + + Widget dropDown = DropdownMenu( + enabled: !disabled, + enableFilter: widget.control.attrBool("enableFilter", false)!, + enableSearch: widget.control.attrBool("enableSearch", true)!, + errorText: widget.control.attrString("errorText"), + helperText: widget.control.attrString("helperText"), + hintText: widget.control.attrString("hintText"), + initialSelection: _value, + requestFocusOnTap: widget.control.attrBool("requestFocusOnTap", true)!, + menuHeight: widget.control.attrDouble("menuHeight"), + width: widget.control.attrDouble("width"), + textStyle: textStyle, + inputFormatters: inputFormatters, + expandedInsets: parseEdgeInsets(widget.control, "expandedInsets"), + menuStyle: parseMenuStyle(Theme.of(context), widget.control, "style"), + focusNode: _focusNode, + label: labelCtrl.isNotEmpty + ? createControl(widget.control, labelCtrl.first.id, disabled) + : label != null + ? Text(label, + style: parseTextStyle( + Theme.of(context), widget.control, "labelStyle")) + : null, + trailingIcon: suffixCtrl.isNotEmpty + ? createControl(widget.control, suffixCtrl.first.id, disabled) + : suffixIcon != null + ? Icon(parseIcon(suffixIcon)) + : null, + leadingIcon: prefixCtrl.isNotEmpty + ? createControl(widget.control, prefixCtrl.first.id, disabled) + : prefixIcon != null + ? Icon(parseIcon(prefixIcon)) + : null, + selectedTrailingIcon: selectedSuffixCtrl.isNotEmpty + ? createControl( + widget.control, selectedSuffixCtrl.first.id, disabled) + : selectedSuffixIcon != null + ? Icon(parseIcon(selectedSuffixIcon)) + : null, + onSelected: disabled + ? null + : (String? value) { + debugPrint("DropdownMenu selected value: $value"); + _value = value!; + widget.backend + .updateControlState(widget.control.id, {"value": value}); + widget.backend + .triggerControlEvent(widget.control.id, "change", value); + }, + dropdownMenuEntries: items, + ); + + return constrainedControl( + context, dropDown, widget.parent, widget.control); + }); + } +} diff --git a/sdk/python/packages/flet-core/src/flet_core/__init__.py b/sdk/python/packages/flet-core/src/flet_core/__init__.py index c3c35845b..4bda62fd0 100644 --- a/sdk/python/packages/flet-core/src/flet_core/__init__.py +++ b/sdk/python/packages/flet-core/src/flet_core/__init__.py @@ -128,6 +128,8 @@ from flet_core.drag_target import DragTarget, DragTargetAcceptEvent from flet_core.draggable import Draggable from flet_core.dropdown import Dropdown +from flet_core.dropdown_menu import DropdownMenu, DropdownMenuOption + from flet_core.elevated_button import ElevatedButton from flet_core.expansion_panel import ExpansionPanel, ExpansionPanelList from flet_core.expansion_tile import ExpansionTile, TileAffinity @@ -338,6 +340,7 @@ BoxShape, Brightness, ClipBehavior, + Duration, OptionalEventCallable, CrossAxisAlignment, FloatingActionButtonLocation, diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py new file mode 100644 index 000000000..3e556f342 --- /dev/null +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py @@ -0,0 +1,475 @@ +import time +from typing import Any, List, Optional, Union + +from flet_core.border import BorderSide +from flet_core.menu_bar import MenuStyle +from flet_core.textfield import InputFilter, TextCapitalization +from flet_core.dropdown import Dropdown, Option +from flet_core.alignment import Alignment +from flet_core.buttons import ButtonStyle +from flet_core.control import Control, OptionalNumber +from flet_core.form_field_control import FormFieldControl, InputBorder +from flet_core.ref import Ref +from flet_core.text_style import TextStyle +from flet_core.types import ( + AnimationValue, + BorderRadiusValue, + OffsetValue, + PaddingValue, + ResponsiveNumber, + RotateValue, + ScaleValue, + OptionalEventCallable, + Duration, +) +from flet_core.utils import deprecated + + +class DropdownMenuOption(Option): + def __init__( + self, + key: Optional[str] = None, + text: Optional[str] = None, + content: Optional[Control] = None, + prefix: Optional[Control] = None, + prefix_icon: Optional[str] = None, + suffix: Optional[Control] = None, + suffix_icon: Optional[str] = None, + style: Optional[ButtonStyle] = None, + # + # Control + # + ref=None, + disabled: Optional[bool] = None, + visible: Optional[bool] = None, + data: Any = None, + ): + Option.__init__( + self, + ref=ref, + disabled=disabled, + visible=visible, + data=data, + key=key, + text=text, + content=content, + ) + self.prefix = prefix + self.suffix = suffix + self.prefix_icon = prefix_icon + self.suffix_icon = suffix_icon + self.style = style + + def _get_control_name(self): + return "dropdownmenuoption" + + def _get_children(self): + children = super()._get_children() + if self.__suffix is not None: + self.__suffix._set_attr_internal("n", "suffix") + children.append(self.__suffix) + if self.__prefix is not None: + self.__prefix._set_attr_internal("n", "prefix") + children.append(self.__prefix) + return children + + def before_update(self): + super().before_update() + assert ( + self.key is not None or self.text is not None + ), "key or text must be specified" + self._set_attr_json("style", self.__style) + + # prefix + @property + def prefix(self) -> Optional[Control]: + return self.prefix + + @prefix.setter + def prefix(self, value: Optional[Control]): + self.__prefix = value + + # suffix + @property + def suffix(self) -> Optional[Control]: + return self.__suffix + + @suffix.setter + def suffix(self, value: Optional[Control]): + self.__suffix = value + + # style + @property + def style(self) -> Optional[ButtonStyle]: + return self.__style + + @style.setter + def style(self, value: Optional[ButtonStyle]): + self.__style = value + + # prefix_icon + @property + def prefix_icon(self) -> Optional[str]: + return self.__prefix_icon + + @prefix_icon.setter + def prefix_icon(self, value: Optional[str]): + self.__prefix_icon = value + + # suffix_icon + @property + def suffix_icon(self) -> Optional[str]: + return self.__suffix_icon + + @suffix_icon.setter + def suffix_icon(self, value: Optional[str]): + self.__suffix_icon = value + + +class DropdownMenu(FormFieldControl): + """ + + + ----- + + Online docs: https://flet.dev/docs/controls/dropdownmenu + """ + + def __init__( + self, + value: Optional[str] = None, + options: Optional[List[DropdownMenuOption]] = None, + label_content: Optional[str] = None, + enable_filter: Optional[bool] = None, + enable_search: Optional[bool] = None, + request_focus_on_tap: Optional[bool] = None, + menu_height: OptionalNumber = None, + expanded_insets: PaddingValue = None, + menu_style: Optional[MenuStyle] = None, + selected_suffix: Optional[Control] = None, + input_filter: Optional[InputFilter] = None, + capitalization: Optional[TextCapitalization] = None, + selected_suffix_icon: Optional[str] = None, + on_change: OptionalEventCallable = None, + on_focus: OptionalEventCallable = None, + on_blur: OptionalEventCallable = None, + # + # FormField specific + # + text_size: OptionalNumber = None, + text_style: Optional[TextStyle] = None, + label: Optional[str] = None, + label_style: Optional[TextStyle] = None, + border: Optional[InputBorder] = None, + color: Optional[str] = None, + focused_color: Optional[str] = None, + focused_bgcolor: Optional[str] = None, + border_width: OptionalNumber = None, + border_color: Optional[str] = None, + focused_border_width: OptionalNumber = None, + focused_border_color: Optional[str] = None, + content_padding: PaddingValue = None, + dense: Optional[bool] = None, + filled: Optional[bool] = None, + fill_color: Optional[str] = None, + hover_color: Optional[str] = None, + hint_text: Optional[str] = None, + hint_style: Optional[TextStyle] = None, + helper_text: Optional[str] = None, + helper_style: Optional[TextStyle] = None, + counter_style: Optional[TextStyle] = None, + error_text: Optional[str] = None, + prefix: Optional[Control] = None, + prefix_icon: Optional[str] = None, + suffix: Optional[Control] = None, + suffix_icon: Optional[str] = None, + # + # InputDecorationTheme + # + icon_color: Optional[str] = None, + prefix_icon_color: Optional[str] = None, + suffix_icon_color: Optional[str] = None, + focus_color: Optional[str] = None, + align_label_with_hint: Optional[bool] = None, + floating_label_text_style: Optional[TextStyle] = None, + active_indicator_border_side: Optional[BorderSide] = None, + hint_fade_duration: Optional[Duration] = None, + error_max_lines: OptionalNumber = None, + helper_max_lines: OptionalNumber = None, + # + # ConstrainedControl + # + ref: Optional[Ref] = None, + key: Optional[str] = None, + width: OptionalNumber = None, + expand: Union[None, bool, int] = None, + expand_loose: Optional[bool] = None, + col: Optional[ResponsiveNumber] = None, + opacity: OptionalNumber = None, + rotate: RotateValue = None, + scale: ScaleValue = None, + offset: OffsetValue = None, + aspect_ratio: OptionalNumber = None, + animate_opacity: AnimationValue = None, + animate_size: AnimationValue = None, + animate_position: AnimationValue = None, + animate_rotation: AnimationValue = None, + animate_scale: AnimationValue = None, + animate_offset: AnimationValue = None, + on_animation_end: OptionalEventCallable = None, + tooltip: Optional[str] = None, + visible: Optional[bool] = None, + disabled: Optional[bool] = None, + data: Any = None, + ): + FormFieldControl.__init__( + self, + text_size=text_size, + text_style=text_style, + label=label, + border=border, + label_style=label_style, + color=color, + focused_color=focused_color, + focused_bgcolor=focused_bgcolor, + border_width=border_width, + border_color=border_color, + focused_border_width=focused_border_width, + focused_border_color=focused_border_color, + content_padding=content_padding, + dense=dense, + filled=filled, + fill_color=fill_color, + hover_color=hover_color, + hint_text=hint_text, + hint_style=hint_style, + helper_text=helper_text, + helper_style=helper_style, + counter_style=counter_style, + error_text=error_text, + prefix=prefix, + prefix_icon=prefix_icon, + suffix=suffix, + suffix_icon=suffix_icon, + # + # InputDecorationTheme + # + icon_color=icon_color, + prefix_icon_color=prefix_icon_color, + suffix_icon_color=suffix_icon_color, + focus_color=focus_color, + align_label_with_hint=align_label_with_hint, + floating_label_text_style=floating_label_text_style, + active_indicator_border_side=active_indicator_border_side, + hint_fade_duration=hint_fade_duration, + error_max_lines=error_max_lines, + helper_max_lines=helper_max_lines, + # + # ConstrainedControl + # + ref=ref, + key=key, + width=width, + expand=expand, + expand_loose=expand_loose, + col=col, + opacity=opacity, + rotate=rotate, + scale=scale, + offset=offset, + aspect_ratio=aspect_ratio, + animate_opacity=animate_opacity, + animate_size=animate_size, + animate_position=animate_position, + animate_rotation=animate_rotation, + animate_scale=animate_scale, + animate_offset=animate_offset, + on_animation_end=on_animation_end, + tooltip=tooltip, + visible=visible, + disabled=disabled, + data=data, + ) + + self.options = options + self.selected_suffix = selected_suffix + self.input_filter = input_filter + self.enable_filter = enable_filter + self.enable_search = enable_search + self.request_focus_on_tap = request_focus_on_tap + self.menu_height = menu_height + self.expanded_insets = expanded_insets + self.menu_style = menu_style + self.capitalization = capitalization + self.label_content = label_content + self.selected_suffix_icon = selected_suffix_icon + self.on_change = on_change + self.on_focus = on_focus + self.on_blur = on_blur + self.value = value + + def _get_control_name(self): + return "dropdownmenu" + + def before_update(self): + super().before_update() + self._set_attr_json("inputFilter", self.__input_filter) + self._set_attr_json("expandInsets", self.__expanded_insets) + self._set_attr_json("menuStyle", self.__menu_style) + self.expand_loose = self.expand # to fix a display issue + + def _get_children(self): + children = FormFieldControl._get_children(self) + self.__options + if isinstance(self.__selected_suffix, Control): + self.__selected_suffix._set_attr_internal("n", "selectedSuffix") + children.append(self.__selected_suffix) + + if isinstance(self.__label_content, Control): + self.__label_content._set_attr_internal("n", "label") + children.append(self.__label_content) + return children + + # value + @property + def value(self) -> Optional[str]: + return self._get_attr("value") + + @value.setter + def value(self, value: Optional[str]): + self._set_attr("value", value) + + # options + @property + def options(self) -> Optional[List[DropdownMenuOption]]: + return self.__options + + @options.setter + def options(self, value: Optional[List[DropdownMenuOption]]): + self.__options = value if value is not None else [] + + # selected_suffix + @property + def selected_suffix(self) -> Optional[Control]: + return self.__selected_suffix + + @selected_suffix.setter + def selected_suffix(self, value: Optional[Control]): + self.__selected_suffix = value + + # label_content + @property + def label_content(self) -> Optional[Control]: + return self.__label_content + + @label_content.setter + def label_content(self, value: Optional[Control]): + self.__label_content = value + + # input_filter + @property + def input_filter(self) -> Optional[InputFilter]: + return self.__input_filter + + @input_filter.setter + def input_filter(self, value: Optional[InputFilter]): + self.__input_filter = value + + # capitalization + @property + def capitalization(self) -> Optional[TextCapitalization]: + return self.__capitalization + + @capitalization.setter + def capitalization(self, value: Optional[TextCapitalization]): + self.__capitalization = value + self._set_enum_attr("capitalization", value, TextCapitalization) + + # enable_filter + @property + def enable_filter(self) -> Optional[bool]: + return self._get_attr("enableFilter", data_type="bool", def_value=False) + + @enable_filter.setter + def enable_filter(self, value: Optional[bool]): + self._set_attr("enableFilter", value) + + # enable_search + @property + def enable_search(self) -> Optional[bool]: + return self._get_attr("enableSearch", data_type="bool", def_value=True) + + @enable_search.setter + def enable_search(self, value: Optional[bool]): + self._set_attr("enableSearch", value) + + # request_focus_on_tap + @property + def request_focus_on_tap(self) -> Optional[bool]: + return self._get_attr("requestFocusOnTap", data_type="bool", def_value=True) + + @request_focus_on_tap.setter + def request_focus_on_tap(self, value: Optional[bool]): + self._set_attr("requestFocusOnTap", value) + + # selected_suffix_icon + @property + def selected_suffix_icon(self) -> Optional[str]: + return self._get_attr("selectedSuffixIcon") + + @selected_suffix_icon.setter + def selected_suffix_icon(self, value: Optional[str]): + self._set_attr("selectedSuffixIcon", value) + + # menu_height + @property + def menu_height(self) -> OptionalNumber: + return self._get_attr("menuHeight", data_type="float") + + @menu_height.setter + def menu_height(self, value: OptionalNumber): + self._set_attr("menuHeight", value) + + # expanded_insets + @property + def expanded_insets(self) -> PaddingValue: + return self.__expanded_insets + + @expanded_insets.setter + def expanded_insets(self, value: PaddingValue): + self.__expanded_insets = value + + # menu_style + @property + def menu_style(self) -> Optional[MenuStyle]: + return self.__menu_style + + @menu_style.setter + def menu_style(self, value: Optional[MenuStyle]): + self.__menu_style = value + + # on_change + @property + def on_change(self) -> OptionalEventCallable: + return self._get_event_handler("change") + + @on_change.setter + def on_change(self, handler: OptionalEventCallable): + self._add_event_handler("change", handler) + + # on_focus + @property + def on_focus(self) -> OptionalEventCallable: + return self._get_event_handler("focus") + + @on_focus.setter + def on_focus(self, handler: OptionalEventCallable): + self._add_event_handler("focus", handler) + + # on_blur + @property + def on_blur(self) -> OptionalEventCallable: + return self._get_event_handler("blur") + + @on_blur.setter + def on_blur(self, handler: OptionalEventCallable): + self._add_event_handler("blur", handler) 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..53967c9f8 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 @@ -1,6 +1,7 @@ from enum import Enum from typing import Any, Optional, Union +from flet_core.border import BorderSide from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref @@ -15,6 +16,7 @@ ScaleValue, VerticalAlignment, OptionalEventCallable, + Duration, ) try: @@ -69,7 +71,19 @@ def __init__( suffix_icon: Optional[str] = None, suffix_text: Optional[str] = None, suffix_style: Optional[TextStyle] = None, - rtl: Optional[bool] = None, + # + # InputDecorationTheme + # + icon_color: Optional[str] = None, + prefix_icon_color: Optional[str] = None, + suffix_icon_color: Optional[str] = None, + focus_color: Optional[str] = None, + align_label_with_hint: Optional[bool] = None, + floating_label_text_style: Optional[TextStyle] = None, + active_indicator_border_side: Optional[BorderSide] = None, + hint_fade_duration: Optional[Duration] = None, + error_max_lines: OptionalNumber = None, + helper_max_lines: OptionalNumber = None, # # ConstrainedControl # @@ -100,6 +114,7 @@ def __init__( visible: Optional[bool] = None, disabled: Optional[bool] = None, data: Any = None, + rtl: Optional[bool] = None, ): ConstrainedControl.__init__( self, @@ -170,6 +185,16 @@ def __init__( self.suffix_style = suffix_style self.hover_color = hover_color self.fill_color = fill_color + self.icon_color = icon_color + self.prefix_icon_color = prefix_icon_color + self.suffix_icon_color = suffix_icon_color + self.focus_color = focus_color + self.align_label_with_hint = align_label_with_hint + self.floating_label_text_style = floating_label_text_style + self.active_indicator_border_side = active_indicator_border_side + self.hint_fade_duration = hint_fade_duration + self.error_max_lines = error_max_lines + self.helper_max_lines = helper_max_lines def before_update(self): super().before_update() @@ -183,6 +208,11 @@ def before_update(self): self._set_attr_json("errorStyle", self.__error_style) self._set_attr_json("prefixStyle", self.__prefix_style) self._set_attr_json("suffixStyle", self.__suffix_style) + self._set_attr_json("floatingLabelTextStyle", self.__floating_label_text_style) + self._set_attr_json( + "activeIndicatorBorderSide", self.__active_indicator_border_side + ) + self._set_attr_json("hintFadeDuration", self.__hint_fade_duration) def _get_children(self): children = [] @@ -530,3 +560,93 @@ def hover_color(self) -> Optional[str]: @hover_color.setter def hover_color(self, value: Optional[str]): self._set_attr("hoverColor", value) + + # icon_color + @property + def icon_color(self) -> Optional[str]: + return self._get_attr("iconColor") + + @icon_color.setter + def icon_color(self, value: Optional[str]): + self._set_attr("iconColor", value) + + # prefix_icon_color + @property + def prefix_icon_color(self) -> Optional[str]: + return self._get_attr("prefixIconColor") + + @prefix_icon_color.setter + def prefix_icon_color(self, value: Optional[str]): + self._set_attr("prefixIconColor", value) + + # suffix_icon_color + @property + def suffix_icon_color(self) -> Optional[str]: + return self._get_attr("suffixIconColor") + + @suffix_icon_color.setter + def suffix_icon_color(self, value: Optional[str]): + self._set_attr("suffixIconColor", value) + + # focus_color + @property + def focus_color(self) -> Optional[str]: + return self._get_attr("focusColor") + + @focus_color.setter + def focus_color(self, value: Optional[str]): + self._set_attr("focusColor", value) + + # align_label_with_hint + @property + def align_label_with_hint(self) -> Optional[bool]: + return self._get_attr("alignLabelWithHint", data_type="bool", def_value=False) + + @align_label_with_hint.setter + def align_label_with_hint(self, value: Optional[bool]): + self._set_attr("alignLabelWithHint", value) + + # floating_label_text_style + @property + def floating_label_text_style(self) -> Optional[TextStyle]: + return self.__floating_label_text_style + + @floating_label_text_style.setter + def floating_label_text_style(self, value: Optional[TextStyle]): + self.__floating_label_text_style = value + + # active_indicator_border_side + @property + def active_indicator_border_side(self) -> Optional[BorderSide]: + return self.__active_indicator_border_side + + @active_indicator_border_side.setter + def active_indicator_border_side(self, value: Optional[BorderSide]): + self.__active_indicator_border_side = value + + # hint_fade_duration + @property + def hint_fade_duration(self) -> Optional[Duration]: + return self.__hint_fade_duration + + @hint_fade_duration.setter + def hint_fade_duration(self, value: Optional[Duration]): + self.__hint_fade_duration = value + + # error_max_lines + @property + def error_max_lines(self) -> Optional[int]: + return self._get_attr("errorMaxLines", data_type="int") + + @error_max_lines.setter + def error_max_lines(self, value: Optional[int]): + self._set_attr("errorMaxLines", value) + + # helper_max_lines + @property + def helper_max_lines(self) -> Optional[int]: + return self._get_attr("helperMaxLines", data_type="int") + + @helper_max_lines.setter + def helper_max_lines(self, value: Optional[int]): + self._set_attr("helperMaxLines", value) diff --git a/sdk/python/packages/flet-core/src/flet_core/types.py b/sdk/python/packages/flet-core/src/flet_core/types.py index a8aab744b..52fe70091 100644 --- a/sdk/python/packages/flet-core/src/flet_core/types.py +++ b/sdk/python/packages/flet-core/src/flet_core/types.py @@ -1,3 +1,4 @@ +from dataclasses import dataclass from enum import Enum, EnumMeta from typing import Any, Callable, Dict, Optional, Protocol, Tuple, Union from warnings import warn @@ -392,6 +393,16 @@ class VisualDensity(Enum): ADAPTIVE_PLATFORM_DENSITY = "adaptivePlatformDensity" +@dataclass +class Duration: + days: int = 0 + hours: int = 0 + minutes: int = 0 + seconds: int = 0 + milliseconds: int = 0 + microseconds: int = 0 + + # Events OptionalEventCallable = Optional[Callable[[ControlEvent], None]] From a134119ffdf62681a54e3f3f3aaa96263b26b424 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Mon, 15 Jul 2024 21:47:53 +0200 Subject: [PATCH 05/10] fix Duration parsing --- packages/flet/lib/src/controls/dropdown_menu.dart | 3 +++ packages/flet/lib/src/utils/form_field.dart | 11 ++--------- packages/flet/lib/src/utils/time.dart | 5 ++++- .../packages/flet-core/src/flet_core/animation.py | 2 +- .../flet-core/src/flet_core/dropdown_menu.py | 14 +++++--------- .../flet-core/src/flet_core/form_field_control.py | 8 ++++---- .../packages/flet-core/src/flet_core/types.py | 2 ++ 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/flet/lib/src/controls/dropdown_menu.dart b/packages/flet/lib/src/controls/dropdown_menu.dart index 2043475fa..778dcd4e9 100644 --- a/packages/flet/lib/src/controls/dropdown_menu.dart +++ b/packages/flet/lib/src/controls/dropdown_menu.dart @@ -6,6 +6,7 @@ import '../models/control.dart'; import '../models/control_view_model.dart'; import '../utils/buttons.dart'; import '../utils/edge_insets.dart'; +import '../utils/form_field.dart'; import '../utils/icons.dart'; import '../utils/menu.dart'; import '../utils/text.dart'; @@ -212,6 +213,8 @@ class _DropdownMenuControlState extends State : selectedSuffixIcon != null ? Icon(parseIcon(selectedSuffixIcon)) : null, + inputDecorationTheme: + buildInputDecorationTheme(context, widget.control, _focused), onSelected: disabled ? null : (String? value) { diff --git a/packages/flet/lib/src/utils/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 7b0f42a48..32e5f22c9 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -161,15 +161,8 @@ InputDecoration buildInputDecoration( suffixStyle: parseTextStyle(theme, control, "suffixStyle")); } -InputDecorationTheme buildInputDecorationTheme( - BuildContext context, - Control control, - Control? prefix, - Control? suffix, - Widget? customSuffix, - bool focused, - bool disabled, - bool? adaptive) { +InputDecorationTheme buildInputDecorationTheme(BuildContext context, + Control control, bool focused) { FormFieldInputBorder inputBorder = parseFormFieldInputBorder( control.attrString("border"), FormFieldInputBorder.outline, diff --git a/packages/flet/lib/src/utils/time.dart b/packages/flet/lib/src/utils/time.dart index 844ef1b72..0c64d8751 100644 --- a/packages/flet/lib/src/utils/time.dart +++ b/packages/flet/lib/src/utils/time.dart @@ -14,7 +14,10 @@ Duration? parseDuration(Control control, String propName, return durationFromJSON(j1); } -Duration? durationFromJSON(Map json) { +Duration durationFromJSON(dynamic json) { + if (json is int || json is double) { + return Duration(seconds: parseInt(json, 0)!); + } return Duration( days: parseInt(json["days"], 0)!, hours: parseInt(json["hours"], 0)!, diff --git a/sdk/python/packages/flet-core/src/flet_core/animation.py b/sdk/python/packages/flet-core/src/flet_core/animation.py index d11bdb2f4..d943abc8b 100644 --- a/sdk/python/packages/flet-core/src/flet_core/animation.py +++ b/sdk/python/packages/flet-core/src/flet_core/animation.py @@ -47,7 +47,7 @@ class AnimationCurve(Enum): ELASTIC_IN_OUT = "elasticInOut" ELASTIC_OUT = "elasticOut" FAST_LINEAR_TO_SLOW_EASE_IN = "fastLinearToSlowEaseIn" - FAST_OUT_SLOWIN = "fastOutSlowIn" + FAST_OUT_SLOW_IN = "fastOutSlowIn" LINEAR = "linear" LINEAR_TO_EASE_OUT = "linearToEaseOut" SLOW_MIDDLE = "slowMiddle" diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py index 3e556f342..40e5025d2 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py @@ -1,28 +1,24 @@ -import time from typing import Any, List, Optional, Union from flet_core.border import BorderSide -from flet_core.menu_bar import MenuStyle -from flet_core.textfield import InputFilter, TextCapitalization -from flet_core.dropdown import Dropdown, Option -from flet_core.alignment import Alignment from flet_core.buttons import ButtonStyle from flet_core.control import Control, OptionalNumber +from flet_core.dropdown import Option from flet_core.form_field_control import FormFieldControl, InputBorder +from flet_core.menu_bar import MenuStyle from flet_core.ref import Ref from flet_core.text_style import TextStyle +from flet_core.textfield import InputFilter, TextCapitalization from flet_core.types import ( AnimationValue, - BorderRadiusValue, OffsetValue, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, OptionalEventCallable, - Duration, + DurationValue, ) -from flet_core.utils import deprecated class DropdownMenuOption(Option): @@ -193,7 +189,7 @@ def __init__( align_label_with_hint: Optional[bool] = None, floating_label_text_style: Optional[TextStyle] = None, active_indicator_border_side: Optional[BorderSide] = None, - hint_fade_duration: Optional[Duration] = None, + hint_fade_duration: DurationValue = None, error_max_lines: OptionalNumber = None, helper_max_lines: OptionalNumber = None, # 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 53967c9f8..015adfcb9 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 @@ -16,7 +16,7 @@ ScaleValue, VerticalAlignment, OptionalEventCallable, - Duration, + DurationValue, ) try: @@ -81,7 +81,7 @@ def __init__( align_label_with_hint: Optional[bool] = None, floating_label_text_style: Optional[TextStyle] = None, active_indicator_border_side: Optional[BorderSide] = None, - hint_fade_duration: Optional[Duration] = None, + hint_fade_duration: DurationValue = None, error_max_lines: OptionalNumber = None, helper_max_lines: OptionalNumber = None, # @@ -626,11 +626,11 @@ def active_indicator_border_side(self, value: Optional[BorderSide]): # hint_fade_duration @property - def hint_fade_duration(self) -> Optional[Duration]: + def hint_fade_duration(self) -> DurationValue: return self.__hint_fade_duration @hint_fade_duration.setter - def hint_fade_duration(self, value: Optional[Duration]): + def hint_fade_duration(self, value: DurationValue): self.__hint_fade_duration = value # error_max_lines diff --git a/sdk/python/packages/flet-core/src/flet_core/types.py b/sdk/python/packages/flet-core/src/flet_core/types.py index 52fe70091..cb4615e88 100644 --- a/sdk/python/packages/flet-core/src/flet_core/types.py +++ b/sdk/python/packages/flet-core/src/flet_core/types.py @@ -403,6 +403,8 @@ class Duration: microseconds: int = 0 +DurationValue = Union[int, Duration, None] + # Events OptionalEventCallable = Optional[Callable[[ControlEvent], None]] From c323661c8c224f0816943075cc3813ba7cd7fd7a Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sat, 20 Jul 2024 11:55:56 +0200 Subject: [PATCH 06/10] cherry pick from textfield-counter-control branch --- 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 ++ .../packages/flet-core/src/flet_core/types.py | 10 ++++---- 7 files changed, 57 insertions(+), 27 deletions(-) diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index 7b890ee9d..de6126d41 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: hintCtrl.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 32e5f22c9..7d944c099 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -54,12 +54,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"), @@ -143,6 +144,10 @@ InputDecoration buildInputDecoration( helperStyle: parseTextStyle(theme, control, "helperStyle"), counterText: control.attrString("counterText"), counterStyle: parseTextStyle(theme, control, "counterStyle"), + counter: counter != null + ? createControl(control, counter.id, control.isDisabled, + parentAdaptive: adaptive) + : null, errorText: control.attrString("errorText"), errorStyle: parseTextStyle(theme, 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..d915e56ab 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 015adfcb9..5178368b7 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 @@ -59,6 +59,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, @@ -171,6 +172,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 @@ -222,6 +224,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 @@ -480,6 +485,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..a6bd31563 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, diff --git a/sdk/python/packages/flet-core/src/flet_core/types.py b/sdk/python/packages/flet-core/src/flet_core/types.py index cb4615e88..cbdeb7360 100644 --- a/sdk/python/packages/flet-core/src/flet_core/types.py +++ b/sdk/python/packages/flet-core/src/flet_core/types.py @@ -395,12 +395,12 @@ class VisualDensity(Enum): @dataclass class Duration: - days: int = 0 - hours: int = 0 - minutes: int = 0 - seconds: int = 0 - milliseconds: int = 0 microseconds: int = 0 + milliseconds: int = 0 + seconds: int = 0 + minutes: int = 0 + hours: int = 0 + days: int = 0 DurationValue = Union[int, Duration, None] From 299887889b41b7c85b363c5f0eabfb7890619606 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Wed, 24 Jul 2024 18:03:35 +0200 Subject: [PATCH 07/10] additional form field props --- packages/flet/lib/src/controls/dropdown.dart | 8 ++ packages/flet/lib/src/controls/textfield.dart | 6 + packages/flet/lib/src/utils/form_field.dart | 114 ++++++++++------- .../flet-core/src/flet_core/dropdown.py | 87 ++++++++----- .../flet-core/src/flet_core/dropdown_menu.py | 25 ++-- .../src/flet_core/form_field_control.py | 116 ++++++++++++------ .../flet-core/src/flet_core/textfield.py | 89 +++++++++----- 7 files changed, 281 insertions(+), 164 deletions(-) diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index de6126d41..d54f9123b 100644 --- a/packages/flet/lib/src/controls/dropdown.dart +++ b/packages/flet/lib/src/controls/dropdown.dart @@ -149,6 +149,10 @@ class _DropdownControlState extends State with FletStoreMixin { .where((c) => c.control.name == "suffix" && c.control.isVisible); var counterControls = itemsView.controlViews .where((c) => c.control.name == "counter" && c.control.isVisible); + var helperControls = itemsView.controlViews + .where((c) => c.control.name == "helper" && c.control.isVisible); + var errorControls = itemsView.controlViews + .where((c) => c.control.name == "error" && c.control.isVisible); var focusValue = widget.control.attrString("focus"); if (focusValue != null && focusValue != _lastFocusValue) { @@ -189,6 +193,10 @@ class _DropdownControlState extends State with FletStoreMixin { counter: counterControls.isNotEmpty ? counterControls.first.control : null, + helper: + helperControls.isNotEmpty ? helperControls.first.control : null, + error: + errorControls.isNotEmpty ? errorControls.first.control : null, customSuffix: null, focused: _focused, disabled: disabled, diff --git a/packages/flet/lib/src/controls/textfield.dart b/packages/flet/lib/src/controls/textfield.dart index 5bd781e26..630968f4f 100644 --- a/packages/flet/lib/src/controls/textfield.dart +++ b/packages/flet/lib/src/controls/textfield.dart @@ -127,6 +127,10 @@ class _TextFieldControlState extends State widget.children.where((c) => c.name == "suffix" && c.isVisible); var counterControls = widget.children.where((c) => c.name == "counter" && c.isVisible); + var helperControls = + widget.children.where((c) => c.name == "helper" && c.isVisible); + var errorControls = + widget.children.where((c) => c.name == "error" && c.isVisible); bool shiftEnter = widget.control.attrBool("shiftEnter", false)!; bool multiline = @@ -227,6 +231,8 @@ class _TextFieldControlState extends State suffix: suffixControls.isNotEmpty ? suffixControls.first : null, counter: counterControls.isNotEmpty ? counterControls.first : null, + helper: helperControls.isNotEmpty ? helperControls.first : null, + error: errorControls.isNotEmpty ? errorControls.first : null, customSuffix: revealPasswordIcon, focused: _focused, disabled: disabled, diff --git a/packages/flet/lib/src/utils/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 7d944c099..757612983 100644 --- a/packages/flet/lib/src/utils/form_field.dart +++ b/packages/flet/lib/src/utils/form_field.dart @@ -51,12 +51,12 @@ TextInputType? parseTextInputType(String? value, [TextInputType? defValue]) { } } -InputDecoration buildInputDecoration( - BuildContext context, - Control control, +InputDecoration buildInputDecoration(BuildContext context, Control control, {Control? prefix, Control? suffix, Control? counter, + Control? helper, + Control? error, Widget? customSuffix, bool focused = false, bool disabled = false, @@ -126,48 +126,68 @@ InputDecoration buildInputDecoration( } return InputDecoration( - enabled: !disabled, - contentPadding: parseEdgeInsets(control, "contentPadding"), - isDense: control.attrBool("dense"), - label: label != "" ? Text(label) : null, - labelStyle: parseTextStyle(theme, control, "labelStyle"), - border: border, - enabledBorder: border, - focusedBorder: focusedBorder, - hoverColor: hoverColor, - icon: icon != null ? Icon(icon) : null, - filled: control.attrBool("filled", false)!, - fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), - hintText: control.attrString("hintText"), - hintStyle: parseTextStyle(theme, control, "hintStyle"), - helperText: control.attrString("helperText"), - helperStyle: parseTextStyle(theme, control, "helperStyle"), - counterText: control.attrString("counterText"), - counterStyle: parseTextStyle(theme, control, "counterStyle"), - counter: counter != null - ? createControl(control, counter.id, control.isDisabled, - parentAdaptive: adaptive) - : null, - errorText: control.attrString("errorText"), - errorStyle: parseTextStyle(theme, control, "errorStyle"), - prefixIcon: prefixIcon != null ? Icon(prefixIcon) : null, - prefixText: prefixText, - prefixStyle: parseTextStyle(theme, control, "prefixStyle"), - prefix: prefix != null - ? createControl(control, prefix.id, control.isDisabled, - parentAdaptive: adaptive) - : null, - suffix: suffix != null - ? createControl(control, suffix.id, control.isDisabled, - parentAdaptive: adaptive) - : null, - suffixIcon: suffixIcon != null ? Icon(suffixIcon) : customSuffix, - suffixText: suffixText, - suffixStyle: parseTextStyle(theme, control, "suffixStyle")); + enabled: !disabled, + contentPadding: parseEdgeInsets(control, "contentPadding"), + isDense: control.attrBool("dense"), + label: label != "" ? Text(label) : null, + labelStyle: parseTextStyle(theme, control, "labelStyle"), + border: border, + enabledBorder: border, + focusedBorder: focusedBorder, + hoverColor: hoverColor, + icon: icon != null ? Icon(icon) : null, + filled: control.attrBool("filled", false)!, + fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), + hintText: control.attrString("hintText"), + hintStyle: parseTextStyle(theme, control, "hintStyle"), + helperText: control.attrString("helperText"), + helperStyle: parseTextStyle(theme, control, "helperStyle"), + counterText: control.attrString("counterText"), + counterStyle: parseTextStyle(theme, control, "counterTextStyle"), + counter: counter != null + ? createControl(control, counter.id, control.isDisabled, + parentAdaptive: adaptive) + : null, + helper: helper != null + ? createControl(control, helper.id, control.isDisabled, + parentAdaptive: adaptive) + : null, + error: error != null + ? createControl(control, error.id, control.isDisabled, + parentAdaptive: adaptive) + : null, + errorMaxLines: control.attrInt("errorMaxLines"), + helperMaxLines: control.attrInt("helperMaxLines"), + hintFadeDuration: parseDuration(control, "hintFadeDuration"), + hintMaxLines: control.attrInt("hintMaxLines"), + iconColor: control.attrColor("iconColor", context), + alignLabelWithHint: control.attrBool("alignLabelWithHint", false)!, + prefixIconColor: control.attrColor("prefixIconColor", context), + suffixIconColor: control.attrColor("suffixIconColor", context), + errorText: control.attrString("errorText"), + errorStyle: parseTextStyle(theme, control, "errorTextStyle"), + prefixIcon: prefixIcon != null ? Icon(prefixIcon) : null, + prefixText: prefixText, + prefixStyle: parseTextStyle(theme, control, "prefixTextStyle"), + prefix: prefix != null + ? createControl(control, prefix.id, control.isDisabled, + parentAdaptive: adaptive) + : null, + suffix: suffix != null + ? createControl(control, suffix.id, control.isDisabled, + parentAdaptive: adaptive) + : null, + suffixIcon: suffixIcon != null ? Icon(suffixIcon) : customSuffix, + suffixText: suffixText, + suffixStyle: parseTextStyle(theme, control, "suffixTextStyle"), + focusColor: control.attrColor("focusColor", context), + floatingLabelStyle: + parseTextStyle(theme, control, "floatingLabelTextStyle"), + ); } -InputDecorationTheme buildInputDecorationTheme(BuildContext context, - Control control, bool focused) { +InputDecorationTheme buildInputDecorationTheme( + BuildContext context, Control control, bool focused) { FormFieldInputBorder inputBorder = parseFormFieldInputBorder( control.attrString("border"), FormFieldInputBorder.outline, @@ -237,10 +257,10 @@ InputDecorationTheme buildInputDecorationTheme(BuildContext context, fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), hintStyle: parseTextStyle(theme, control, "hintStyle"), helperStyle: parseTextStyle(theme, control, "helperStyle"), - counterStyle: parseTextStyle(theme, control, "counterStyle"), - errorStyle: parseTextStyle(theme, control, "errorStyle"), - prefixStyle: parseTextStyle(theme, control, "prefixStyle"), - suffixStyle: parseTextStyle(theme, control, "suffixStyle"), + counterStyle: parseTextStyle(theme, control, "counterTextStyle"), + errorStyle: parseTextStyle(theme, control, "errorTextStyle"), + prefixStyle: parseTextStyle(theme, control, "prefixTextStyle"), + suffixStyle: parseTextStyle(theme, control, "suffixTextStyle"), iconColor: control.attrColor("iconColor", context), alignLabelWithHint: control.attrBool("alignLabelWithHint", false)!, prefixIconColor: control.attrColor("prefixIconColor", context), 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 d915e56ab..b1c057769 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown.py @@ -2,6 +2,7 @@ from typing import Any, List, Optional, Union from flet_core.alignment import Alignment +from flet_core.border import BorderSide from flet_core.control import Control, OptionalNumber from flet_core.form_field_control import FormFieldControl, InputBorder from flet_core.ref import Ref @@ -15,6 +16,7 @@ RotateValue, ScaleValue, OptionalEventCallable, + DurationValue, ) from flet_core.utils import deprecated @@ -195,11 +197,13 @@ def __init__( fill_color: Optional[str] = None, hint_text: Optional[str] = None, hint_style: Optional[TextStyle] = None, + helper: Optional[Control] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, - counter: Optional[Control] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, counter_style: Optional[TextStyle] = None, + error: Optional[Control] = None, error_text: Optional[str] = None, error_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, @@ -210,6 +214,17 @@ def __init__( suffix_icon: Optional[str] = None, suffix_text: Optional[str] = None, suffix_style: Optional[TextStyle] = None, + icon_color: Optional[str] = None, + prefix_icon_color: Optional[str] = None, + suffix_icon_color: Optional[str] = None, + focus_color: Optional[str] = None, + align_label_with_hint: Optional[bool] = None, + floating_label_text_style: Optional[TextStyle] = None, + active_indicator_border_side: Optional[BorderSide] = None, + hint_fade_duration: DurationValue = None, + error_max_lines: OptionalNumber = None, + helper_max_lines: OptionalNumber = None, + hint_max_lines: OptionalNumber = None, # # ConstrainedControl # @@ -239,32 +254,6 @@ def __init__( ): FormFieldControl.__init__( self, - ref=ref, - key=key, - width=width, - height=height, - expand=expand, - expand_loose=expand_loose, - col=col, - opacity=opacity, - rotate=rotate, - scale=scale, - offset=offset, - aspect_ratio=aspect_ratio, - animate_opacity=animate_opacity, - animate_size=animate_size, - animate_position=animate_position, - animate_rotation=animate_rotation, - animate_scale=animate_scale, - animate_offset=animate_offset, - on_animation_end=on_animation_end, - tooltip=tooltip, - visible=visible, - disabled=disabled, - data=data, - # - # FormField specific - # text_size=text_size, text_style=text_style, label=label, @@ -286,21 +275,57 @@ def __init__( fill_color=fill_color, hint_text=hint_text, hint_style=hint_style, + helper=helper, helper_text=helper_text, helper_style=helper_style, counter=counter, counter_text=counter_text, - counter_style=counter_style, + counter_text_style=counter_style, + error=error, error_text=error_text, - error_style=error_style, + error_text_style=error_style, prefix=prefix, prefix_icon=prefix_icon, prefix_text=prefix_text, - prefix_style=prefix_style, + prefix_text_style=prefix_style, suffix=suffix, suffix_icon=suffix_icon, suffix_text=suffix_text, - suffix_style=suffix_style, + suffix_text_style=suffix_style, + icon_color=icon_color, + prefix_icon_color=prefix_icon_color, + suffix_icon_color=suffix_icon_color, + focus_color=focus_color, + align_label_with_hint=align_label_with_hint, + floating_label_text_style=floating_label_text_style, + active_indicator_border_side=active_indicator_border_side, + hint_fade_duration=hint_fade_duration, + error_max_lines=error_max_lines, + helper_max_lines=helper_max_lines, + hint_max_lines=hint_max_lines, + ref=ref, + key=key, + width=width, + height=height, + expand=expand, + expand_loose=expand_loose, + col=col, + opacity=opacity, + rotate=rotate, + scale=scale, + offset=offset, + aspect_ratio=aspect_ratio, + animate_opacity=animate_opacity, + animate_size=animate_size, + animate_position=animate_position, + animate_rotation=animate_rotation, + animate_scale=animate_scale, + animate_offset=animate_offset, + on_animation_end=on_animation_end, + tooltip=tooltip, + visible=visible, + disabled=disabled, + data=data, ) self.__options = [] diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py index 40e5025d2..51fcf36a5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py @@ -124,7 +124,7 @@ def suffix_icon(self, value: Optional[str]): class DropdownMenu(FormFieldControl): """ - + A dropdown menu control that allows users to select a single option from a list of options. ----- @@ -175,13 +175,13 @@ def __init__( helper_style: Optional[TextStyle] = None, counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, + error_text_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, prefix_icon: Optional[str] = None, + prefix_style: Optional[TextStyle] = None, suffix: Optional[Control] = None, suffix_icon: Optional[str] = None, - # - # InputDecorationTheme - # + suffix_style: Optional[TextStyle] = None, icon_color: Optional[str] = None, prefix_icon_color: Optional[str] = None, suffix_icon_color: Optional[str] = None, @@ -223,13 +223,13 @@ def __init__( text_size=text_size, text_style=text_style, label=label, - border=border, label_style=label_style, + border=border, color=color, - focused_color=focused_color, - focused_bgcolor=focused_bgcolor, border_width=border_width, border_color=border_color, + focused_color=focused_color, + focused_bgcolor=focused_bgcolor, focused_border_width=focused_border_width, focused_border_color=focused_border_color, content_padding=content_padding, @@ -241,15 +241,15 @@ def __init__( hint_style=hint_style, helper_text=helper_text, helper_style=helper_style, - counter_style=counter_style, + counter_text_style=counter_style, error_text=error_text, + error_text_style=error_text_style, prefix=prefix, prefix_icon=prefix_icon, + prefix_text_style=prefix_style, suffix=suffix, suffix_icon=suffix_icon, - # - # InputDecorationTheme - # + suffix_text_style=suffix_style, icon_color=icon_color, prefix_icon_color=prefix_icon_color, suffix_icon_color=suffix_icon_color, @@ -260,9 +260,6 @@ def __init__( hint_fade_duration=hint_fade_duration, error_max_lines=error_max_lines, helper_max_lines=helper_max_lines, - # - # ConstrainedControl - # ref=ref, key=key, width=width, 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 5178368b7..a6933718b 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,24 +57,23 @@ def __init__( hover_color: Optional[str] = None, hint_text: Optional[str] = None, hint_style: Optional[TextStyle] = None, + helper: Optional[Control] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, - counter: Optional[Control] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, - counter_style: Optional[TextStyle] = None, + counter_text_style: Optional[TextStyle] = None, + error: Optional[Control] = None, error_text: Optional[str] = None, - error_style: Optional[TextStyle] = None, + error_text_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, prefix_icon: Optional[str] = None, prefix_text: Optional[str] = None, - prefix_style: Optional[TextStyle] = None, + prefix_text_style: Optional[TextStyle] = None, suffix: Optional[Control] = None, suffix_icon: Optional[str] = None, suffix_text: Optional[str] = None, - suffix_style: Optional[TextStyle] = None, - # - # InputDecorationTheme - # + suffix_text_style: Optional[TextStyle] = None, icon_color: Optional[str] = None, prefix_icon_color: Optional[str] = None, suffix_icon_color: Optional[str] = None, @@ -85,6 +84,7 @@ def __init__( hint_fade_duration: DurationValue = None, error_max_lines: OptionalNumber = None, helper_max_lines: OptionalNumber = None, + hint_max_lines: OptionalNumber = None, # # ConstrainedControl # @@ -174,17 +174,17 @@ def __init__( self.helper_style = helper_style self.counter = counter self.counter_text = counter_text - self.counter_style = counter_style + self.counter_text_style = counter_text_style self.error_text = error_text - self.error_style = error_style + self.error_text_style = error_text_style self.prefix = prefix self.prefix_icon = prefix_icon self.prefix_text = prefix_text - self.prefix_style = prefix_style + self.prefix_text_style = prefix_text_style self.suffix = suffix self.suffix_icon = suffix_icon self.suffix_text = suffix_text - self.suffix_style = suffix_style + self.suffix_text_style = suffix_text_style self.hover_color = hover_color self.fill_color = fill_color self.icon_color = icon_color @@ -197,6 +197,9 @@ def __init__( self.hint_fade_duration = hint_fade_duration self.error_max_lines = error_max_lines self.helper_max_lines = helper_max_lines + self.hint_max_lines = hint_max_lines + self.error = error + self.helper = helper def before_update(self): super().before_update() @@ -206,10 +209,10 @@ def before_update(self): self._set_attr_json("labelStyle", self.__label_style) self._set_attr_json("hintStyle", self.__hint_style) self._set_attr_json("helperStyle", self.__helper_style) - self._set_attr_json("counterStyle", self.__counter_style) - self._set_attr_json("errorStyle", self.__error_style) - self._set_attr_json("prefixStyle", self.__prefix_style) - self._set_attr_json("suffixStyle", self.__suffix_style) + self._set_attr_json("counterTextStyle", self.__counter_text_style) + self._set_attr_json("errorTextStyle", self.__error_text_style) + self._set_attr_json("prefixTextStyle", self.__prefix_text_style) + self._set_attr_json("suffixTextStyle", self.__suffix_text_style) self._set_attr_json("floatingLabelTextStyle", self.__floating_label_text_style) self._set_attr_json( "activeIndicatorBorderSide", self.__active_indicator_border_side @@ -227,6 +230,12 @@ def _get_children(self): if isinstance(self.__counter, Control): self.__counter._set_attr_internal("n", "counter") children.append(self.__counter) + if isinstance(self.__error, Control): + self.__error._set_attr_internal("n", "error") + children.append(self.__error) + if isinstance(self.__helper, Control): + self.__helper._set_attr_internal("n", "helper") + children.append(self.__helper) return children # text_size @@ -449,14 +458,14 @@ def counter_text(self) -> Optional[str]: def counter_text(self, value: Optional[str]): self._set_attr("counterText", value) - # counter_style + # counter_text_style @property - def counter_style(self) -> Optional[TextStyle]: - return self.__counter_style + def counter_text_style(self) -> Optional[TextStyle]: + return self.__counter_text_style - @counter_style.setter - def counter_style(self, value: Optional[TextStyle]): - self.__counter_style = value + @counter_text_style.setter + def counter_text_style(self, value: Optional[TextStyle]): + self.__counter_text_style = value # error_text @property @@ -467,14 +476,14 @@ def error_text(self) -> Optional[str]: def error_text(self, value: Optional[str]): self._set_attr("errorText", value) - # error_style + # error_text_style @property - def error_style(self) -> Optional[TextStyle]: - return self.__error_style + def error_text_style(self) -> Optional[TextStyle]: + return self.__error_text_style - @error_style.setter - def error_style(self, value: Optional[TextStyle]): - self.__error_style = value + @error_text_style.setter + def error_text_style(self, value: Optional[TextStyle]): + self.__error_text_style = value # prefix @property @@ -485,6 +494,24 @@ def prefix(self) -> Optional[Control]: def prefix(self, value: Optional[Control]): self.__prefix = value + # error + @property + def error(self) -> Optional[Control]: + return self.__error + + @error.setter + def error(self, value: Optional[Control]): + self.__error = value + + # helper + @property + def helper(self) -> Optional[Control]: + return self.__helper + + @helper.setter + def helper(self, value: Optional[Control]): + self.__helper = value + # counter @property def counter(self) -> Optional[Control]: @@ -512,14 +539,14 @@ def prefix_text(self) -> Optional[str]: def prefix_text(self, value: Optional[str]): self._set_attr("prefixText", value) - # prefix_style + # prefix_text_style @property - def prefix_style(self) -> Optional[TextStyle]: - return self.__prefix_style + def prefix_text_style(self) -> Optional[TextStyle]: + return self.__prefix_text_style - @prefix_style.setter - def prefix_style(self, value: Optional[TextStyle]): - self.__prefix_style = value + @prefix_text_style.setter + def prefix_text_style(self, value: Optional[TextStyle]): + self.__prefix_text_style = value # suffix @property @@ -548,14 +575,14 @@ def suffix_text(self) -> Optional[str]: def suffix_text(self, value: Optional[str]): self._set_attr("suffixText", value) - # suffix_style + # suffix_text_style @property - def suffix_style(self) -> Optional[TextStyle]: - return self.__suffix_style + def suffix_text_style(self) -> Optional[TextStyle]: + return self.__suffix_text_style - @suffix_style.setter - def suffix_style(self, value: Optional[TextStyle]): - self.__suffix_style = value + @suffix_text_style.setter + def suffix_text_style(self, value: Optional[TextStyle]): + self.__suffix_text_style = value # fill_color @property @@ -664,3 +691,12 @@ def helper_max_lines(self) -> Optional[int]: @helper_max_lines.setter def helper_max_lines(self, value: Optional[int]): self._set_attr("helperMaxLines", value) + + # hint_max_lines + @property + def hint_max_lines(self) -> Optional[int]: + return self._get_attr("hintMaxLines", data_type="int") + + @hint_max_lines.setter + def hint_max_lines(self, value: Optional[int]): + self._set_attr("hintMaxLines", value) 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 a6bd31563..cc27aaabe 100644 --- a/sdk/python/packages/flet-core/src/flet_core/textfield.py +++ b/sdk/python/packages/flet-core/src/flet_core/textfield.py @@ -6,6 +6,7 @@ from flet_core.adaptive_control import AdaptiveControl from flet_core.autofill_group import AutofillHint +from flet_core.border import BorderSide from flet_core.control import Control, OptionalNumber from flet_core.form_field_control import FormFieldControl, InputBorder from flet_core.ref import Ref @@ -21,6 +22,7 @@ TextAlign, VerticalAlignment, OptionalEventCallable, + DurationValue, ) from flet_core.utils import deprecated @@ -154,11 +156,13 @@ def __init__( hover_color: Optional[str] = None, hint_text: Optional[str] = None, hint_style: Optional[TextStyle] = None, + helper: Optional[Control] = None, helper_text: Optional[str] = None, helper_style: Optional[TextStyle] = None, - counter: Optional[Control] = None, + counter: Optional[Control] = None, counter_text: Optional[str] = None, counter_style: Optional[TextStyle] = None, + error: Optional[Control] = None, error_text: Optional[str] = None, error_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, @@ -169,6 +173,17 @@ def __init__( suffix_icon: Optional[str] = None, suffix_text: Optional[str] = None, suffix_style: Optional[TextStyle] = None, + icon_color: Optional[str] = None, + prefix_icon_color: Optional[str] = None, + suffix_icon_color: Optional[str] = None, + focus_color: Optional[str] = None, + align_label_with_hint: Optional[bool] = None, + floating_label_text_style: Optional[TextStyle] = None, + active_indicator_border_side: Optional[BorderSide] = None, + hint_fade_duration: DurationValue = None, + error_max_lines: OptionalNumber = None, + helper_max_lines: OptionalNumber = None, + hint_max_lines: OptionalNumber = None, # # ConstrainedControl and AdaptiveControl # @@ -200,33 +215,6 @@ def __init__( ): FormFieldControl.__init__( self, - ref=ref, - key=key, - width=width, - height=height, - expand=expand, - expand_loose=expand_loose, - col=col, - opacity=opacity, - rotate=rotate, - scale=scale, - offset=offset, - aspect_ratio=aspect_ratio, - animate_opacity=animate_opacity, - animate_size=animate_size, - animate_position=animate_position, - animate_rotation=animate_rotation, - animate_scale=animate_scale, - animate_offset=animate_offset, - on_animation_end=on_animation_end, - tooltip=tooltip, - visible=visible, - disabled=disabled, - data=data, - rtl=rtl, - # - # FormField - # text_size=text_size, text_style=text_style, text_vertical_align=text_vertical_align, @@ -250,21 +238,58 @@ def __init__( hover_color=hover_color, hint_text=hint_text, hint_style=hint_style, + helper=helper, helper_text=helper_text, helper_style=helper_style, counter=counter, counter_text=counter_text, - counter_style=counter_style, + counter_text_style=counter_style, + error=error, error_text=error_text, - error_style=error_style, + error_text_style=error_style, prefix=prefix, prefix_icon=prefix_icon, prefix_text=prefix_text, - prefix_style=prefix_style, + prefix_text_style=prefix_style, suffix=suffix, suffix_icon=suffix_icon, suffix_text=suffix_text, - suffix_style=suffix_style, + suffix_text_style=suffix_style, + icon_color=icon_color, + prefix_icon_color=prefix_icon_color, + suffix_icon_color=suffix_icon_color, + focus_color=focus_color, + align_label_with_hint=align_label_with_hint, + floating_label_text_style=floating_label_text_style, + active_indicator_border_side=active_indicator_border_side, + hint_fade_duration=hint_fade_duration, + error_max_lines=error_max_lines, + helper_max_lines=helper_max_lines, + hint_max_lines=hint_max_lines, + ref=ref, + key=key, + width=width, + height=height, + expand=expand, + expand_loose=expand_loose, + col=col, + opacity=opacity, + rotate=rotate, + scale=scale, + offset=offset, + aspect_ratio=aspect_ratio, + animate_opacity=animate_opacity, + animate_size=animate_size, + animate_position=animate_position, + animate_rotation=animate_rotation, + animate_scale=animate_scale, + animate_offset=animate_offset, + on_animation_end=on_animation_end, + tooltip=tooltip, + visible=visible, + disabled=disabled, + data=data, + rtl=rtl, ) AdaptiveControl.__init__(self, adaptive=adaptive) From 964265db2b340164eeac66a324a164367bff59c5 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Thu, 25 Jul 2024 22:00:47 +0200 Subject: [PATCH 08/10] use DurationValue --- .../lib/src/controls/animated_switcher.dart | 19 ++++---- .../flet/lib/src/controls/dismissible.dart | 9 ++-- .../flet/lib/src/controls/navigation_bar.dart | 7 ++- .../lib/src/controls/scrollable_control.dart | 17 ++++--- packages/flet/lib/src/controls/snack_bar.dart | 46 ++++++++++--------- packages/flet/lib/src/controls/tabs.dart | 6 +-- packages/flet/lib/src/controls/tooltip.dart | 12 ++--- packages/flet/lib/src/utils/buttons.dart | 5 +- packages/flet/lib/src/utils/time.dart | 9 ++-- .../src/flet_core/animated_switcher.py | 23 ++++++---- .../flet-core/src/flet_core/animation.py | 8 ++-- .../flet-core/src/flet_core/border.py | 8 ++-- .../flet-core/src/flet_core/buttons.py | 5 +- .../flet-core/src/flet_core/dismissible.py | 27 ++++++----- .../src/flet_core/map/rich_attribution.py | 20 ++++---- .../flet-core/src/flet_core/navigation_bar.py | 12 +++-- .../packages/flet-core/src/flet_core/page.py | 3 +- .../src/flet_core/scrollable_control.py | 4 +- .../flet-core/src/flet_core/snack_bar.py | 12 +++-- .../packages/flet-core/src/flet_core/tabs.py | 12 +++-- .../flet-core/src/flet_core/time_picker.py | 11 +++-- .../flet-core/src/flet_core/tooltip.py | 23 ++++++---- .../packages/flet-core/src/flet_core/types.py | 9 ++-- 23 files changed, 166 insertions(+), 141 deletions(-) diff --git a/packages/flet/lib/src/controls/animated_switcher.dart b/packages/flet/lib/src/controls/animated_switcher.dart index e4344f6ce..9b3560367 100644 --- a/packages/flet/lib/src/controls/animated_switcher.dart +++ b/packages/flet/lib/src/controls/animated_switcher.dart @@ -1,3 +1,4 @@ +import 'package:flet/src/utils/time.dart'; import 'package:flutter/material.dart'; import '../models/control.dart'; @@ -27,12 +28,6 @@ class AnimatedSwitcherControl extends StatelessWidget { var contentCtrls = children.where((c) => c.name == "content" && c.isVisible); - var switchInCurve = - parseCurve(control.attrString("switchInCurve"), Curves.linear)!; - var switchOutCurve = - parseCurve(control.attrString("switchOutCurve"), Curves.linear)!; - var duration = control.attrInt("duration", 1000)!; - var reverseDuration = control.attrInt("reverseDuration", 1000)!; bool disabled = control.isDisabled || parentDisabled; if (contentCtrls.isEmpty) { @@ -46,10 +41,14 @@ class AnimatedSwitcherControl extends StatelessWidget { return constrainedControl( context, AnimatedSwitcher( - duration: Duration(milliseconds: duration), - reverseDuration: Duration(milliseconds: reverseDuration), - switchInCurve: switchInCurve, - switchOutCurve: switchOutCurve, + duration: parseDuration( + control, "duration", const Duration(milliseconds: 1000))!, + reverseDuration: parseDuration(control, "reverseDuration", + const Duration(milliseconds: 1000))!, + switchInCurve: + parseCurve(control.attrString("switchInCurve"), Curves.linear)!, + switchOutCurve: parseCurve( + control.attrString("switchOutCurve"), Curves.linear)!, transitionBuilder: (child, animation) { switch (control.attrString("transition", "")!.toLowerCase()) { case "rotation": diff --git a/packages/flet/lib/src/controls/dismissible.dart b/packages/flet/lib/src/controls/dismissible.dart index ea156cf85..2e3bcb780 100644 --- a/packages/flet/lib/src/controls/dismissible.dart +++ b/packages/flet/lib/src/controls/dismissible.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import '../flet_control_backend.dart'; import '../models/control.dart'; import '../utils/dismissible.dart'; +import '../utils/time.dart'; import 'create_control.dart'; import 'error.dart'; @@ -121,10 +122,10 @@ class _DismissibleControlState extends State { return completer.future; } : null, - movementDuration: Duration( - milliseconds: widget.control.attrInt("duration", 200)!), - resizeDuration: Duration( - milliseconds: widget.control.attrInt("resizeDuration", 300)!), + movementDuration: parseDuration(widget.control, "movementDuration", + const Duration(milliseconds: 200))!, + resizeDuration: parseDuration(widget.control, "resizeDuration", + const Duration(milliseconds: 300))!, crossAxisEndOffset: widget.control.attrDouble("crossAxisEndOffset", 0.0)!, dismissThresholds: dismissThresholds ?? {}, diff --git a/packages/flet/lib/src/controls/navigation_bar.dart b/packages/flet/lib/src/controls/navigation_bar.dart index bfca05aa0..5057487fd 100644 --- a/packages/flet/lib/src/controls/navigation_bar.dart +++ b/packages/flet/lib/src/controls/navigation_bar.dart @@ -6,6 +6,7 @@ import '../utils/borders.dart'; import '../utils/colors.dart'; import '../utils/icons.dart'; import '../utils/others.dart'; +import '../utils/time.dart'; import 'create_control.dart'; import 'cupertino_navigation_bar.dart'; import 'flet_store_mixin.dart'; @@ -68,7 +69,6 @@ class _NavigationBarControlState extends State if (_selectedIndex != selectedIndex) { _selectedIndex = selectedIndex; } - var animationDuration = widget.control.attrInt("animationDuration"); NavigationDestinationLabelBehavior? labelBehavior = parseNavigationDestinationLabelBehavior( @@ -81,9 +81,8 @@ class _NavigationBarControlState extends State return NavigationBar( labelBehavior: labelBehavior, height: widget.control.attrDouble("height"), - animationDuration: animationDuration != null - ? Duration(milliseconds: animationDuration) - : null, + animationDuration: + parseDuration(widget.control, "animationDuration"), elevation: widget.control.attrDouble("elevation"), shadowColor: widget.control.attrColor("shadowColor", context), surfaceTintColor: diff --git a/packages/flet/lib/src/controls/scrollable_control.dart b/packages/flet/lib/src/controls/scrollable_control.dart index 384809b37..d2051aac1 100644 --- a/packages/flet/lib/src/controls/scrollable_control.dart +++ b/packages/flet/lib/src/controls/scrollable_control.dart @@ -10,6 +10,7 @@ import '../utils/animations.dart'; import '../utils/desktop.dart'; import '../utils/numbers.dart'; import '../utils/others.dart'; +import '../utils/time.dart'; import '../widgets/adjustable_scroll_controller.dart'; import 'flet_store_mixin.dart'; @@ -87,7 +88,8 @@ class _ScrollableControlState extends State var params = Map.from(mj["p"] as Map); if (name == "scroll_to") { - var duration = parseInt(params["duration"], 0)!; + var duration = durationFromJSON(params["duration"]) ?? Duration.zero; + var curve = parseCurve(params["curve"], Curves.ease)!; if (params["key"] != null) { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -96,10 +98,7 @@ class _ScrollableControlState extends State var ctx = key.currentContext; if (ctx != null) { Scrollable.ensureVisible(ctx, - duration: duration > 0 - ? Duration(milliseconds: duration) - : Duration.zero, - curve: curve); + duration: duration, curve: curve); } } }); @@ -109,12 +108,12 @@ class _ScrollableControlState extends State if (offset < 0) { offset = _controller.position.maxScrollExtent + offset + 1; } - if (duration < 1) { + if (duration.compareTo(const Duration(milliseconds: 1)) < 0) { _controller.jumpTo(offset); } else { _controller.animateTo( offset, - duration: Duration(milliseconds: duration), + duration: duration, curve: curve, ); } @@ -123,12 +122,12 @@ class _ScrollableControlState extends State WidgetsBinding.instance.addPostFrameCallback((_) { var delta = parseDouble(params["delta"], 0)!; var offset = _controller.position.pixels + delta; - if (duration < 1) { + if (duration.compareTo(const Duration(milliseconds: 1)) < 0) { _controller.jumpTo(offset); } else { _controller.animateTo( offset, - duration: Duration(milliseconds: duration), + duration: duration, curve: curve, ); } diff --git a/packages/flet/lib/src/controls/snack_bar.dart b/packages/flet/lib/src/controls/snack_bar.dart index e638c7485..e2de298ac 100644 --- a/packages/flet/lib/src/controls/snack_bar.dart +++ b/packages/flet/lib/src/controls/snack_bar.dart @@ -6,6 +6,7 @@ import '../utils/borders.dart'; import '../utils/dismissible.dart'; import '../utils/edge_insets.dart'; import '../utils/others.dart'; +import '../utils/time.dart'; import 'create_control.dart'; import 'error.dart'; @@ -73,28 +74,29 @@ class _SnackBarControlState extends State { } return SnackBar( - behavior: behavior, - clipBehavior: clipBehavior, - actionOverflowThreshold: - widget.control.attrDouble("actionOverflowThreshold"), - shape: parseOutlinedBorder(widget.control, "shape"), - onVisible: () { - debugPrint("SnackBar.onVisible(${widget.control.id})"); - widget.backend.triggerControlEvent(widget.control.id, "visible"); - }, - dismissDirection: dismissDirection, - showCloseIcon: widget.control.attrBool("showCloseIcon"), - closeIconColor: widget.control.attrColor("closeIconColor", context), - content: createControl(widget.control, contentCtrls.first.id, disabled, - parentAdaptive: widget.parentAdaptive), - backgroundColor: widget.control.attrColor("bgColor", context), - action: action, - margin: margin, - padding: parseEdgeInsets(widget.control, "padding"), - width: width, - elevation: widget.control.attrDouble("elevation"), - duration: - Duration(milliseconds: widget.control.attrInt("duration", 4000)!)); + behavior: behavior, + clipBehavior: clipBehavior, + actionOverflowThreshold: + widget.control.attrDouble("actionOverflowThreshold"), + shape: parseOutlinedBorder(widget.control, "shape"), + onVisible: () { + debugPrint("SnackBar.onVisible(${widget.control.id})"); + widget.backend.triggerControlEvent(widget.control.id, "visible"); + }, + dismissDirection: dismissDirection, + showCloseIcon: widget.control.attrBool("showCloseIcon"), + closeIconColor: widget.control.attrColor("closeIconColor", context), + content: createControl(widget.control, contentCtrls.first.id, disabled, + parentAdaptive: widget.parentAdaptive), + backgroundColor: widget.control.attrColor("bgColor", context), + action: action, + margin: margin, + padding: parseEdgeInsets(widget.control, "padding"), + width: width, + elevation: widget.control.attrDouble("elevation"), + duration: parseDuration( + widget.control, "duration", const Duration(milliseconds: 4000))!, + ); } @override diff --git a/packages/flet/lib/src/controls/tabs.dart b/packages/flet/lib/src/controls/tabs.dart index 5c5a4c127..a7db7a620 100644 --- a/packages/flet/lib/src/controls/tabs.dart +++ b/packages/flet/lib/src/controls/tabs.dart @@ -15,6 +15,7 @@ import '../utils/icons.dart'; import '../utils/material_state.dart'; import '../utils/mouse.dart'; import '../utils/others.dart'; +import '../utils/time.dart'; import 'create_control.dart'; class TabsControl extends StatefulWidget { @@ -92,9 +93,8 @@ class _TabsControlState extends State } _tabController = TabController( length: viewModel.controlViews.length, - animationDuration: Duration( - milliseconds: - widget.control.attrInt("animationDuration", 50)!), + animationDuration: parseDuration(widget.control, + "animationDuration", const Duration(milliseconds: 50))!, vsync: this); _tabController!.addListener(_tabChanged); } diff --git a/packages/flet/lib/src/controls/tooltip.dart b/packages/flet/lib/src/controls/tooltip.dart index a50a266b8..794195be1 100644 --- a/packages/flet/lib/src/controls/tooltip.dart +++ b/packages/flet/lib/src/controls/tooltip.dart @@ -6,6 +6,7 @@ import '../utils/edge_insets.dart'; import '../utils/gradient.dart'; import '../utils/others.dart'; import '../utils/text.dart'; +import '../utils/time.dart'; import 'create_control.dart'; class TooltipControl extends StatelessWidget { @@ -31,9 +32,6 @@ class TooltipControl extends StatelessWidget { children.where((c) => c.name == "content" && c.isVisible); bool disabled = control.isDisabled || parentDisabled; - var showDuration = control.attrInt("showDuration"); - var waitDuration = control.attrInt("waitDuration"); - var bgColor = control.attrString("bgColor"); var border = parseBorder(Theme.of(context), control, "border"); var borderRadius = parseBorderRadius(control, "borderRadius"); @@ -72,12 +70,8 @@ class TooltipControl extends StatelessWidget { padding: parseEdgeInsets(control, "padding"), preferBelow: control.attrBool("preferBelow"), message: control.attrString("message"), - showDuration: showDuration != null - ? Duration(milliseconds: showDuration) - : null, - waitDuration: waitDuration != null - ? Duration(milliseconds: waitDuration) - : null, + showDuration: parseDuration(control, "showDuration"), + waitDuration: parseDuration(control, "waitDuration"), verticalOffset: control.attrDouble("verticalOffset"), textStyle: parseTextStyle(Theme.of(context), control, "textStyle"), textAlign: parseTextAlign(control.attrString("textAlign")), diff --git a/packages/flet/lib/src/utils/buttons.dart b/packages/flet/lib/src/utils/buttons.dart index 85474cf63..9b2a59e00 100644 --- a/packages/flet/lib/src/utils/buttons.dart +++ b/packages/flet/lib/src/utils/buttons.dart @@ -13,6 +13,7 @@ import 'mouse.dart'; import 'numbers.dart'; import 'text.dart'; import 'theme.dart'; +import 'time.dart'; ButtonStyle? parseButtonStyle(ThemeData theme, Control control, String propName, {Color? defaultForegroundColor, @@ -70,9 +71,7 @@ ButtonStyle? buttonStyleFromJSON(ThemeData theme, Map? json, (jv) => parseColor(theme, jv as String), defaultSurfaceTintColor), elevation: getWidgetStateProperty( json["elevation"], (jv) => parseDouble(jv, 0)!, defaultElevation), - animationDuration: json["animation_duration"] != null - ? Duration(milliseconds: parseInt(json["animation_duration"], 0)!) - : null, + animationDuration: durationFromJSON(json["animation_duration"]), padding: getWidgetStateProperty( json["padding"], (jv) => edgeInsetsFromJson(jv), defaultPadding), side: getWidgetStateProperty( diff --git a/packages/flet/lib/src/utils/time.dart b/packages/flet/lib/src/utils/time.dart index 0c64d8751..5a9ef6e6f 100644 --- a/packages/flet/lib/src/utils/time.dart +++ b/packages/flet/lib/src/utils/time.dart @@ -4,7 +4,7 @@ import '../models/control.dart'; import 'numbers.dart'; Duration? parseDuration(Control control, String propName, - {Duration? defaultValue}) { + [Duration? defaultValue]) { var v = control.attrString(propName, null); if (v == null) { return null; @@ -14,9 +14,12 @@ Duration? parseDuration(Control control, String propName, return durationFromJSON(j1); } -Duration durationFromJSON(dynamic json) { +Duration? durationFromJSON(dynamic json) { + if (json == null) { + return null; + } if (json is int || json is double) { - return Duration(seconds: parseInt(json, 0)!); + return Duration(milliseconds: parseInt(json, 0)!); } return Duration( days: parseInt(json["days"], 0)!, diff --git a/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py b/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py index d7a904e75..ef17ef816 100644 --- a/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py +++ b/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py @@ -12,6 +12,7 @@ RotateValue, ScaleValue, OptionalEventCallable, + DurationValue, ) try: @@ -81,8 +82,8 @@ def animate(e): def __init__( self, content: Control, - duration: Optional[int] = None, - reverse_duration: Optional[int] = None, + duration: DurationValue = None, + reverse_duration: DurationValue = None, switch_in_curve: Optional[AnimationCurve] = None, switch_out_curve: Optional[AnimationCurve] = None, transition: Optional[AnimatedSwitcherTransition] = None, @@ -159,6 +160,8 @@ def _get_control_name(self): def before_update(self): super().before_update() assert self.__content.visible, "content must be visible" + self._set_attr_json("duration", self.__duration) + self._set_attr_json("reverseDuration", self.__reverse_duration) def _get_children(self): self.__content._set_attr_internal("n", "content") @@ -175,21 +178,21 @@ def content(self, value: Control): # duration @property - def duration(self) -> int: - return self._get_attr("duration", data_type="int", def_value=1000) + def duration(self) -> DurationValue: + return self.__duration @duration.setter - def duration(self, value: Optional[int]): - self._set_attr("duration", value) + def duration(self, value: DurationValue): + self.__duration = value # reverse_duration @property - def reverse_duration(self) -> int: - return self._get_attr("reverseDuration", data_type="int", def_value=1000) + def reverse_duration(self) -> DurationValue: + return self.__reverse_duration @reverse_duration.setter - def reverse_duration(self, value: Optional[int]): - self._set_attr("reverseDuration", value) + def reverse_duration(self, value: DurationValue): + self.__reverse_duration = value # switch_in_curve @property diff --git a/sdk/python/packages/flet-core/src/flet_core/animation.py b/sdk/python/packages/flet-core/src/flet_core/animation.py index d943abc8b..45a6c2f29 100644 --- a/sdk/python/packages/flet-core/src/flet_core/animation.py +++ b/sdk/python/packages/flet-core/src/flet_core/animation.py @@ -1,6 +1,8 @@ from dataclasses import dataclass, field from enum import Enum -from typing import Optional +from typing import Optional, Union + +from flet_core.types import Duration try: from typing import Literal @@ -55,9 +57,9 @@ class AnimationCurve(Enum): @dataclass class Animation: - duration: int = field(default=1) + duration: Union[int, Duration] = field(default=1000) curve: Optional[AnimationCurve] = field(default=None) -def implicit(duration: int, curve: Optional[AnimationCurve] = None): +def implicit(duration: Union[int, Duration], curve: Optional[AnimationCurve] = None): return Animation(duration=duration, curve=curve) diff --git a/sdk/python/packages/flet-core/src/flet_core/border.py b/sdk/python/packages/flet-core/src/flet_core/border.py index a12639e8c..aa9ea7829 100644 --- a/sdk/python/packages/flet-core/src/flet_core/border.py +++ b/sdk/python/packages/flet-core/src/flet_core/border.py @@ -2,8 +2,6 @@ from enum import Enum from typing import Optional, Union -from flet_core.types import OptionalNumber - class BorderSideStrokeAlign(Enum): STROKE_ALIGN_INSIDE = -1.0 @@ -13,9 +11,11 @@ class BorderSideStrokeAlign(Enum): @dataclass class BorderSide: - width: OptionalNumber + width: Union[None, int, float] color: Optional[str] = field(default=None) - stroke_align: Union[BorderSideStrokeAlign, OptionalNumber] = field(default=None) + stroke_align: Union[BorderSideStrokeAlign, Union[None, int, float]] = field( + default=None + ) @dataclass diff --git a/sdk/python/packages/flet-core/src/flet_core/buttons.py b/sdk/python/packages/flet-core/src/flet_core/buttons.py index 9e50fc944..b9a0fa045 100644 --- a/sdk/python/packages/flet-core/src/flet_core/buttons.py +++ b/sdk/python/packages/flet-core/src/flet_core/buttons.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field -from typing import Dict, Optional, Union +from typing import Dict, Union from flet_core.alignment import Alignment from flet_core.border import BorderSide @@ -12,6 +12,7 @@ ThemeVisualDensity, VisualDensity, MouseCursor, + DurationValue, ) @@ -71,7 +72,7 @@ class ButtonStyle: elevation: Union[ None, float, int, Dict[Union[str, ControlState], Union[float, int]] ] = field(default=None) - animation_duration: Optional[int] = field(default=None) + animation_duration: DurationValue = field(default=None) padding: Union[PaddingValue, Dict[Union[str, ControlState], PaddingValue]] = field( default=None ) diff --git a/sdk/python/packages/flet-core/src/flet_core/dismissible.py b/sdk/python/packages/flet-core/src/flet_core/dismissible.py index 46d1d5384..598092a65 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dismissible.py +++ b/sdk/python/packages/flet-core/src/flet_core/dismissible.py @@ -15,6 +15,7 @@ RotateValue, ScaleValue, OptionalEventCallable, + DurationValue, ) from flet_core.utils import deprecated @@ -40,8 +41,8 @@ def __init__( secondary_background: Optional[Control] = None, dismiss_direction: Optional[DismissDirection] = None, dismiss_thresholds: Optional[Dict[DismissDirection, OptionalNumber]] = None, - movement_duration: Optional[int] = None, - resize_duration: Optional[int] = None, + movement_duration: DurationValue = None, + resize_duration: DurationValue = None, cross_axis_end_offset: OptionalNumber = None, on_update: Optional[Callable[["DismissibleUpdateEvent"], None]] = None, on_dismiss: Optional[Callable[["DismissibleDismissEvent"], None]] = None, @@ -157,6 +158,8 @@ def _get_children(self): def before_update(self): super().before_update() self._set_attr_json("dismissThresholds", self.__dismiss_thresholds) + self._set_attr_json("movementDuration", self.__movement_duration) + self._set_attr_json("resizeDuration", self.__resize_duration) def confirm_dismiss(self, dismiss: bool): self.invoke_method("confirm_dismiss", {"dismiss": str(dismiss).lower()}) @@ -196,23 +199,23 @@ def secondary_background(self) -> Optional[Control]: def secondary_background(self, value: Optional[Control]): self.__secondary_background = value - # movementDuration + # movement_duration @property - def movement_duration(self) -> Optional[int]: - return self._get_attr("movementDuration", data_type="int") + def movement_duration(self) -> DurationValue: + return self.__movement_duration @movement_duration.setter - def movement_duration(self, value: Optional[int]): - self._set_attr("movementDuration", value) + def movement_duration(self, value: DurationValue): + self.__movement_duration = value - # resizeDuration + # resize_duration @property - def resize_duration(self) -> Optional[int]: - return self._get_attr("resizeDuration", data_type="int") + def resize_duration(self) -> DurationValue: + return self.__resize_duration @resize_duration.setter - def resize_duration(self, value: Optional[int]): - self._set_attr("resizeDuration", value) + def resize_duration(self, value: DurationValue): + self.__resize_duration = value # crossAxisEndOffset @property diff --git a/sdk/python/packages/flet-core/src/flet_core/map/rich_attribution.py b/sdk/python/packages/flet-core/src/flet_core/map/rich_attribution.py index 3208c94bc..19d1f900b 100644 --- a/sdk/python/packages/flet-core/src/flet_core/map/rich_attribution.py +++ b/sdk/python/packages/flet-core/src/flet_core/map/rich_attribution.py @@ -6,6 +6,7 @@ from flet_core.map.map_layer import MapLayer from flet_core.map.text_source_attribution import TextSourceAttribution from flet_core.ref import Ref +from flet_core.types import DurationValue class AttributionAlignment(Enum): @@ -29,7 +30,7 @@ def __init__( alignment: Optional[AttributionAlignment] = None, popup_bgcolor: Optional[str] = None, popup_border_radius: Optional[BorderRadius] = None, - popup_initial_display_duration: Optional[int] = None, + popup_initial_display_duration: DurationValue = None, permanent_height: OptionalNumber = None, show_flutter_map_attribution: Optional[bool] = None, # @@ -65,6 +66,9 @@ def before_update(self): super().before_update() self._set_attr_json("popupBorderRadius", self.__popup_border_radius) self._set_attr_json("alignment", self.__alignment) + self._set_attr_json( + "popupInitialDisplayDuration", self.__popup_initial_display_duration + ) # permanent_height @property @@ -78,17 +82,15 @@ def permanent_height(self, value: OptionalNumber): # popup_initial_display_duration @property - def popup_initial_display_duration(self) -> int: - return self._get_attr( - "popupInitialDisplayDuration", data_type="int", def_value=0 - ) + def popup_initial_display_duration(self) -> DurationValue: + return self.__popup_initial_display_duration @popup_initial_display_duration.setter - def popup_initial_display_duration(self, value: Optional[int]): - assert ( - value is None or value >= 0 + def popup_initial_display_duration(self, value: DurationValue): + assert value is None or ( + isinstance(value, int) and value >= 0 ), "popup_initial_display_duration cannot be negative" - self._set_attr("popupInitialDisplayDuration", value) + self.__popup_initial_display_duration = value # popup_border_radius @property diff --git a/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py b/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py index 5353f89ed..4c0b4a2b1 100644 --- a/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py @@ -16,6 +16,7 @@ RotateValue, ScaleValue, ControlState, + DurationValue, ) from flet_core.utils import deprecated @@ -210,7 +211,7 @@ def __init__( indicator_shape: Optional[OutlinedBorder] = None, surface_tint_color: Optional[str] = None, border: Optional[Border] = None, - animation_duration: Optional[int] = None, + animation_duration: DurationValue = None, overlay_color: Union[None, str, Dict[ControlState, str]] = None, on_change: OptionalEventCallable = None, # @@ -296,6 +297,7 @@ def before_update(self): self._set_attr_json("indicatorShape", self.__indicator_shape) self._set_attr_json("border", self.__border) self._set_attr_json("overlayColor", self.__overlay_color) + self._set_attr_json("animationDuration", self.__animation_duration) def _get_children(self): return self.__destinations @@ -402,12 +404,12 @@ def border(self, value: Optional[Border]): # animation_duration @property - def animation_duration(self) -> Optional[int]: - return self._get_attr("animationDuration", data_type="int") + def animation_duration(self) -> DurationValue: + return self.__animation_duration @animation_duration.setter - def animation_duration(self, value: Optional[int]): - self._set_attr("animationDuration", value) + def animation_duration(self, value: DurationValue): + self.__animation_duration = value # on_change @property diff --git a/sdk/python/packages/flet-core/src/flet_core/page.py b/sdk/python/packages/flet-core/src/flet_core/page.py index 9f0b37c26..e13b21f09 100644 --- a/sdk/python/packages/flet-core/src/flet_core/page.py +++ b/sdk/python/packages/flet-core/src/flet_core/page.py @@ -77,6 +77,7 @@ Wrapper, OptionalEventCallable, WindowEventType, + DurationValue, ) from flet_core.utils import classproperty, deprecated from flet_core.utils.concurrency_utils import is_pyodide @@ -1286,7 +1287,7 @@ def scroll_to( offset: Optional[float] = None, delta: Optional[float] = None, key: Optional[str] = None, - duration: Optional[int] = None, + duration: DurationValue = None, curve: Optional[AnimationCurve] = None, ) -> None: self.__default_view.scroll_to( diff --git a/sdk/python/packages/flet-core/src/flet_core/scrollable_control.py b/sdk/python/packages/flet-core/src/flet_core/scrollable_control.py index e06726b68..d64d3775a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/scrollable_control.py +++ b/sdk/python/packages/flet-core/src/flet_core/scrollable_control.py @@ -6,7 +6,7 @@ from flet_core.control import Control, OptionalNumber from flet_core.control_event import ControlEvent from flet_core.event_handler import EventHandler -from flet_core.types import ScrollMode +from flet_core.types import ScrollMode, DurationValue from flet_core.utils import deprecated @@ -34,7 +34,7 @@ def scroll_to( offset: Optional[float] = None, delta: Optional[float] = None, key: Optional[str] = None, - duration: Optional[int] = None, + duration: DurationValue = None, curve: Optional[AnimationCurve] = None, ): m = { diff --git a/sdk/python/packages/flet-core/src/flet_core/snack_bar.py b/sdk/python/packages/flet-core/src/flet_core/snack_bar.py index a6e6b993f..cf02b932b 100644 --- a/sdk/python/packages/flet-core/src/flet_core/snack_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/snack_bar.py @@ -10,6 +10,7 @@ PaddingValue, ClipBehavior, OptionalEventCallable, + DurationValue, ) @@ -77,7 +78,7 @@ def __init__( action_color: Optional[str] = None, close_icon_color: Optional[str] = None, bgcolor: Optional[str] = None, - duration: Optional[int] = None, + duration: DurationValue = None, margin: MarginValue = None, padding: PaddingValue = None, width: OptionalNumber = None, @@ -134,6 +135,7 @@ def before_update(self): super().before_update() self._set_attr_json("shape", self.__shape) self._set_attr_json("padding", self.__padding) + self._set_attr_json("duration", self.__duration) if isinstance(self.__margin, (int, float, Padding)) and not self.width: # margin and width cannot be set together - if width is set, margin is ignored self._set_attr_json("margin", self.__margin) @@ -203,12 +205,12 @@ def close_icon_color(self, value: Optional[str]): # duration @property - def duration(self) -> Optional[int]: - return self._get_attr("duration", data_type="int") + def duration(self) -> DurationValue: + return self.__duration @duration.setter - def duration(self, value: Optional[int]): - self._set_attr("duration", value) + def duration(self, value: DurationValue): + self.__duration = value # action_overflow_threshold @property diff --git a/sdk/python/packages/flet-core/src/flet_core/tabs.py b/sdk/python/packages/flet-core/src/flet_core/tabs.py index b2b80112f..54d416c4e 100644 --- a/sdk/python/packages/flet-core/src/flet_core/tabs.py +++ b/sdk/python/packages/flet-core/src/flet_core/tabs.py @@ -18,6 +18,7 @@ ScaleValue, TabAlignment, OptionalEventCallable, + DurationValue, ) @@ -147,7 +148,7 @@ def __init__( selected_index: Optional[int] = None, scrollable: Optional[bool] = None, tab_alignment: Optional[TabAlignment] = None, - animation_duration: Optional[int] = None, + animation_duration: DurationValue = None, divider_color: Optional[str] = None, indicator_color: Optional[str] = None, indicator_border_radius: BorderRadiusValue = None, @@ -258,6 +259,7 @@ def before_update(self): self._set_attr_json("indicatorBorderRadius", self.__indicator_border_radius) self._set_attr_json("indicatorBorderSide", self.__indicator_border_side) self._set_attr_json("indicatorPadding", self.__indicator_padding) + self._set_attr_json("animationDuration", self.__animation_duration) def _get_children(self): return self.__tabs @@ -339,12 +341,12 @@ def tab_alignment(self, value: Optional[TabAlignment]): # animation_duration @property - def animation_duration(self) -> Optional[int]: - return self._get_attr("animationDuration", data_type="int") + def animation_duration(self) -> DurationValue: + return self.__animation_duration @animation_duration.setter - def animation_duration(self, value: Optional[int]): - self._set_attr("animationDuration", value) + def animation_duration(self, value: DurationValue): + self.__animation_duration = value # divider_height @property diff --git a/sdk/python/packages/flet-core/src/flet_core/time_picker.py b/sdk/python/packages/flet-core/src/flet_core/time_picker.py index 46594bd9c..07063636a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/time_picker.py +++ b/sdk/python/packages/flet-core/src/flet_core/time_picker.py @@ -2,11 +2,16 @@ from enum import Enum from typing import Any, Optional, Union, Callable -from flet_core import ControlEvent -from flet_core.control import Control, OptionalNumber +from flet_core.control import Control +from flet_core.control_event import ControlEvent from flet_core.event_handler import EventHandler from flet_core.ref import Ref -from flet_core.types import Orientation, ResponsiveNumber, OptionalEventCallable +from flet_core.types import ( + Orientation, + ResponsiveNumber, + OptionalEventCallable, + OptionalNumber, +) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/tooltip.py b/sdk/python/packages/flet-core/src/flet_core/tooltip.py index d964c1ab7..09e891ddf 100644 --- a/sdk/python/packages/flet-core/src/flet_core/tooltip.py +++ b/sdk/python/packages/flet-core/src/flet_core/tooltip.py @@ -11,6 +11,7 @@ MarginValue, PaddingValue, TextAlign, + DurationValue, ) @@ -79,8 +80,8 @@ def __init__( text_style: Optional[TextStyle] = None, text_align: Optional[TextAlign] = None, prefer_below: Optional[bool] = None, - show_duration: Optional[int] = None, - wait_duration: Optional[int] = None, + show_duration: DurationValue = None, + wait_duration: DurationValue = None, enable_tap_to_dismiss: Optional[bool] = None, exclude_from_semantics: Optional[bool] = None, # @@ -130,6 +131,8 @@ def before_update(self): self._set_attr_json("borderRadius", self.__border_radius) self._set_attr_json("border", self.__border) self._set_attr_json("gradient", self.__gradient) + self._set_attr_json("showDuration", self.__show_duration) + self._set_attr_json("waitDuration", self.__wait_duration) def _get_children(self): if self.__content is not None: @@ -285,21 +288,21 @@ def vertical_offset(self, value: OptionalNumber): # show_duration @property - def show_duration(self) -> Optional[int]: - return self._get_attr("showDuration", data_type="int") + def show_duration(self) -> DurationValue: + return self.__show_duration @show_duration.setter - def show_duration(self, value: Optional[int]): - self._set_attr("showDuration", value) + def show_duration(self, value: DurationValue): + self.__show_duration = value # wait_duration @property - def wait_duration(self) -> Optional[int]: - return self._get_attr("waitDuration", data_type="int") + def wait_duration(self) -> DurationValue: + return self.__wait_duration @wait_duration.setter - def wait_duration(self, value: Optional[int]): - self._set_attr("waitDuration", value) + def wait_duration(self, value: DurationValue): + self.__wait_duration = value # content @property diff --git a/sdk/python/packages/flet-core/src/flet_core/types.py b/sdk/python/packages/flet-core/src/flet_core/types.py index cbdeb7360..6968d9b09 100644 --- a/sdk/python/packages/flet-core/src/flet_core/types.py +++ b/sdk/python/packages/flet-core/src/flet_core/types.py @@ -1,15 +1,18 @@ from dataclasses import dataclass from enum import Enum, EnumMeta -from typing import Any, Callable, Dict, Optional, Protocol, Tuple, Union +from typing import Any, Callable, Dict, Optional, Protocol, Tuple, Union, TYPE_CHECKING from warnings import warn -from flet_core.animation import Animation from flet_core.border_radius import BorderRadius from flet_core.control_event import ControlEvent from flet_core.margin import Margin from flet_core.padding import Padding from flet_core.transform import Offset, Rotate, Scale +if TYPE_CHECKING: + pass + + WEB_BROWSER = "web_browser" FLET_APP = "flet_app" FLET_APP_WEB = "flet_app_web" @@ -64,7 +67,7 @@ class UrlTarget(Enum): OffsetValue = Optional[Union[Offset, Tuple[Union[float, int], Union[float, int]]]] -AnimationValue = Optional[Union[bool, int, Animation]] +AnimationValue = Optional[Union[bool, int, "Animation"]] class FontWeight(Enum): From e153cce980918b0e0ddc06d2cf961f109d763d0a Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Fri, 2 Aug 2024 18:32:18 +0200 Subject: [PATCH 09/10] optimize imports --- sdk/python/packages/flet-core/src/flet_core/column.py | 2 +- .../src/flet_core/cupertino_sliding_segmented_button.py | 2 +- sdk/python/packages/flet-core/src/flet_core/expansion_tile.py | 2 +- .../packages/flet-core/src/flet_core/navigation_drawer.py | 2 +- sdk/python/packages/flet-core/src/flet_core/responsive_row.py | 2 +- sdk/python/packages/flet-core/src/flet_core/submenu_button.py | 2 +- sdk/python/packages/flet-core/src/flet_core/template_route.py | 1 + 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sdk/python/packages/flet-core/src/flet_core/column.py b/sdk/python/packages/flet-core/src/flet_core/column.py index 6f60b2109..b1cbb1dec 100644 --- a/sdk/python/packages/flet-core/src/flet_core/column.py +++ b/sdk/python/packages/flet-core/src/flet_core/column.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Union, Callable +from typing import Any, Optional, Sequence, Union, Callable from flet_core.adaptive_control import AdaptiveControl from flet_core.constrained_control import ConstrainedControl diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py index d1b7972f0..b74159de0 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence, Union, List +from typing import Any, Optional, Sequence, Union from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber, Control diff --git a/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py b/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py index 24dfb06ec..cf78dbc01 100644 --- a/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py +++ b/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, List, Optional, Union, Sequence +from typing import Any, Optional, Union, Sequence from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment diff --git a/sdk/python/packages/flet-core/src/flet_core/navigation_drawer.py b/sdk/python/packages/flet-core/src/flet_core/navigation_drawer.py index a88f69ddb..e43f85b08 100644 --- a/sdk/python/packages/flet-core/src/flet_core/navigation_drawer.py +++ b/sdk/python/packages/flet-core/src/flet_core/navigation_drawer.py @@ -240,7 +240,7 @@ def controls(self) -> Optional[List[Control]]: @controls.setter def controls(self, value: Optional[Sequence[Control]]): - self.__controls = list(value) if value is not None else [] + self.__controls = list(value) if value is not None else [] # selected_index @property diff --git a/sdk/python/packages/flet-core/src/flet_core/responsive_row.py b/sdk/python/packages/flet-core/src/flet_core/responsive_row.py index 8f71ab06b..3e85e5f2c 100644 --- a/sdk/python/packages/flet-core/src/flet_core/responsive_row.py +++ b/sdk/python/packages/flet-core/src/flet_core/responsive_row.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Union, Sequence +from typing import Any, Optional, Union, Sequence from flet_core.adaptive_control import AdaptiveControl from flet_core.constrained_control import ConstrainedControl diff --git a/sdk/python/packages/flet-core/src/flet_core/submenu_button.py b/sdk/python/packages/flet-core/src/flet_core/submenu_button.py index eb8b1a5a4..720fe32b7 100644 --- a/sdk/python/packages/flet-core/src/flet_core/submenu_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/submenu_button.py @@ -1,5 +1,5 @@ import time -from typing import Any, List, Optional, Union, Sequence +from typing import Any, Optional, Union, Sequence from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl diff --git a/sdk/python/packages/flet-core/src/flet_core/template_route.py b/sdk/python/packages/flet-core/src/flet_core/template_route.py index 12b693a1f..a60e8a867 100644 --- a/sdk/python/packages/flet-core/src/flet_core/template_route.py +++ b/sdk/python/packages/flet-core/src/flet_core/template_route.py @@ -1,4 +1,5 @@ import re + import repath From 64473f4b38b7266d7b5674cd2e9167237f9b0ec3 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sun, 27 Oct 2024 02:53:51 +0100 Subject: [PATCH 10/10] fix AnimationDuration imports --- .../flet-core/src/flet_core/animated_switcher.py | 4 ++-- .../packages/flet-core/src/flet_core/animation.py | 3 +++ .../flet-core/src/flet_core/bottom_app_bar.py | 4 ++-- .../flet-core/src/flet_core/canvas/canvas.py | 6 +++--- .../packages/flet-core/src/flet_core/card.py | 4 ++-- .../flet-core/src/flet_core/charts/bar_chart.py | 8 ++++---- .../flet-core/src/flet_core/charts/line_chart.py | 10 +++++----- .../flet-core/src/flet_core/charts/pie_chart.py | 6 +++--- .../packages/flet-core/src/flet_core/checkbox.py | 6 +++--- .../packages/flet-core/src/flet_core/chip.py | 10 +++++----- .../flet-core/src/flet_core/circle_avatar.py | 4 ++-- .../packages/flet-core/src/flet_core/column.py | 8 ++++---- .../flet-core/src/flet_core/constrained_control.py | 4 ++-- .../packages/flet-core/src/flet_core/container.py | 2 +- .../src/flet_core/cupertino_action_sheet.py | 4 ++-- .../src/flet_core/cupertino_action_sheet_action.py | 4 ++-- .../src/flet_core/cupertino_activity_indicator.py | 4 ++-- .../flet-core/src/flet_core/cupertino_button.py | 4 ++-- .../flet-core/src/flet_core/cupertino_checkbox.py | 4 ++-- .../src/flet_core/cupertino_date_picker.py | 4 ++-- .../flet-core/src/flet_core/cupertino_list_tile.py | 4 ++-- .../src/flet_core/cupertino_navigation_bar.py | 4 ++-- .../flet-core/src/flet_core/cupertino_picker.py | 4 ++-- .../flet-core/src/flet_core/cupertino_radio.py | 4 ++-- .../src/flet_core/cupertino_segmented_button.py | 10 +++++----- .../flet-core/src/flet_core/cupertino_slider.py | 4 ++-- .../cupertino_sliding_segmented_button.py | 8 ++++---- .../flet-core/src/flet_core/cupertino_switch.py | 4 ++-- .../flet-core/src/flet_core/cupertino_textfield.py | 6 +++--- .../src/flet_core/cupertino_timer_picker.py | 4 ++-- .../packages/flet-core/src/flet_core/datatable.py | 10 +++++----- .../flet-core/src/flet_core/dismissible.py | 2 +- .../packages/flet-core/src/flet_core/dropdown.py | 2 +- .../flet-core/src/flet_core/dropdown_menu.py | 2 +- .../flet-core/src/flet_core/elevated_button.py | 2 +- .../flet-core/src/flet_core/expansion_panel.py | 4 ++-- .../flet-core/src/flet_core/expansion_tile.py | 6 +++--- .../packages/flet-core/src/flet_core/flet_app.py | 4 ++-- .../src/flet_core/floating_action_button.py | 4 ++-- .../flet-core/src/flet_core/form_field_control.py | 2 +- .../flet-core/src/flet_core/gesture_detector.py | 6 +++--- .../packages/flet-core/src/flet_core/grid_view.py | 10 +++++----- .../packages/flet-core/src/flet_core/icon.py | 4 ++-- .../flet-core/src/flet_core/icon_button.py | 6 +++--- .../packages/flet-core/src/flet_core/image.py | 2 +- .../flet-core/src/flet_core/interactive_viewer.py | 10 +++++----- .../packages/flet-core/src/flet_core/list_tile.py | 6 +++--- .../packages/flet-core/src/flet_core/list_view.py | 10 +++++----- .../packages/flet-core/src/flet_core/lottie.py | 6 +++--- .../packages/flet-core/src/flet_core/map/map.py | 14 +++++++------- .../src/flet_core/map/map_configuration.py | 4 +--- .../packages/flet-core/src/flet_core/markdown.py | 2 +- .../flet-core/src/flet_core/matplotlib_chart.py | 6 +++--- .../flet-core/src/flet_core/menu_item_button.py | 4 ++-- .../flet-core/src/flet_core/navigation_bar.py | 2 +- .../flet-core/src/flet_core/navigation_rail.py | 4 ++-- .../flet-core/src/flet_core/outlined_button.py | 4 ++-- .../packages/flet-core/src/flet_core/pagelet.py | 4 ++-- .../flet-core/src/flet_core/placeholder.py | 7 +++---- .../flet-core/src/flet_core/plotly_chart.py | 6 +++--- .../flet-core/src/flet_core/popup_menu_button.py | 4 ++-- .../flet-core/src/flet_core/progress_bar.py | 4 ++-- .../flet-core/src/flet_core/progress_ring.py | 4 ++-- .../packages/flet-core/src/flet_core/radio.py | 6 +++--- .../flet-core/src/flet_core/range_slider.py | 4 ++-- .../flet-core/src/flet_core/responsive_row.py | 6 +++--- .../packages/flet-core/src/flet_core/rive.py | 8 ++++---- sdk/python/packages/flet-core/src/flet_core/row.py | 10 +++++----- .../packages/flet-core/src/flet_core/safe_area.py | 4 ++-- .../packages/flet-core/src/flet_core/search_bar.py | 10 +++++----- .../flet-core/src/flet_core/segmented_button.py | 4 ++-- .../flet-core/src/flet_core/shader_mask.py | 4 ++-- .../packages/flet-core/src/flet_core/slider.py | 4 ++-- .../packages/flet-core/src/flet_core/stack.py | 6 +++--- .../flet-core/src/flet_core/submenu_button.py | 6 +++--- .../packages/flet-core/src/flet_core/switch.py | 6 +++--- .../packages/flet-core/src/flet_core/tabs.py | 2 +- .../packages/flet-core/src/flet_core/text.py | 6 +++--- .../flet-core/src/flet_core/text_button.py | 4 ++-- .../packages/flet-core/src/flet_core/textfield.py | 2 +- .../flet-core/src/flet_core/transparent_pointer.py | 4 ++-- .../packages/flet-core/src/flet_core/types.py | 3 --- .../packages/flet-core/src/flet_core/video.py | 6 +++--- .../packages/flet-core/src/flet_core/webview.py | 4 ++-- .../flet-core/src/flet_core/window_drag_area.py | 4 ++-- 85 files changed, 216 insertions(+), 219 deletions(-) diff --git a/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py b/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py index 04757d488..d597a50ea 100644 --- a/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py +++ b/sdk/python/packages/flet-core/src/flet_core/animated_switcher.py @@ -1,15 +1,15 @@ from enum import Enum from typing import Any, Optional, Union -from flet_core.animation import AnimationCurve +from flet_core.animation import AnimationCurve, AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, DurationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, diff --git a/sdk/python/packages/flet-core/src/flet_core/animation.py b/sdk/python/packages/flet-core/src/flet_core/animation.py index 45a6c2f29..659f8526c 100644 --- a/sdk/python/packages/flet-core/src/flet_core/animation.py +++ b/sdk/python/packages/flet-core/src/flet_core/animation.py @@ -63,3 +63,6 @@ class Animation: def implicit(duration: Union[int, Duration], curve: Optional[AnimationCurve] = None): return Animation(duration=duration, curve=curve) + + +AnimationValue = Optional[Union[bool, int, Animation]] diff --git a/sdk/python/packages/flet-core/src/flet_core/bottom_app_bar.py b/sdk/python/packages/flet-core/src/flet_core/bottom_app_bar.py index 6d426e25b..9f95165d4 100644 --- a/sdk/python/packages/flet-core/src/flet_core/bottom_app_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/bottom_app_bar.py @@ -1,18 +1,18 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue 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, NotchShape, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/canvas/canvas.py b/sdk/python/packages/flet-core/src/flet_core/canvas/canvas.py index 8a5461614..789efaf48 100644 --- a/sdk/python/packages/flet-core/src/flet_core/canvas/canvas.py +++ b/sdk/python/packages/flet-core/src/flet_core/canvas/canvas.py @@ -1,6 +1,7 @@ import json from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.canvas.shape import Shape from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber @@ -8,13 +9,12 @@ from flet_core.event_handler import EventHandler from flet_core.ref import Ref from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/card.py b/sdk/python/packages/flet-core/src/flet_core/card.py index 4546dc6ef..7dc05571f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/card.py +++ b/sdk/python/packages/flet-core/src/flet_core/card.py @@ -3,19 +3,19 @@ from flet_core import OutlinedBorder from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, MarginValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/charts/bar_chart.py b/sdk/python/packages/flet-core/src/flet_core/charts/bar_chart.py index e6dd328d4..58d4137c8 100644 --- a/sdk/python/packages/flet-core/src/flet_core/charts/bar_chart.py +++ b/sdk/python/packages/flet-core/src/flet_core/charts/bar_chart.py @@ -2,6 +2,7 @@ from enum import Enum from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.border import Border, BorderSide from flet_core.charts.bar_chart_group import BarChartGroup from flet_core.charts.chart_axis import ChartAxis @@ -13,14 +14,13 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, + PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - PaddingValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/charts/line_chart.py b/sdk/python/packages/flet-core/src/flet_core/charts/line_chart.py index a5cff181a..ef01366e1 100644 --- a/sdk/python/packages/flet-core/src/flet_core/charts/line_chart.py +++ b/sdk/python/packages/flet-core/src/flet_core/charts/line_chart.py @@ -1,6 +1,7 @@ import json -from typing import List, Optional, Union, Any +from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.border import Border, BorderSide from flet_core.charts.chart_axis import ChartAxis from flet_core.charts.chart_grid_lines import ChartGridLines @@ -12,14 +13,13 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, + PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - PaddingValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/charts/pie_chart.py b/sdk/python/packages/flet-core/src/flet_core/charts/pie_chart.py index 4702794ba..56cf60ed1 100644 --- a/sdk/python/packages/flet-core/src/flet_core/charts/pie_chart.py +++ b/sdk/python/packages/flet-core/src/flet_core/charts/pie_chart.py @@ -2,6 +2,7 @@ from enum import Enum from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.charts.pie_chart_section import PieChartSection from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber @@ -10,13 +11,12 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/checkbox.py b/sdk/python/packages/flet-core/src/flet_core/checkbox.py index a30241c60..bcf643b2d 100644 --- a/sdk/python/packages/flet-core/src/flet_core/checkbox.py +++ b/sdk/python/packages/flet-core/src/flet_core/checkbox.py @@ -1,6 +1,7 @@ from typing import Any, Dict, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.border import BorderSide from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl @@ -9,17 +10,16 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, - LabelPosition, ControlState, + LabelPosition, MouseCursor, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, ThemeVisualDensity, VisualDensity, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/chip.py b/sdk/python/packages/flet-core/src/flet_core/chip.py index 6ea0f22bc..55cb798cf 100644 --- a/sdk/python/packages/flet-core/src/flet_core/chip.py +++ b/sdk/python/packages/flet-core/src/flet_core/chip.py @@ -1,5 +1,6 @@ -from typing import Any, Optional, Union, Dict +from typing import Any, Dict, Optional, Union +from flet_core.animation import AnimationValue from flet_core.border import BorderSide from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl @@ -8,17 +9,16 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ClipBehavior, + ControlState, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - ClipBehavior, - ControlState, ThemeVisualDensity, VisualDensity, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/circle_avatar.py b/sdk/python/packages/flet-core/src/flet_core/circle_avatar.py index 112c4ca7c..5f3b9781d 100644 --- a/sdk/python/packages/flet-core/src/flet_core/circle_avatar.py +++ b/sdk/python/packages/flet-core/src/flet_core/circle_avatar.py @@ -1,17 +1,17 @@ import warnings from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/column.py b/sdk/python/packages/flet-core/src/flet_core/column.py index c078aea50..f5e6f2271 100644 --- a/sdk/python/packages/flet-core/src/flet_core/column.py +++ b/sdk/python/packages/flet-core/src/flet_core/column.py @@ -1,21 +1,21 @@ -from typing import Any, Optional, Sequence, Union, Callable +from typing import Any, Callable, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control from flet_core.ref import Ref -from flet_core.scrollable_control import ScrollableControl, OnScrollEvent +from flet_core.scrollable_control import OnScrollEvent, ScrollableControl from flet_core.types import ( - AnimationValue, CrossAxisAlignment, MainAxisAlignment, OffsetValue, + OptionalControlEventCallable, OptionalNumber, ResponsiveNumber, RotateValue, ScaleValue, ScrollMode, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/constrained_control.py b/sdk/python/packages/flet-core/src/flet_core/constrained_control.py index e0f8dc7aa..958127266 100644 --- a/sdk/python/packages/flet-core/src/flet_core/constrained_control.py +++ b/sdk/python/packages/flet-core/src/flet_core/constrained_control.py @@ -1,15 +1,15 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/container.py b/sdk/python/packages/flet-core/src/flet_core/container.py index 6dbbd52a6..90479c3e3 100644 --- a/sdk/python/packages/flet-core/src/flet_core/container.py +++ b/sdk/python/packages/flet-core/src/flet_core/container.py @@ -4,6 +4,7 @@ from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.blur import Blur from flet_core.border import Border from flet_core.box import ( @@ -22,7 +23,6 @@ from flet_core.theme import Theme from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BlendMode, BorderRadiusValue, ClipBehavior, diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet.py index 3953dc3e5..eb87fb36d 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet.py @@ -1,16 +1,16 @@ from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet_action.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet_action.py index 44656213a..0f5f1b6f9 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet_action.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_action_sheet_action.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_activity_indicator.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_activity_indicator.py index c96fe33eb..29a68a2fa 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_activity_indicator.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_activity_indicator.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_button.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_button.py index ff8bb3686..0ac936a7d 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_button.py @@ -2,20 +2,20 @@ from typing import Any, Optional, Union from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, UrlTarget, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_checkbox.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_checkbox.py index 9edfe4a1d..d0ca91ece 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_checkbox.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_checkbox.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, LabelPosition, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_date_picker.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_date_picker.py index a0d3a1353..565696ce0 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_date_picker.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_date_picker.py @@ -2,17 +2,17 @@ from enum import Enum from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_list_tile.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_list_tile.py index 0c2745493..e6b7eccfb 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_list_tile.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_list_tile.py @@ -1,18 +1,18 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, UrlTarget, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_navigation_bar.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_navigation_bar.py index ccf102921..499af95bc 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_navigation_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_navigation_bar.py @@ -1,17 +1,17 @@ from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.border import Border from flet_core.constrained_control import ConstrainedControl from flet_core.navigation_bar import NavigationBarDestination from flet_core.ref import Ref from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, OptionalNumber, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_picker.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_picker.py index c6b8cfac8..16372a7ee 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_picker.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_picker.py @@ -1,16 +1,16 @@ from typing import Any, List, Optional, Sequence, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_radio.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_radio.py index 53b7af778..f7136d244 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_radio.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_radio.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, LabelPosition, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) try: diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_segmented_button.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_segmented_button.py index b8c40aeaf..8614046ff 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_segmented_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_segmented_button.py @@ -1,17 +1,17 @@ -from typing import Any, Optional, Sequence, Union, List +from typing import Any, List, Optional, Sequence, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl -from flet_core.control import OptionalNumber, Control +from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - PaddingValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_slider.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_slider.py index 0c977b6cb..577c159f9 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_slider.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_slider.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py index 0bec11b4a..30059893f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_sliding_segmented_button.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Sequence, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl -from flet_core.control import OptionalNumber, Control +from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, + PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - PaddingValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_switch.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_switch.py index d63157ec8..a64e322d8 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_switch.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_switch.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, LabelPosition, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_textfield.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_textfield.py index 35a694d6e..43e9bb42f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_textfield.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_textfield.py @@ -1,9 +1,10 @@ from enum import Enum from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.autofill_group import AutofillHint from flet_core.border import Border -from flet_core.box import BoxShadow, DecorationImage, BoxShape +from flet_core.box import BoxShadow, BoxShape, DecorationImage from flet_core.control import Control, OptionalNumber from flet_core.gradients import Gradient from flet_core.ref import Ref @@ -11,16 +12,15 @@ from flet_core.textfield import InputFilter, KeyboardType, TextCapitalization, TextField from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BlendMode, BorderRadiusValue, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, TextAlign, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/cupertino_timer_picker.py b/sdk/python/packages/flet-core/src/flet_core/cupertino_timer_picker.py index 3d0ba6b48..bbdd7da2c 100644 --- a/sdk/python/packages/flet-core/src/flet_core/cupertino_timer_picker.py +++ b/sdk/python/packages/flet-core/src/flet_core/cupertino_timer_picker.py @@ -2,17 +2,17 @@ from typing import Any, Optional, Union from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/datatable.py b/sdk/python/packages/flet-core/src/flet_core/datatable.py index e89163653..383c36f36 100644 --- a/sdk/python/packages/flet-core/src/flet_core/datatable.py +++ b/sdk/python/packages/flet-core/src/flet_core/datatable.py @@ -1,6 +1,7 @@ import json from typing import Any, Dict, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.border import Border, BorderSide from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber @@ -12,17 +13,16 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, + ClipBehavior, ControlState, + MainAxisAlignment, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - ClipBehavior, - OptionalEventCallable, - OptionalControlEventCallable, - MainAxisAlignment, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/dismissible.py b/sdk/python/packages/flet-core/src/flet_core/dismissible.py index 9ec698be9..80e679d86 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dismissible.py +++ b/sdk/python/packages/flet-core/src/flet_core/dismissible.py @@ -2,6 +2,7 @@ from typing import Any, Dict, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.control_event import ControlEvent @@ -10,7 +11,6 @@ from flet_core.snack_bar import DismissDirection from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, DurationValue, OffsetValue, OptionalControlEventCallable, 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 0ebca8d8e..f1a87d973 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown.py @@ -2,6 +2,7 @@ from typing import Any, List, Optional, Union from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.control import Control, OptionalNumber from flet_core.form_field_control import ( FormFieldControl, @@ -12,7 +13,6 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, OffsetValue, OptionalControlEventCallable, diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py index 85038e712..3b7986d6d 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py @@ -1,5 +1,6 @@ from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.control import Control, OptionalNumber from flet_core.dropdown import Option @@ -9,7 +10,6 @@ from flet_core.text_style import TextStyle from flet_core.textfield import InputFilter, TextCapitalization from flet_core.types import ( - AnimationValue, OffsetValue, OptionalEventCallable, PaddingValue, diff --git a/sdk/python/packages/flet-core/src/flet_core/elevated_button.py b/sdk/python/packages/flet-core/src/flet_core/elevated_button.py index db7d133ed..7f837d091 100644 --- a/sdk/python/packages/flet-core/src/flet_core/elevated_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/elevated_button.py @@ -2,13 +2,13 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, OffsetValue, OptionalControlEventCallable, diff --git a/sdk/python/packages/flet-core/src/flet_core/expansion_panel.py b/sdk/python/packages/flet-core/src/flet_core/expansion_panel.py index 6de3ca716..714007769 100644 --- a/sdk/python/packages/flet-core/src/flet_core/expansion_panel.py +++ b/sdk/python/packages/flet-core/src/flet_core/expansion_panel.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue 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, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py b/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py index 7ace1a6d8..e79d83253 100644 --- a/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py +++ b/sdk/python/packages/flet-core/src/flet_core/expansion_tile.py @@ -1,25 +1,25 @@ from enum import Enum -from typing import Any, Optional, Union, Sequence +from typing import Any, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue 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.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, CrossAxisAlignment, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, ThemeVisualDensity, VisualDensity, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/flet_app.py b/sdk/python/packages/flet-core/src/flet_core/flet_app.py index 241108fa1..f24778fb1 100644 --- a/sdk/python/packages/flet-core/src/flet_core/flet_app.py +++ b/sdk/python/packages/flet-core/src/flet_core/flet_app.py @@ -1,15 +1,15 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/floating_action_button.py b/sdk/python/packages/flet-core/src/flet_core/floating_action_button.py index 7f72f35a9..3df335373 100644 --- a/sdk/python/packages/flet-core/src/flet_core/floating_action_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/floating_action_button.py @@ -1,20 +1,20 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue 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.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, MouseCursor, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, UrlTarget, - OptionalControlEventCallable, ) 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 2151dded5..0efd6da9d 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 @@ -1,13 +1,13 @@ from enum import Enum from typing import Any, Optional, Union +from flet_core.animation import AnimationValue 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.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, OffsetValue, OptionalControlEventCallable, diff --git a/sdk/python/packages/flet-core/src/flet_core/gesture_detector.py b/sdk/python/packages/flet-core/src/flet_core/gesture_detector.py index e5870c453..1f54b1983 100644 --- a/sdk/python/packages/flet-core/src/flet_core/gesture_detector.py +++ b/sdk/python/packages/flet-core/src/flet_core/gesture_detector.py @@ -2,20 +2,20 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.control_event import ControlEvent from flet_core.event_handler import EventHandler from flet_core.ref import Ref from flet_core.types import ( - AnimationValue, MouseCursor, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/grid_view.py b/sdk/python/packages/flet-core/src/flet_core/grid_view.py index b6d8338ae..d816d8534 100644 --- a/sdk/python/packages/flet-core/src/flet_core/grid_view.py +++ b/sdk/python/packages/flet-core/src/flet_core/grid_view.py @@ -1,19 +1,19 @@ -from typing import Any, List, Optional, Union, Callable, Sequence +from typing import Any, Callable, List, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref -from flet_core.scrollable_control import ScrollableControl, OnScrollEvent +from flet_core.scrollable_control import OnScrollEvent, ScrollableControl from flet_core.types import ( - AnimationValue, + ClipBehavior, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - ClipBehavior, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/icon.py b/sdk/python/packages/flet-core/src/flet_core/icon.py index 1d496b656..8a1e01698 100644 --- a/sdk/python/packages/flet-core/src/flet_core/icon.py +++ b/sdk/python/packages/flet-core/src/flet_core/icon.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/icon_button.py b/sdk/python/packages/flet-core/src/flet_core/icon_button.py index 74306538e..af36874d4 100644 --- a/sdk/python/packages/flet-core/src/flet_core/icon_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/icon_button.py @@ -3,23 +3,23 @@ from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, MouseCursor, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - UrlTarget, ThemeVisualDensity, + UrlTarget, VisualDensity, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/image.py b/sdk/python/packages/flet-core/src/flet_core/image.py index 5a1c05995..3095df8b5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/image.py +++ b/sdk/python/packages/flet-core/src/flet_core/image.py @@ -1,12 +1,12 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.box import FilterQuality from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BlendMode, BorderRadiusValue, ImageFit, diff --git a/sdk/python/packages/flet-core/src/flet_core/interactive_viewer.py b/sdk/python/packages/flet-core/src/flet_core/interactive_viewer.py index 7c2eae3b0..05c284d15 100644 --- a/sdk/python/packages/flet-core/src/flet_core/interactive_viewer.py +++ b/sdk/python/packages/flet-core/src/flet_core/interactive_viewer.py @@ -1,8 +1,9 @@ import json -from typing import Any, Optional, Union, Callable +from typing import Any, Callable, Optional, Union from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.control_event import ControlEvent @@ -10,16 +11,15 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, MarginValue, + Offset, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, - Offset, - OptionalEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/list_tile.py b/sdk/python/packages/flet-core/src/flet_core/list_tile.py index 902f21f35..629e1ad8b 100644 --- a/sdk/python/packages/flet-core/src/flet_core/list_tile.py +++ b/sdk/python/packages/flet-core/src/flet_core/list_tile.py @@ -2,6 +2,7 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber @@ -9,17 +10,16 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, MouseCursor, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - UrlTarget, ThemeVisualDensity, + UrlTarget, VisualDensity, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/list_view.py b/sdk/python/packages/flet-core/src/flet_core/list_view.py index aaccbb88e..11abc8447 100644 --- a/sdk/python/packages/flet-core/src/flet_core/list_view.py +++ b/sdk/python/packages/flet-core/src/flet_core/list_view.py @@ -1,19 +1,19 @@ -from typing import Any, List, Optional, Union, Callable, Sequence +from typing import Any, Callable, List, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref -from flet_core.scrollable_control import ScrollableControl, OnScrollEvent +from flet_core.scrollable_control import OnScrollEvent, ScrollableControl from flet_core.types import ( - AnimationValue, + ClipBehavior, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - ClipBehavior, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/lottie.py b/sdk/python/packages/flet-core/src/flet_core/lottie.py index b49aefe8f..551a3bb37 100644 --- a/sdk/python/packages/flet-core/src/flet_core/lottie.py +++ b/sdk/python/packages/flet-core/src/flet_core/lottie.py @@ -1,18 +1,18 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.box import FilterQuality from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ImageFit, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - ImageFit, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/map/map.py b/sdk/python/packages/flet-core/src/flet_core/map/map.py index b9b485722..a0df6d518 100644 --- a/sdk/python/packages/flet-core/src/flet_core/map/map.py +++ b/sdk/python/packages/flet-core/src/flet_core/map/map.py @@ -1,8 +1,9 @@ import json from enum import Enum -from typing import Any, Optional, Union, List, Tuple +from typing import Any, List, Optional, Tuple, Union from flet_core import AnimationCurve +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.event_handler import EventHandler @@ -12,16 +13,15 @@ from flet_core.tooltip import TooltipValue from flet_core.transform import Offset from flet_core.types import ( - AnimationValue, + ControlEvent, + DurationValue, + Number, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - Number, - DurationValue, - ControlEvent, - OptionalEventCallable, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/map/map_configuration.py b/sdk/python/packages/flet-core/src/flet_core/map/map_configuration.py index 9de102088..0998a1121 100644 --- a/sdk/python/packages/flet-core/src/flet_core/map/map_configuration.py +++ b/sdk/python/packages/flet-core/src/flet_core/map/map_configuration.py @@ -4,9 +4,7 @@ from flet_core.animation import AnimationCurve from flet_core.control import OptionalNumber -from flet_core.types import ( - DurationValue, -) +from flet_core.types import DurationValue @dataclass diff --git a/sdk/python/packages/flet-core/src/flet_core/markdown.py b/sdk/python/packages/flet-core/src/flet_core/markdown.py index f40e9586b..4c20557c5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/markdown.py +++ b/sdk/python/packages/flet-core/src/flet_core/markdown.py @@ -4,6 +4,7 @@ from enum import Enum from typing import Any, Optional, Union, cast +from flet_core.animation import AnimationValue from flet_core.box import BoxDecoration from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber @@ -14,7 +15,6 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, MainAxisAlignment, OffsetValue, OptionalControlEventCallable, diff --git a/sdk/python/packages/flet-core/src/flet_core/matplotlib_chart.py b/sdk/python/packages/flet-core/src/flet_core/matplotlib_chart.py index 28e6bab2c..e629a1374 100644 --- a/sdk/python/packages/flet-core/src/flet_core/matplotlib_chart.py +++ b/sdk/python/packages/flet-core/src/flet_core/matplotlib_chart.py @@ -4,19 +4,19 @@ from typing import Any, Optional, Union from flet_core import alignment +from flet_core.animation import AnimationValue from flet_core.container import Container from flet_core.control import OptionalNumber from flet_core.image import Image from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ImageFit, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - ImageFit, - OptionalControlEventCallable, ) try: diff --git a/sdk/python/packages/flet-core/src/flet_core/menu_item_button.py b/sdk/python/packages/flet-core/src/flet_core/menu_item_button.py index c92e02c20..aa555fdc5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/menu_item_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/menu_item_button.py @@ -2,19 +2,19 @@ from typing import Any, Optional, Union from flet_core.alignment import Axis +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py b/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py index 11b586230..7256d7f10 100644 --- a/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/navigation_bar.py @@ -2,6 +2,7 @@ from typing import Any, Callable, Dict, List, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.border import Border from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl @@ -9,7 +10,6 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ControlState, DurationValue, OffsetValue, diff --git a/sdk/python/packages/flet-core/src/flet_core/navigation_rail.py b/sdk/python/packages/flet-core/src/flet_core/navigation_rail.py index 113353573..df97689e6 100644 --- a/sdk/python/packages/flet-core/src/flet_core/navigation_rail.py +++ b/sdk/python/packages/flet-core/src/flet_core/navigation_rail.py @@ -1,20 +1,20 @@ from enum import Enum from typing import Any, Callable, List, Optional, Union +from flet_core.animation import AnimationValue from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control from flet_core.ref import Ref from flet_core.text_style import TextStyle from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, OptionalNumber, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/outlined_button.py b/sdk/python/packages/flet-core/src/flet_core/outlined_button.py index ff1c8ba63..84d4f5747 100644 --- a/sdk/python/packages/flet-core/src/flet_core/outlined_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/outlined_button.py @@ -2,20 +2,20 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, UrlTarget, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/pagelet.py b/sdk/python/packages/flet-core/src/flet_core/pagelet.py index 3b9232139..8722c815a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/pagelet.py +++ b/sdk/python/packages/flet-core/src/flet_core/pagelet.py @@ -1,6 +1,7 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.app_bar import AppBar from flet_core.bottom_app_bar import BottomAppBar from flet_core.constrained_control import ConstrainedControl @@ -13,13 +14,12 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, FloatingActionButtonLocation, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/placeholder.py b/sdk/python/packages/flet-core/src/flet_core/placeholder.py index f47900d34..76bd5701c 100644 --- a/sdk/python/packages/flet-core/src/flet_core/placeholder.py +++ b/sdk/python/packages/flet-core/src/flet_core/placeholder.py @@ -1,17 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl -from flet_core.control import Control -from flet_core.control import OptionalNumber +from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/plotly_chart.py b/sdk/python/packages/flet-core/src/flet_core/plotly_chart.py index e8b90d4ba..0ee9f3726 100644 --- a/sdk/python/packages/flet-core/src/flet_core/plotly_chart.py +++ b/sdk/python/packages/flet-core/src/flet_core/plotly_chart.py @@ -3,19 +3,19 @@ from typing import Any, Optional, Union from flet_core import alignment +from flet_core.animation import AnimationValue from flet_core.container import Container from flet_core.control import OptionalNumber from flet_core.image import Image from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ImageFit, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - ImageFit, - OptionalControlEventCallable, ) try: diff --git a/sdk/python/packages/flet-core/src/flet_core/popup_menu_button.py b/sdk/python/packages/flet-core/src/flet_core/popup_menu_button.py index a6f1058bc..ee3399278 100644 --- a/sdk/python/packages/flet-core/src/flet_core/popup_menu_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/popup_menu_button.py @@ -2,21 +2,21 @@ from enum import Enum from typing import Any, List, Optional, Union +from flet_core.animation import AnimationValue 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.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, MouseCursor, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/progress_bar.py b/sdk/python/packages/flet-core/src/flet_core/progress_bar.py index d11708a75..dbc7b4d9a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/progress_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/progress_bar.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/progress_ring.py b/sdk/python/packages/flet-core/src/flet_core/progress_ring.py index 83dc0f91e..550f6c4fe 100644 --- a/sdk/python/packages/flet-core/src/flet_core/progress_ring.py +++ b/sdk/python/packages/flet-core/src/flet_core/progress_ring.py @@ -1,17 +1,17 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, StrokeCap, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/radio.py b/sdk/python/packages/flet-core/src/flet_core/radio.py index b218a6757..70c395bd7 100644 --- a/sdk/python/packages/flet-core/src/flet_core/radio.py +++ b/sdk/python/packages/flet-core/src/flet_core/radio.py @@ -1,23 +1,23 @@ from typing import Any, Dict, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, - LabelPosition, ControlState, + LabelPosition, MouseCursor, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, ThemeVisualDensity, VisualDensity, - OptionalControlEventCallable, ) try: diff --git a/sdk/python/packages/flet-core/src/flet_core/range_slider.py b/sdk/python/packages/flet-core/src/flet_core/range_slider.py index 7f6fcb2b5..f61285e57 100644 --- a/sdk/python/packages/flet-core/src/flet_core/range_slider.py +++ b/sdk/python/packages/flet-core/src/flet_core/range_slider.py @@ -1,17 +1,17 @@ from typing import Any, Dict, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ControlState, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/responsive_row.py b/sdk/python/packages/flet-core/src/flet_core/responsive_row.py index bd28b313c..7c33de812 100644 --- a/sdk/python/packages/flet-core/src/flet_core/responsive_row.py +++ b/sdk/python/packages/flet-core/src/flet_core/responsive_row.py @@ -1,18 +1,18 @@ -from typing import Any, Optional, Union, Sequence +from typing import Any, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue 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, CrossAxisAlignment, MainAxisAlignment, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/rive.py b/sdk/python/packages/flet-core/src/flet_core/rive.py index 5fe424ac4..8b54ae8bd 100644 --- a/sdk/python/packages/flet-core/src/flet_core/rive.py +++ b/sdk/python/packages/flet-core/src/flet_core/rive.py @@ -1,18 +1,18 @@ from typing import Any, Optional, Union from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl -from flet_core.control import OptionalNumber, Control +from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ImageFit, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - ImageFit, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/row.py b/sdk/python/packages/flet-core/src/flet_core/row.py index 775ad5b63..7322afae2 100644 --- a/sdk/python/packages/flet-core/src/flet_core/row.py +++ b/sdk/python/packages/flet-core/src/flet_core/row.py @@ -1,22 +1,22 @@ -from typing import Any, List, Optional, Union, Sequence +from typing import Any, List, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control from flet_core.ref import Ref -from flet_core.scrollable_control import ScrollableControl, OnScrollEvent +from flet_core.scrollable_control import OnScrollEvent, ScrollableControl from flet_core.types import ( - AnimationValue, CrossAxisAlignment, MainAxisAlignment, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, OptionalNumber, ResponsiveNumber, RotateValue, ScaleValue, ScrollMode, - OptionalEventCallable, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/safe_area.py b/sdk/python/packages/flet-core/src/flet_core/safe_area.py index 427913bb7..b5cda0c4f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/safe_area.py +++ b/sdk/python/packages/flet-core/src/flet_core/safe_area.py @@ -2,18 +2,18 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/search_bar.py b/sdk/python/packages/flet-core/src/flet_core/search_bar.py index 413bd8306..d8115c2e8 100644 --- a/sdk/python/packages/flet-core/src/flet_core/search_bar.py +++ b/sdk/python/packages/flet-core/src/flet_core/search_bar.py @@ -1,7 +1,8 @@ import time -from typing import Any, Dict, List, Optional, Union, Sequence +from typing import Any, Dict, List, Optional, Sequence, Union from flet_core import BoxConstraints +from flet_core.animation import AnimationValue from flet_core.border import BorderSide from flet_core.buttons import OutlinedBorder from flet_core.constrained_control import ConstrainedControl @@ -11,16 +12,15 @@ from flet_core.textfield import KeyboardType, TextCapitalization from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ControlState, + Number, OffsetValue, + OptionalControlEventCallable, OptionalNumber, + PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, - Number, - PaddingValue, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/segmented_button.py b/sdk/python/packages/flet-core/src/flet_core/segmented_button.py index 4d49af402..8caf7d6f5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/segmented_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/segmented_button.py @@ -1,18 +1,18 @@ import json from typing import Any, List, Optional, Set, Union +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/shader_mask.py b/sdk/python/packages/flet-core/src/flet_core/shader_mask.py index e11180530..73672408f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/shader_mask.py +++ b/sdk/python/packages/flet-core/src/flet_core/shader_mask.py @@ -1,19 +1,19 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.gradients import Gradient from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BlendMode, BorderRadiusValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/slider.py b/sdk/python/packages/flet-core/src/flet_core/slider.py index 241450140..bacf11a26 100644 --- a/sdk/python/packages/flet-core/src/flet_core/slider.py +++ b/sdk/python/packages/flet-core/src/flet_core/slider.py @@ -2,19 +2,19 @@ from typing import Any, Dict, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ControlState, MouseCursor, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/stack.py b/sdk/python/packages/flet-core/src/flet_core/stack.py index a3a4e6a90..d75ca2a99 100644 --- a/sdk/python/packages/flet-core/src/flet_core/stack.py +++ b/sdk/python/packages/flet-core/src/flet_core/stack.py @@ -1,19 +1,19 @@ from enum import Enum -from typing import Any, List, Optional, Union, Sequence +from typing import Any, List, Optional, Sequence, Union from flet_core.adaptive_control import AdaptiveControl from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue 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, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/submenu_button.py b/sdk/python/packages/flet-core/src/flet_core/submenu_button.py index 0c61b14b2..f3892ce21 100644 --- a/sdk/python/packages/flet-core/src/flet_core/submenu_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/submenu_button.py @@ -1,6 +1,7 @@ import time -from typing import Any, Optional, Union, Sequence +from typing import Any, Optional, Sequence, Union +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber @@ -8,13 +9,12 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ClipBehavior, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/switch.py b/sdk/python/packages/flet-core/src/flet_core/switch.py index da4550f1d..4d6b1b7c1 100644 --- a/sdk/python/packages/flet-core/src/flet_core/switch.py +++ b/sdk/python/packages/flet-core/src/flet_core/switch.py @@ -1,21 +1,21 @@ from typing import Any, Dict, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, - LabelPosition, ControlState, + LabelPosition, MouseCursor, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/tabs.py b/sdk/python/packages/flet-core/src/flet_core/tabs.py index f2c0a51fa..af69e818c 100644 --- a/sdk/python/packages/flet-core/src/flet_core/tabs.py +++ b/sdk/python/packages/flet-core/src/flet_core/tabs.py @@ -1,13 +1,13 @@ from typing import Any, Dict, List, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.border import BorderSide 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, BorderRadiusValue, ClipBehavior, ControlState, diff --git a/sdk/python/packages/flet-core/src/flet_core/text.py b/sdk/python/packages/flet-core/src/flet_core/text.py index f1b6a8a6a..ba2ec3a03 100644 --- a/sdk/python/packages/flet-core/src/flet_core/text.py +++ b/sdk/python/packages/flet-core/src/flet_core/text.py @@ -3,21 +3,21 @@ from typing import Any, List, Optional, Union from warnings import warn +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.text_span import TextSpan -from flet_core.text_style import TextStyle, TextThemeStyle, TextOverflow +from flet_core.text_style import TextOverflow, TextStyle, TextThemeStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, FontWeight, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, TextAlign, - OptionalControlEventCallable, ) try: diff --git a/sdk/python/packages/flet-core/src/flet_core/text_button.py b/sdk/python/packages/flet-core/src/flet_core/text_button.py index edbfc4c67..e09672bc6 100644 --- a/sdk/python/packages/flet-core/src/flet_core/text_button.py +++ b/sdk/python/packages/flet-core/src/flet_core/text_button.py @@ -2,19 +2,19 @@ from typing import Any, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.buttons import ButtonStyle from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, UrlTarget, - OptionalControlEventCallable, ) from flet_core.utils import deprecated 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 3d3d2c444..266a934d7 100644 --- a/sdk/python/packages/flet-core/src/flet_core/textfield.py +++ b/sdk/python/packages/flet-core/src/flet_core/textfield.py @@ -4,6 +4,7 @@ from typing import Any, List, Optional, Union from flet_core.adaptive_control import AdaptiveControl +from flet_core.animation import AnimationValue from flet_core.autofill_group import AutofillHint from flet_core.control import Control, OptionalNumber from flet_core.form_field_control import ( @@ -15,7 +16,6 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, BorderRadiusValue, OffsetValue, OptionalControlEventCallable, diff --git a/sdk/python/packages/flet-core/src/flet_core/transparent_pointer.py b/sdk/python/packages/flet-core/src/flet_core/transparent_pointer.py index e01c70a2a..53a24bef0 100644 --- a/sdk/python/packages/flet-core/src/flet_core/transparent_pointer.py +++ b/sdk/python/packages/flet-core/src/flet_core/transparent_pointer.py @@ -1,15 +1,15 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/types.py b/sdk/python/packages/flet-core/src/flet_core/types.py index 24b515680..2ba671533 100644 --- a/sdk/python/packages/flet-core/src/flet_core/types.py +++ b/sdk/python/packages/flet-core/src/flet_core/types.py @@ -3,7 +3,6 @@ from typing import Any, Callable, Dict, Optional, Protocol, Tuple, TypeVar, Union from warnings import warn -from flet_core.animation import Animation from flet_core.border_radius import BorderRadius from flet_core.control_event import ControlEvent from flet_core.event import Event @@ -67,8 +66,6 @@ class UrlTarget(Enum): OffsetValue = Optional[Union[Offset, Tuple[Union[float, int], Union[float, int]]]] -AnimationValue = Optional[Union[bool, int, Animation]] - class FontWeight(Enum): NORMAL = "normal" diff --git a/sdk/python/packages/flet-core/src/flet_core/video.py b/sdk/python/packages/flet-core/src/flet_core/video.py index 59fea8754..ef2dfc497 100644 --- a/sdk/python/packages/flet-core/src/flet_core/video.py +++ b/sdk/python/packages/flet-core/src/flet_core/video.py @@ -3,6 +3,7 @@ from typing import Any, Dict, List, Optional, Union, cast from flet_core.alignment import Alignment +from flet_core.animation import AnimationValue from flet_core.box import FilterQuality from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber @@ -10,16 +11,15 @@ from flet_core.text_style import TextStyle from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, ImageFit, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, TextAlign, - OptionalEventCallable, - OptionalControlEventCallable, ) from flet_core.utils import deprecated diff --git a/sdk/python/packages/flet-core/src/flet_core/webview.py b/sdk/python/packages/flet-core/src/flet_core/webview.py index 870d8c8a5..65c98a81e 100644 --- a/sdk/python/packages/flet-core/src/flet_core/webview.py +++ b/sdk/python/packages/flet-core/src/flet_core/webview.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) diff --git a/sdk/python/packages/flet-core/src/flet_core/window_drag_area.py b/sdk/python/packages/flet-core/src/flet_core/window_drag_area.py index d4ecf4529..a6e2aff9a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/window_drag_area.py +++ b/sdk/python/packages/flet-core/src/flet_core/window_drag_area.py @@ -1,16 +1,16 @@ from typing import Any, Optional, Union +from flet_core.animation import AnimationValue from flet_core.constrained_control import ConstrainedControl from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, )