flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.56k stars 452 forks source link

feat: expose more properties in Controls #4105

Closed ndonkoHenri closed 4 weeks ago

ndonkoHenri commented 1 month ago

Summary by Sourcery

Enhance the Flet core library by introducing new properties across multiple controls, including TextField, Text, Icon, PopupMenuButton, GestureDetector, Draggable, and NavigationBarDestination, to provide more customization and interaction options. Refactor existing functions and controls to improve flexibility, error handling, and support for adaptive design.

New Features:

Enhancements:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request exposes more properties in various controls, enhancing their customization capabilities. It also includes some refactoring and code improvements across multiple files.

Class diagram for updated TextField class

classDiagram
    class TextField {
        +Optional[bool] enable_interactive_selection
        +Optional[bool] enable_ime_personalized_learning
        +Optional[bool] can_request_focus
        +Optional[bool] ignore_pointers
        +Optional[bool] enable_scribble
        +Optional[bool] animate_cursor_opacity
        +Optional[bool] always_call_on_tap
        +PaddingValue scroll_padding
        +Optional[ClipBehavior] clip_behavior
        +Optional[Brightness] keyboard_brightness
        +Optional[MouseCursor] mouse_cursor
        +Optional[StrutStyle] strut_style
        +OptionalControlEventCallable on_click
        +Optional[Control] helper
        +Optional[Control] error
        +Union[None, str, Control] prefix_icon
        +Union[None, str, Control] suffix_icon
        +Optional[str] focus_color
        +Optional[bool] align_label_with_hint
        +DurationValue hint_fade_duration
        +Optional[int] hint_max_lines
        +Optional[int] helper_max_lines
        +Optional[int] error_max_lines
        +Optional[str] prefix_icon_color
        +Optional[BoxConstraints] prefix_icon_size_constraints
        +Optional[str] suffix_icon_color
        +Optional[BoxConstraints] suffix_icon_size_constraints
    }

Class diagram for updated Text class

classDiagram
    class Text {
        +Optional[bool] show_selection_cursor
        +Optional[bool] enable_interactive_selection
        +OptionalNumber selection_cursor_width
        +OptionalNumber selection_cursor_height
        +Optional[str] selection_cursor_color
        +OptionalControlEventCallable on_tap
        +OptionalEventCallable[TextSelectionChangeEvent] on_selection_change
    }

Class diagram for updated Icon class

classDiagram
    class Icon {
        +Union[BoxShadow, List[BoxShadow], None] shadows
        +OptionalNumber fill
        +Optional[bool] apply_text_scaling
        +OptionalNumber grade
        +OptionalNumber weight
        +OptionalNumber optical_size
    }

Class diagram for updated PopupMenuButton class

classDiagram
    class PopupMenuButton {
        +PaddingValue menu_padding
        +Optional[ButtonStyle] style
        +Optional[AnimationStyle] popup_animation_style
        +Optional[BoxConstraints] size_constraints
        +OptionalControlEventCallable on_select
    }

Class diagram for updated GestureDetector class

classDiagram
    class GestureDetector {
        +Optional[bool] exclude_from_semantics
        +Optional[bool] trackpad_scroll_causes_scale
        +Optional[Set[PointerDeviceType]] allowed_devices
    }

File-Level Changes

Change Details Files
Enhanced TextField control with additional properties and functionality
  • Added new properties such as cursor_error_color, obscuring_character, enable_interactive_selection, and more
  • Implemented new methods for the added properties
  • Updated the build method to include the new properties
sdk/python/packages/flet-core/src/flet_core/textfield.py
packages/flet/lib/src/controls/textfield.dart
Expanded FormFieldControl with new attributes and methods
  • Added properties like focus_color, align_label_with_hint, hint_fade_duration, and more
  • Implemented getter and setter methods for the new properties
  • Updated the buildInputDecoration method to include the new properties
sdk/python/packages/flet-core/src/flet_core/form_field_control.py
packages/flet/lib/src/utils/form_field.dart
Enhanced Icon control with additional customization options
  • Added properties like shadows, fill, apply_text_scaling, grade, weight, and optical_size
  • Implemented getter and setter methods for the new properties
  • Updated the build method to include the new properties
sdk/python/packages/flet-core/src/flet_core/icon.py
packages/flet/lib/src/controls/icon.dart
Refactored and improved various controls and utilities
  • Updated PopupMenuButton with new properties and methods
  • Refactored GestureDetector to support more customization options
  • Improved Dropdown control with additional properties
  • Enhanced NavigationBar and NavigationDrawer controls
  • Updated utility functions for parsing and handling various properties
sdk/python/packages/flet-core/src/flet_core/popup_menu_button.py
packages/flet/lib/src/controls/popup_menu_button.dart
sdk/python/packages/flet-core/src/flet_core/gesture_detector.py
packages/flet/lib/src/controls/gesture_detector.dart
sdk/python/packages/flet-core/src/flet_core/dropdown.py
packages/flet/lib/src/controls/dropdown.dart
sdk/python/packages/flet-core/src/flet_core/navigation_bar.py
packages/flet/lib/src/controls/navigation_bar.dart
sdk/python/packages/flet-core/src/flet_core/navigation_drawer.py
packages/flet/lib/src/controls/navigation_drawer.dart
packages/flet/lib/src/utils/transforms.dart
packages/flet/lib/src/utils/box.dart
packages/flet/lib/src/utils/others.dart

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
FeodorFitsner commented 1 month ago

Please resolve conflicts.

FeodorFitsner commented 1 month ago

Could you look at the conflict please?