diff --git a/ci/update-flet-wheel-deps.py b/ci/update-flet-wheel-deps.py index b17f36e88..5f7a84467 100644 --- a/ci/update-flet-wheel-deps.py +++ b/ci/update-flet-wheel-deps.py @@ -1,7 +1,5 @@ import os import re -import shutil -import subprocess import sys import tempfile from pathlib import Path 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/create_control.dart b/packages/flet/lib/src/controls/create_control.dart index 9284b58b1..685519c1d 100644 --- a/packages/flet/lib/src/controls/create_control.dart +++ b/packages/flet/lib/src/controls/create_control.dart @@ -59,6 +59,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'; @@ -835,6 +836,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, 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/dropdown_menu.dart b/packages/flet/lib/src/controls/dropdown_menu.dart new file mode 100644 index 000000000..778dcd4e9 --- /dev/null +++ b/packages/flet/lib/src/controls/dropdown_menu.dart @@ -0,0 +1,235 @@ +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/form_field.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, + inputDecorationTheme: + buildInputDecorationTheme(context, widget.control, _focused), + 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/packages/flet/lib/src/controls/navigation_bar.dart b/packages/flet/lib/src/controls/navigation_bar.dart index 5f365ff96..7138e076a 100644 --- a/packages/flet/lib/src/controls/navigation_bar.dart +++ b/packages/flet/lib/src/controls/navigation_bar.dart @@ -68,6 +68,7 @@ class _NavigationBarControlState extends State if (_selectedIndex != selectedIndex) { _selectedIndex = selectedIndex; } + var navBar = withControls( widget.children .where((c) => c.isVisible && c.name == null) diff --git a/packages/flet/lib/src/controls/scrollable_control.dart b/packages/flet/lib/src/controls/scrollable_control.dart index 5596c26a5..7fb7623fe 100644 --- a/packages/flet/lib/src/controls/scrollable_control.dart +++ b/packages/flet/lib/src/controls/scrollable_control.dart @@ -9,6 +9,7 @@ import '../models/control.dart'; import '../utils/animations.dart'; import '../utils/numbers.dart'; import '../utils/others.dart'; +import '../utils/time.dart'; import 'flet_store_mixin.dart'; class ScrollableControl extends StatefulWidget { @@ -83,7 +84,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((_) { @@ -92,10 +94,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); } } }); @@ -105,12 +104,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, ); } @@ -119,12 +118,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 f9091ee80..fe1657dcb 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'; @@ -76,28 +77,29 @@ class _SnackBarControlState extends State { margin = (width != null && margin != null) ? null : margin; 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 0db47574e..6174e5161 100644 --- a/packages/flet/lib/src/controls/tabs.dart +++ b/packages/flet/lib/src/controls/tabs.dart @@ -16,6 +16,7 @@ import '../utils/material_state.dart'; import '../utils/mouse.dart'; import '../utils/others.dart'; import '../utils/text.dart'; +import '../utils/time.dart'; import 'create_control.dart'; class TabsControl extends StatefulWidget { @@ -93,9 +94,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 new file mode 100644 index 000000000..e69de29bb diff --git a/packages/flet/lib/src/utils/buttons.dart b/packages/flet/lib/src/utils/buttons.dart index f35f27722..9b2a59e00 100644 --- a/packages/flet/lib/src/utils/buttons.dart +++ b/packages/flet/lib/src/utils/buttons.dart @@ -13,17 +13,18 @@ import 'mouse.dart'; import 'numbers.dart'; import 'text.dart'; import 'theme.dart'; +import 'time.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; @@ -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/form_field.dart b/packages/flet/lib/src/utils/form_field.dart index 2db9645ea..84a1a5880 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 } @@ -50,9 +51,7 @@ TextInputType? parseTextInputType(String? value, [TextInputType? defValue]) { } } -InputDecoration buildInputDecoration( - BuildContext context, - Control control, +InputDecoration buildInputDecoration(BuildContext context, Control control, {Control? prefix, Control? prefixIcon, Control? suffix, @@ -68,8 +67,8 @@ InputDecoration buildInputDecoration( control.attrString("border"), FormFieldInputBorder.outline, )!; + var theme = Theme.of(context); var iconStr = parseIcon(control.attrString("icon")); - var prefixIconStr = parseIcon(control.attrString("prefixIcon")); var prefixText = control.attrString("prefixText"); var suffixIconStr = parseIcon(control.attrString("suffixIcon")); @@ -106,7 +105,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)); } } @@ -122,61 +121,157 @@ InputDecoration buildInputDecoration( : BorderSide( color: focusedBorderColor ?? borderColor ?? - Theme.of(context).colorScheme.primary, + theme.colorScheme.primary, width: focusedBorderWidth ?? borderWidth ?? 2.0)); } return InputDecoration( - enabled: !disabled, - contentPadding: parseEdgeInsets(control, "contentPadding"), - isDense: control.attrBool("dense"), - label: label != "" ? Text(label) : null, - labelStyle: parseTextStyle(Theme.of(context), control, "labelStyle"), - border: border, - enabledBorder: border, - focusedBorder: focusedBorder, - hoverColor: hoverColor, - icon: icon != null - ? createControl(control, icon.id, control.isDisabled, - parentAdaptive: adaptive) - : iconStr !=null? Icon(iconStr): null, - filled: control.attrBool("filled", false)!, - fillColor: fillColor ?? (focused ? focusedBgcolor ?? bgcolor : bgcolor), - hintText: control.attrString("hintText"), - hintStyle: parseTextStyle(Theme.of(context), control, "hintStyle"), - helperText: control.attrString("helperText"), - helperStyle: parseTextStyle(Theme.of(context), control, "helperStyle"), - counterText: control.attrString("counterText"), - counterStyle: parseTextStyle(Theme.of(context), control, "counterStyle"), - counter: counter != null - ? createControl(control, counter.id, control.isDisabled, - parentAdaptive: adaptive) - : null, - errorText: control.attrString("errorText") != "" - ? control.attrString("errorText") - : null, - errorStyle: parseTextStyle(Theme.of(context), control, "errorStyle"), - prefixIcon: prefixIcon != null - ? createControl(control, prefixIcon.id, control.isDisabled, - parentAdaptive: adaptive) - : prefixIconStr !=null? Icon(prefixIconStr): null, - prefixText: prefixText, - prefixStyle: parseTextStyle(Theme.of(context), 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 - ? createControl(control, suffixIcon.id, control.isDisabled, - parentAdaptive: adaptive) - : suffixIconStr !=null? Icon(suffixIconStr): customSuffix, - suffixText: suffixText, - suffixStyle: parseTextStyle(Theme.of(context), 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 + ? createControl(control, icon.id, control.isDisabled, + parentAdaptive: adaptive) + : iconStr != null + ? Icon(iconStr) + : 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") != "" + ? control.attrString("errorText") + : null, + errorStyle: parseTextStyle(theme, control, "errorStyle"), + prefixIcon: prefixIcon != null + ? createControl(control, prefixIcon.id, control.isDisabled, + parentAdaptive: adaptive) + : prefixIconStr != null + ? Icon(prefixIconStr) + : 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 + ? createControl(control, suffixIcon.id, control.isDisabled, + parentAdaptive: adaptive) + : suffixIconStr != null + ? Icon(suffixIconStr) + : customSuffix, + suffixText: suffixText, + suffixStyle: parseTextStyle(theme, control, "suffixStyle"), + ); +} + +InputDecorationTheme buildInputDecorationTheme( + BuildContext context, Control control, bool focused) { + 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, "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), + 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) { diff --git a/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/macos_utils.py b/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/macos_utils.py index c02d8f5fd..56d0ec99f 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/macos_utils.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/macos_utils.py @@ -5,9 +5,10 @@ import tarfile from pathlib import Path -from flet_core.utils import safe_tar_extractall from PyInstaller.building.icon import normalize_icon_type +from flet_core.utils import safe_tar_extractall + def unpack_app_bundle(tar_path): bin_dir = str(Path(tar_path).parent) diff --git a/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/win_utils.py b/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/win_utils.py index bbc8e0954..66ac66101 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/win_utils.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/win_utils.py @@ -3,11 +3,10 @@ import uuid from pathlib import Path -from packaging import version import pefile -from PyInstaller.utils.win32 import versioninfo -from PyInstaller.building.icon import normalize_icon_type +from packaging import version from PyInstaller.compat import win32api +from PyInstaller.utils.win32 import versioninfo from PyInstaller.utils.win32.icon import IconFile, normalize_icon_type diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py index 61c0103fb..6f395a387 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py @@ -1,6 +1,5 @@ import argparse import glob -import json import os import platform import re @@ -14,14 +13,14 @@ import toml import yaml from flet.version import update_version -from flet_core.utils import copy_tree, is_windows, slugify -from flet_core.utils.platform_utils import get_bool_env_var +from flet_cli.commands.base import BaseCommand +from flet_cli.utils.merge import merge_dict from packaging import version from rich.console import Console, Style from rich.table import Column, Table -from flet_cli.commands.base import BaseCommand -from flet_cli.utils.merge import merge_dict +from flet_core.utils import copy_tree, is_windows, slugify +from flet_core.utils.platform_utils import get_bool_env_var if is_windows(): from ctypes import windll diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/create.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/create.py index 1daf0b907..aff5318f2 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/commands/create.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/create.py @@ -4,10 +4,11 @@ import flet.version from flet_cli.commands.base import BaseCommand -from flet_core.utils import slugify from packaging import version from rich import print +from flet_core.utils import slugify + class Command(BaseCommand): """ diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py index c0235579f..92a9fc088 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py @@ -4,11 +4,11 @@ import sys from pathlib import Path -from flet_core.utils import is_macos, is_windows - import flet_cli.__pyinstaller.config as hook_config from flet_cli.commands.base import BaseCommand +from flet_core.utils import is_macos, is_windows + class Command(BaseCommand): """ @@ -173,7 +173,6 @@ def handle(self, options: argparse.Namespace) -> None: try: import PyInstaller.__main__ - from flet_cli.__pyinstaller.utils import copy_flet_bin pyi_args = [options.script, "--noconfirm"] diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/run.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/run.py index ef0d544d3..3bbacd74f 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/commands/run.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/run.py @@ -13,11 +13,12 @@ import qrcode from flet.utils import get_free_tcp_port, get_local_ip, open_in_browser from flet_cli.commands.base import BaseCommand -from flet_core.utils import is_windows, random_string from flet_desktop import close_flet_view, open_flet_view from watchdog.events import FileSystemEventHandler from watchdog.observers import Observer +from flet_core.utils import is_windows, random_string + class Command(BaseCommand): """ 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 82ab2376a..0ef41fc3b 100644 --- a/sdk/python/packages/flet-core/src/flet_core/__init__.py +++ b/sdk/python/packages/flet-core/src/flet_core/__init__.py @@ -23,9 +23,9 @@ from flet_core.app_bar import AppBar from flet_core.audio import ( Audio, - AudioState, AudioDurationChangeEvent, AudioPositionChangeEvent, + AudioState, AudioStateChangeEvent, ) from flet_core.audio_recorder import ( @@ -36,8 +36,8 @@ ) from flet_core.auto_complete import ( AutoComplete, - AutoCompleteSuggestion, AutoCompleteSelectEvent, + AutoCompleteSuggestion, ) from flet_core.autofill_group import ( AutofillGroup, @@ -52,14 +52,14 @@ from flet_core.bottom_app_bar import BottomAppBar from flet_core.bottom_sheet import BottomSheet from flet_core.box import ( - BoxShadow, - ShadowBlurStyle, + BoxConstraints, BoxDecoration, + BoxShadow, BoxShape, - BoxConstraints, + ColorFilter, DecorationImage, FilterQuality, - ColorFilter, + ShadowBlurStyle, ) from flet_core.buttons import ( BeveledRectangleBorder, @@ -137,8 +137,8 @@ from flet_core.date_picker import ( DatePicker, DatePickerEntryMode, - DatePickerMode, DatePickerEntryModeChangeEvent, + DatePickerMode, ) from flet_core.dismissible import ( Dismissible, @@ -149,6 +149,7 @@ 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 @@ -167,12 +168,12 @@ from flet_core.form_field_control import InputBorder from flet_core.geolocator import ( Geolocator, - GeolocatorPositionAccuracy, - GeolocatorPermissionStatus, - GeolocatorPosition, GeolocatorActivityType, GeolocatorAndroidSettings, GeolocatorAppleSettings, + GeolocatorPermissionStatus, + GeolocatorPosition, + GeolocatorPositionAccuracy, GeolocatorPositionChangeEvent, GeolocatorSettings, GeolocatorWebSettings, @@ -205,9 +206,9 @@ from flet_core.image import Image from flet_core.interactive_viewer import ( InteractiveViewer, + InteractiveViewerInteractionEndEvent, InteractiveViewerInteractionStartEvent, InteractiveViewerInteractionUpdateEvent, - InteractiveViewerInteractionEndEvent, ) from flet_core.list_tile import ListTile, ListTileStyle, ListTileTitleAlignment from flet_core.list_view import ListView @@ -215,19 +216,19 @@ from flet_core.margin import Margin from flet_core.markdown import ( Markdown, + MarkdownCodeTheme, MarkdownExtensionSet, - MarkdownSelectionChangeEvent, MarkdownSelectionChangeCause, + MarkdownSelectionChangeEvent, MarkdownStyleSheet, - MarkdownCodeTheme, ) from flet_core.menu_bar import MenuBar, MenuStyle from flet_core.menu_item_button import MenuItemButton from flet_core.navigation_bar import ( NavigationBar, NavigationBarDestination, - NavigationDestination, NavigationBarLabelBehavior, + NavigationDestination, ) from flet_core.navigation_drawer import ( NavigationDrawer, @@ -243,6 +244,7 @@ from flet_core.padding import Padding from flet_core.page import ( AppLifecycleStateChangeEvent, + BrowserContextMenu, KeyboardEvent, Locale, LocaleConfiguration, @@ -252,12 +254,11 @@ PageMediaData, RouteChangeEvent, ViewPopEvent, - context, - WindowEvent, - WindowResizeEvent, Window, + WindowEvent, WindowEventType, - BrowserContextMenu, + WindowResizeEvent, + context, ) from flet_core.pagelet import Pagelet from flet_core.painting import ( @@ -270,8 +271,8 @@ ) from flet_core.permission_handler import ( PermissionHandler, - PermissionType, PermissionStatus, + PermissionType, ) from flet_core.placeholder import Placeholder from flet_core.popup_menu_button import ( @@ -306,16 +307,16 @@ from flet_core.switch import Switch from flet_core.tabs import Tab, Tabs from flet_core.template_route import TemplateRoute -from flet_core.text import Text, TextSelection, TextAffinity +from flet_core.text import Text, TextAffinity, TextSelection from flet_core.text_button import TextButton from flet_core.text_span import TextSpan from flet_core.text_style import ( + TextBaseline, TextDecoration, TextDecorationStyle, - TextStyle, TextOverflow, + TextStyle, TextThemeStyle, - TextBaseline, ) from flet_core.textfield import ( InputFilter, @@ -330,12 +331,14 @@ BadgeTheme, BannerTheme, BottomAppBarTheme, - BottomSheetTheme, BottomNavigationBarTheme, + BottomSheetTheme, + ButtonTheme, CardTheme, CheckboxTheme, ChipTheme, ColorScheme, + DataTableTheme, DatePickerTheme, DialogTheme, DividerTheme, @@ -364,8 +367,6 @@ Theme, TimePickerTheme, TooltipTheme, - DataTableTheme, - ButtonTheme, ) from flet_core.time_picker import ( TimePicker, @@ -380,35 +381,35 @@ BlendMode, Brightness, ClipBehavior, - OptionalEventCallable, + ControlState, CrossAxisAlignment, + Duration, FloatingActionButtonLocation, FontWeight, ImageFit, ImageRepeat, LabelPosition, MainAxisAlignment, - ControlState, MaterialState, MouseCursor, NotchShape, Number, + OptionalEventCallable, OptionalNumber, Orientation, PaddingValue, PagePlatform, ScrollMode, + StrokeCap, + StrokeJoin, SupportsStr, TabAlignment, TextAlign, ThemeMode, ThemeVisualDensity, - VisualDensity, UrlTarget, VerticalAlignment, - StrokeCap, - StrokeJoin, - Duration, + VisualDensity, ) from flet_core.user_control import UserControl from flet_core.vertical_divider import VerticalDivider 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 cf42c1048..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,18 +1,18 @@ 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, - OptionalControlEventCallable, ) try: @@ -82,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, @@ -160,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") @@ -176,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 d11bdb2f4..659f8526c 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 @@ -47,7 +49,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" @@ -55,9 +57,12 @@ 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) + + +AnimationValue = Optional[Union[bool, int, Animation]] 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 b9d1c1dd3..592800abb 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): 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/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/buttons.py b/sdk/python/packages/flet-core/src/flet_core/buttons.py index b536aacd6..273f199c5 100644 --- a/sdk/python/packages/flet-core/src/flet_core/buttons.py +++ b/sdk/python/packages/flet-core/src/flet_core/buttons.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Dict, Optional, Union from flet_core.alignment import Alignment @@ -7,6 +7,7 @@ from flet_core.types import ( BorderRadiusValue, ControlState, + DurationValue, MouseCursor, Number, PaddingValue, @@ -65,7 +66,7 @@ class ButtonStyle: elevation: Union[ None, float, int, Dict[Union[str, ControlState], Union[float, int]] ] = None - animation_duration: Optional[int] = None + animation_duration: DurationValue = None padding: Union[PaddingValue, Dict[Union[str, ControlState], PaddingValue]] = None side: Union[None, BorderSide, Dict[Union[str, ControlState], BorderSide]] = None shape: Union[ 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 7b617f10f..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,13 +4,14 @@ 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 ( + BoxDecoration, BoxShadow, BoxShape, ColorFilter, - BoxDecoration, DecorationImage, ) from flet_core.constrained_control import ConstrainedControl @@ -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, @@ -30,14 +30,14 @@ ImageRepeat, MarginValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, ThemeMode, UrlTarget, - OptionalEventCallable, - OptionalControlEventCallable, ) @@ -215,12 +215,12 @@ def _get_control_name(self): def before_update(self): super().before_update() assert ( - self.__blend_mode is None - or self.__gradient is not None - or self.bgcolor is not None + self.__blend_mode is None + or self.__gradient is not None + or self.bgcolor is not None ), "blend_mode applies to bgcolor or gradient, but no bgcolor or gradient was provided" assert ( - self.__shape != BoxShape.CIRCLE or self.__border_radius is None + self.__shape != BoxShape.CIRCLE or self.__border_radius is None ), "border_radius is not supported with shape=BoxShape.CIRCLE" self._set_attr_json("borderRadius", self.__border_radius) self._set_attr_json("border", self.__border) 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 07b52a329..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,13 +11,13 @@ from flet_core.snack_bar import DismissDirection from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + DurationValue, OffsetValue, + OptionalControlEventCallable, + OptionalEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalEventCallable, - OptionalControlEventCallable, ) from flet_core.utils import deprecated @@ -42,8 +43,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: OptionalEventCallable["DismissibleUpdateEvent"] = None, on_dismiss: OptionalEventCallable["DismissibleDismissEvent"] = 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/dropdown.py b/sdk/python/packages/flet-core/src/flet_core/dropdown.py index f00c26d10..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,23 +2,27 @@ 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, InputBorder +from flet_core.form_field_control import ( + FormFieldControl, + IconValueOrControl, + InputBorder, +) 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, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) from flet_core.utils import deprecated -from flet_core.form_field_control import IconValueOrControl + class Option(Control): def __init__( @@ -202,17 +206,13 @@ def __init__( helper_style: Optional[TextStyle] = None, counter: Optional[Control] = None, counter_text: Optional[str] = None, - counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, - error_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, prefix_icon: Optional[IconValueOrControl] = None, prefix_text: Optional[str] = None, - prefix_style: Optional[TextStyle] = None, suffix: Optional[Control] = None, suffix_icon: Optional[IconValueOrControl] = None, suffix_text: Optional[str] = None, - suffix_style: Optional[TextStyle] = None, # # ConstrainedControl # @@ -242,32 +242,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, @@ -293,17 +267,36 @@ def __init__( helper_style=helper_style, counter=counter, counter_text=counter_text, - counter_style=counter_style, error_text=error_text, - error_style=error_style, prefix=prefix, prefix_icon=prefix_icon, prefix_text=prefix_text, - prefix_style=prefix_style, suffix=suffix, suffix_icon=suffix_icon, suffix_text=suffix_text, - suffix_style=suffix_style, + 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 new file mode 100644 index 000000000..3b7986d6d --- /dev/null +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown_menu.py @@ -0,0 +1,438 @@ +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 +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 ( + OffsetValue, + OptionalEventCallable, + PaddingValue, + ResponsiveNumber, + RotateValue, + ScaleValue, +) + + +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): + """ + A dropdown menu control that allows users to select a single option from a list of options. + + ----- + + 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, + error_text: Optional[str] = None, + prefix: Optional[Control] = None, + prefix_icon: Optional[str] = None, + suffix: Optional[Control] = None, + suffix_icon: Optional[str] = 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, + label_style=label_style, + border=border, + color=color, + 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, + 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, + error_text=error_text, + prefix=prefix, + prefix_icon=prefix_icon, + suffix=suffix, + suffix_icon=suffix_icon, + 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/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 263926c45..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,22 +1,21 @@ 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.icon import Icon 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, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, VerticalAlignment, - OptionalControlEventCallable, ) try: @@ -26,6 +25,7 @@ IconValueOrControl = Union[str, Control] + class InputBorder(Enum): NONE = "none" OUTLINE = "outline" @@ -73,7 +73,6 @@ def __init__( suffix_icon: Optional[IconValueOrControl] = None, suffix_text: Optional[str] = None, suffix_style: Optional[TextStyle] = None, - rtl: Optional[bool] = None, # # ConstrainedControl # @@ -104,6 +103,7 @@ def __init__( visible: Optional[bool] = None, disabled: Optional[bool] = None, data: Any = None, + rtl: Optional[bool] = None, ): ConstrainedControl.__init__( self, @@ -517,7 +517,7 @@ def suffix(self) -> Optional[Control]: @suffix.setter def suffix(self, value: Optional[Control]): self.__suffix = value - + # suffix_icon @property def suffix_icon(self) -> Optional[IconValueOrControl]: 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 5706f7678..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,21 +1,21 @@ 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, ImageRepeat, OffsetValue, + OptionalControlEventCallable, ResponsiveNumber, RotateValue, ScaleValue, - OptionalControlEventCallable, ) try: @@ -91,7 +91,7 @@ def __init__( animate_rotation: AnimationValue = None, animate_scale: AnimationValue = None, animate_offset: AnimationValue = None, - on_animation_end: OptionalControlEventCallable = None, + on_animation_end: OptionalControlEventCallable = None, tooltip: TooltipValue = None, visible: Optional[bool] = None, disabled: Optional[bool] = None, 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/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/map/simple_attribution.py b/sdk/python/packages/flet-core/src/flet_core/map/simple_attribution.py index c211c1e61..2dbd5a002 100644 --- a/sdk/python/packages/flet-core/src/flet_core/map/simple_attribution.py +++ b/sdk/python/packages/flet-core/src/flet_core/map/simple_attribution.py @@ -20,7 +20,7 @@ def __init__( text: str, alignment: Optional[Alignment] = None, bgcolor: Optional[str] = None, - on_click: OptionalControlEventCallable = None, + on_click: OptionalControlEventCallable = None, # # MapLayer # 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 376273edc..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,14 +10,14 @@ from flet_core.ref import Ref from flet_core.tooltip import TooltipValue from flet_core.types import ( - AnimationValue, + ControlState, + DurationValue, OffsetValue, + OptionalControlEventCallable, OptionalNumber, ResponsiveNumber, RotateValue, ScaleValue, - ControlState, - OptionalControlEventCallable, ) from flet_core.utils import deprecated @@ -211,7 +212,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: OptionalControlEventCallable = None, # @@ -297,6 +298,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 @@ -403,12 +405,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/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/page.py b/sdk/python/packages/flet-core/src/flet_core/page.py index 79a3609d5..25adaa39a 100644 --- a/sdk/python/packages/flet-core/src/flet_core/page.py +++ b/sdk/python/packages/flet-core/src/flet_core/page.py @@ -26,13 +26,6 @@ ) from urllib.parse import urlparse -from flet_core.box import BoxDecoration - -try: - from typing import ParamSpec -except ImportError: - from typing_extensions import ParamSpec - import flet_core from flet_core.adaptive_control import AdaptiveControl from flet_core.alert_dialog import AlertDialog @@ -42,6 +35,7 @@ from flet_core.banner import Banner from flet_core.bottom_app_bar import BottomAppBar from flet_core.bottom_sheet import BottomSheet +from flet_core.box import BoxDecoration from flet_core.client_storage import ClientStorage from flet_core.connection import Connection from flet_core.control import Control @@ -68,6 +62,7 @@ AppLifecycleState, Brightness, CrossAxisAlignment, + DurationValue, FloatingActionButtonLocation, MainAxisAlignment, OffsetValue, @@ -84,6 +79,12 @@ from flet_core.utils import classproperty, deprecated, is_pyodide from flet_core.view import View +try: + from typing import ParamSpec +except ImportError: + from typing_extensions import ParamSpec + + logger = logging.getLogger(flet_core.__name__) _session_page = ContextVar("flet_session_page", default=None) @@ -1291,7 +1292,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/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/scrollable_control.py b/sdk/python/packages/flet-core/src/flet_core/scrollable_control.py index eaa8ccffa..fb1d6c89e 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, OptionalEventCallable +from flet_core.types import DurationValue, OptionalEventCallable, ScrollMode 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/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/snack_bar.py b/sdk/python/packages/flet-core/src/flet_core/snack_bar.py index e7317d0da..c5559e22a 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 @@ -5,10 +5,11 @@ from flet_core.control import Control, OptionalNumber from flet_core.ref import Ref from flet_core.types import ( - MarginValue, - PaddingValue, ClipBehavior, + DurationValue, + MarginValue, OptionalControlEventCallable, + PaddingValue, ) @@ -76,7 +77,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, @@ -133,6 +134,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) self._set_attr_json("margin", self.__margin) # open @@ -200,12 +202,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/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 fa1901dbe..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,24 +1,25 @@ 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, + DurationValue, MouseCursor, OffsetValue, + OptionalControlEventCallable, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, TabAlignment, - OptionalControlEventCallable, ) @@ -148,7 +149,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, @@ -271,6 +272,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) self._set_attr_json("labelPadding", self.__label_padding) self._set_attr_json("labelTextStyle", self.__label_text_style) self._set_attr_json( @@ -357,12 +359,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/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 3e57c7aa2..266a934d7 100644 --- a/sdk/python/packages/flet-core/src/flet_core/textfield.py +++ b/sdk/python/packages/flet-core/src/flet_core/textfield.py @@ -1,29 +1,32 @@ import dataclasses import time from enum import Enum -from typing import Any, Optional, Union, List +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 FormFieldControl, InputBorder +from flet_core.form_field_control import ( + FormFieldControl, + IconValueOrControl, + InputBorder, +) 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, PaddingValue, ResponsiveNumber, RotateValue, ScaleValue, TextAlign, VerticalAlignment, - OptionalControlEventCallable, ) from flet_core.utils import deprecated -from flet_core.form_field_control import IconValueOrControl try: from typing import Literal @@ -163,17 +166,13 @@ def __init__( helper_style: Optional[TextStyle] = None, counter: Optional[Control] = None, counter_text: Optional[str] = None, - counter_style: Optional[TextStyle] = None, error_text: Optional[str] = None, - error_style: Optional[TextStyle] = None, prefix: Optional[Control] = None, prefix_icon: Optional[IconValueOrControl] = None, prefix_text: Optional[str] = None, - prefix_style: Optional[TextStyle] = None, suffix: Optional[Control] = None, suffix_icon: Optional[IconValueOrControl] = None, suffix_text: Optional[str] = None, - suffix_style: Optional[TextStyle] = None, # # ConstrainedControl and AdaptiveControl # @@ -205,33 +204,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, @@ -259,17 +231,37 @@ def __init__( helper_style=helper_style, counter=counter, counter_text=counter_text, - counter_style=counter_style, error_text=error_text, - error_style=error_style, prefix=prefix, prefix_icon=prefix_icon, prefix_text=prefix_text, - prefix_style=prefix_style, suffix=suffix, suffix_icon=suffix_icon, suffix_text=suffix_text, - suffix_style=suffix_style, + 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) 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 268119a07..65be8b146 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,16 +2,17 @@ from enum import Enum from typing import Any, Optional, Union -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.tooltip import TooltipValue from flet_core.types import ( - Orientation, - ResponsiveNumber, OptionalControlEventCallable, OptionalEventCallable, + OptionalNumber, + Orientation, + ResponsiveNumber, ) 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 8fc7e017f..fd46d581f 100644 --- a/sdk/python/packages/flet-core/src/flet_core/tooltip.py +++ b/sdk/python/packages/flet-core/src/flet_core/tooltip.py @@ -1,18 +1,18 @@ from dataclasses import dataclass -from typing import Optional, List, Union +from typing import List, Optional, Union from flet_core.border import Border -from flet_core.box import BoxShape, DecorationImage, BoxShadow +from flet_core.box import BoxShadow, BoxShape, DecorationImage from flet_core.gradients import Gradient from flet_core.text_style import TextStyle from flet_core.types import ( + BlendMode, BorderRadiusValue, + DurationValue, MarginValue, + OptionalNumber, PaddingValue, TextAlign, - DurationValue, - OptionalNumber, - BlendMode, ) 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 353314015..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,21 +66,6 @@ class UrlTarget(Enum): OffsetValue = Optional[Union[Offset, Tuple[Union[float, int], Union[float, int]]]] -AnimationValue = Optional[Union[bool, int, Animation]] - - -@dataclass -class Duration: - microseconds: int = 0 - milliseconds: int = 0 - seconds: int = 0 - minutes: int = 0 - hours: int = 0 - days: int = 0 - - -DurationValue = Union[int, Duration, None] - class FontWeight(Enum): NORMAL = "normal" @@ -404,6 +388,18 @@ class VisualDensity(Enum): ADAPTIVE_PLATFORM_DENSITY = "adaptivePlatformDensity" +@dataclass +class Duration: + microseconds: int = 0 + milliseconds: int = 0 + seconds: int = 0 + minutes: int = 0 + hours: int = 0 + days: int = 0 + + +DurationValue = Union[int, Duration, None] + # Events ControlEventType = TypeVar("ControlEventType", bound=ControlEvent) EventType = TypeVar("EventType", bound=Event) 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, ) diff --git a/sdk/python/packages/flet-embed/src/flet/map/__init__.py b/sdk/python/packages/flet-embed/src/flet/map/__init__.py index d491c756a..8b1378917 100644 --- a/sdk/python/packages/flet-embed/src/flet/map/__init__.py +++ b/sdk/python/packages/flet-embed/src/flet/map/__init__.py @@ -1 +1 @@ -from flet_core.map import * + diff --git a/sdk/python/packages/flet-web/src/flet_web/fastapi/app.py b/sdk/python/packages/flet-web/src/flet_web/fastapi/app.py index fb3a961df..90396e9d5 100644 --- a/sdk/python/packages/flet-web/src/flet_web/fastapi/app.py +++ b/sdk/python/packages/flet-web/src/flet_web/fastapi/app.py @@ -3,8 +3,6 @@ from typing import Awaitable, Callable, Optional, Union from fastapi import Request, WebSocket -from flet_core.page import Page -from flet_core.types import WebRenderer from flet_web.fastapi.flet_app import ( DEFAULT_FLET_OAUTH_STATE_TIMEOUT, DEFAULT_FLET_SESSION_TIMEOUT, @@ -15,6 +13,9 @@ from flet_web.fastapi.flet_static_files import FletStaticFiles from flet_web.fastapi.flet_upload import FletUpload +from flet_core.page import Page +from flet_core.types import WebRenderer + def app( session_handler: Union[Callable[[Page], Awaitable], Callable[[Page], None]], diff --git a/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py b/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py index bd1b6c6ac..bf60a9424 100644 --- a/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py +++ b/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_app.py @@ -9,6 +9,10 @@ import flet_web.fastapi as flet_fastapi from fastapi import WebSocket, WebSocketDisconnect +from flet_web.fastapi.flet_app_manager import app_manager +from flet_web.fastapi.oauth_state import OAuthState +from flet_web.uploads import build_upload_url + from flet_core.event import Event from flet_core.local_connection import LocalConnection from flet_core.page import Page, PageDisconnectedException @@ -21,11 +25,7 @@ PageCommandsBatchResponsePayload, RegisterWebClientRequestPayload, ) -from flet_core.pubsub import PubSubHub from flet_core.utils import random_string, sha1 -from flet_web.fastapi.flet_app_manager import app_manager -from flet_web.fastapi.oauth_state import OAuthState -from flet_web.uploads import build_upload_url logger = logging.getLogger(flet_fastapi.__name__) diff --git a/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_static_files.py b/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_static_files.py index eebef4a3e..1034348e1 100644 --- a/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_static_files.py +++ b/sdk/python/packages/flet-web/src/flet_web/fastapi/flet_static_files.py @@ -7,12 +7,13 @@ import flet_web.fastapi as flet_fastapi from fastapi.staticfiles import StaticFiles -from flet_core.types import WebRenderer -from flet_core.utils import Once, get_bool_env_var from flet_web import get_package_web_dir, patch_index_html, patch_manifest_json from flet_web.fastapi.flet_app_manager import app_manager from starlette.types import Receive, Scope, Send +from flet_core.types import WebRenderer +from flet_core.utils import Once, get_bool_env_var + logger = logging.getLogger(flet_fastapi.__name__) diff --git a/sdk/python/packages/flet-web/src/flet_web/fastapi/serve_fastapi_web_app.py b/sdk/python/packages/flet-web/src/flet_web/fastapi/serve_fastapi_web_app.py index bc9420a82..a96e605f2 100644 --- a/sdk/python/packages/flet-web/src/flet_web/fastapi/serve_fastapi_web_app.py +++ b/sdk/python/packages/flet-web/src/flet_web/fastapi/serve_fastapi_web_app.py @@ -5,6 +5,7 @@ import flet_web.fastapi import flet_web.fastapi as flet_fastapi import uvicorn + from flet_core.types import WebRenderer logger = logging.getLogger(flet_fastapi.__name__) diff --git a/sdk/python/packages/flet/src/flet/__init__.py b/sdk/python/packages/flet/src/flet/__init__.py index 1a7971468..bda8d87e6 100644 --- a/sdk/python/packages/flet/src/flet/__init__.py +++ b/sdk/python/packages/flet/src/flet/__init__.py @@ -1,11 +1 @@ from flet.app import app, app_async -from flet_core import * -from flet_core.pubsub import PubSubClient -from flet_core.types import ( - FLET_APP, - FLET_APP_HIDDEN, - FLET_APP_WEB, - WEB_BROWSER, - AppView, - WebRenderer, -) diff --git a/sdk/python/packages/flet/src/flet/app.py b/sdk/python/packages/flet/src/flet/app.py index b139d54f6..035debcf0 100644 --- a/sdk/python/packages/flet/src/flet/app.py +++ b/sdk/python/packages/flet/src/flet/app.py @@ -10,6 +10,7 @@ import flet import flet.version from flet.utils import get_current_script_dir, get_free_tcp_port, open_in_browser + from flet_core.event import Event from flet_core.page import Page from flet_core.types import AppView, WebRenderer @@ -298,7 +299,6 @@ async def __run_web_server( def __run_pyodide(target): - import flet_js from flet.pyodide_connection import PyodideConnection async def on_event(e): diff --git a/sdk/python/packages/flet/src/flet/auth/authorization.py b/sdk/python/packages/flet/src/flet/auth/authorization.py index 2034060c9..477af9650 100644 --- a/sdk/python/packages/flet/src/flet/auth/authorization.py +++ b/sdk/python/packages/flet/src/flet/auth/authorization.py @@ -10,11 +10,12 @@ from flet.auth.oauth_token import OAuthToken from flet.auth.user import User from flet.version import version -from flet_core.locks import AsyncNopeLock, NopeLock -from flet_core.utils import is_asyncio from oauthlib.oauth2 import WebApplicationClient from oauthlib.oauth2.rfc6749.tokens import OAuth2Token +from flet_core.locks import AsyncNopeLock, NopeLock +from flet_core.utils import is_asyncio + class Authorization: def __init__( diff --git a/sdk/python/packages/flet/src/flet/fastapi/__init__.py b/sdk/python/packages/flet/src/flet/fastapi/__init__.py index eb2d1fb05..8b1378917 100644 --- a/sdk/python/packages/flet/src/flet/fastapi/__init__.py +++ b/sdk/python/packages/flet/src/flet/fastapi/__init__.py @@ -1 +1 @@ -from flet_web.fastapi import * + diff --git a/sdk/python/packages/flet/src/flet/pyodide_connection.py b/sdk/python/packages/flet/src/flet/pyodide_connection.py index cc478de6e..62c2dbf29 100644 --- a/sdk/python/packages/flet/src/flet/pyodide_connection.py +++ b/sdk/python/packages/flet/src/flet/pyodide_connection.py @@ -5,7 +5,7 @@ import flet import flet_js -import js + from flet_core.local_connection import LocalConnection from flet_core.protocol import ( ClientActions, diff --git a/sdk/python/packages/flet/src/flet/utils/__init__.py b/sdk/python/packages/flet/src/flet/utils/__init__.py index cc5d56779..7f368699e 100644 --- a/sdk/python/packages/flet/src/flet/utils/__init__.py +++ b/sdk/python/packages/flet/src/flet/utils/__init__.py @@ -2,7 +2,7 @@ import socket import sys -from flet_core.utils import Vector, is_mobile, slugify +from flet_core.utils import is_mobile def open_in_browser(url):