Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:ControlState should be resolved based on user-defined order #4556

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Dec 12, 2024

Fixes #4409

Test Code

import flet as ft


def main(page: ft.Page):
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    button = ft.TextButton(
        "Test Button",
        style=ft.ButtonStyle(
            bgcolor={
                ft.ControlState.DEFAULT: ft.colors.with_opacity(0.786, "ffffff"),
                 ft.ControlState.PRESSED: ft.colors.BLUE,
                ft.ControlState.HOVERED: ft.colors.GREEN,
            }
        ),
    )
    page.add(button)


ft.app(main)

Summary by Sourcery

Resolve ControlState based on user-defined order and replace the empty string with 'default' for default state handling.

Bug Fixes:

  • Fix the resolution of ControlState to respect user-defined order, ensuring that the correct state is applied based on the specified sequence.

Enhancements:

  • Deprecate the use of an empty string for default state and replace it with the term 'default' for clarity and consistency.

Tests:

  • Update tests to reflect the change from an empty string to 'default' for default state handling, ensuring that the new logic is correctly validated.

@FeodorFitsner FeodorFitsner merged commit 0e73586 into main Dec 12, 2024
1 of 2 checks passed
@FeodorFitsner FeodorFitsner deleted the ndonkoHenri/control-state-resolve-order branch December 12, 2024 22:35
FeodorFitsner pushed a commit that referenced this pull request Dec 12, 2024
)

* ControlState: rename "" to "default"

* resolve ControlState on user-defined order

* fix failing tests

* remove breaking line
FeodorFitsner added a commit that referenced this pull request Dec 13, 2024
* feat: implement `Window.ignore_mouse_events` (#4465)

* Update project_dependencies.py (#4459)

# `Fixed` when I get no markers key in the version_value variable.

```bash
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.5/x64/bin/flet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet/cli.py", line 12, in main
    flet_cli.cli.main()
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet_cli/cli.py", line 89, in main
    args.handler(args)
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet_cli/commands/build.py", line 557, in handle
    self.package_python_app()
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet_cli/commands/build.py", line 1303, in package_python_app
    toml_dependencies = get_poetry_dependencies(
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet_cli/utils/project_dependencies.py", line 41, in get_poetry_dependencies
    format_dependency_version(dependency, version)
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/flet_cli/utils/project_dependencies.py", line 21, in format_dependency_version
    if version_value["markers"]:
       ~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'markers'
```

* Remove `v0.26.0` deprecations (#4479)

* delete deprecations on py end

* delete deprecations on dart end

* fix: `SafeArea` object has no attribute `_SafeArea__minimum` (#4500)

* remove minimum from SafeArea

* remove deprecated props

* Changelog updated

* Fix publishing flet-windows.zip to releases

* Revert "Merge branch 'main' into feodor/prepare-0-25-2"

This reverts commit 32a7343, reversing
changes made to 3dc01e1.

* Changelog updated

* Update changelog.

* Changelog updated with cherry-picked bug fixes

* fix broken `Map.center_on()` and default animations (#4519)

* fix center_on

* get default animation duration and curve

* fix: Tooltip corruption in `Segment` and `BarChartRod` on `update()` (#4525)

* avoid jsonDecoding `Segment` and `BarChartRod` tooltips

* avoid jsonEncoding `Segment` and `BarChartRod` tooltips

* Unset theme visual density default

* Unset `SegmentedButton` border side default

* `TextField.hint_text` should be displayed if `label` is not specified

* fix: Setting `CheckBox.border_side.stroke_align` to an Enum fails (#4526)

* `BorderSideStrokeAlign` should inherit from float

* properly parse `Chip.border_side`

* fix:`ControlState` should be resolved based on user-defined order (#4556)

* ControlState: rename "" to "default"

* resolve ControlState on user-defined order

* fix failing tests

* remove breaking line

* fix wrong attribute name (#4557)

* Publish flet wheels to GitHub releases

* remove redeclared `MapPointerDeviceType`

---------

Co-authored-by: TheEthicalBoy <98978078+ndonkoHenri@users.noreply.github.com>
Co-authored-by: Osama Mohammed Al-zabidi <57198110+omamkaz@users.noreply.github.com>
Co-authored-by: ndonkoHenri <robotcoder4@protonmail.com>
syleishere pushed a commit to syleishere/flet-dev that referenced this pull request Dec 14, 2024
…et-dev#4556)

* ControlState: rename "" to "default"

* resolve ControlState on user-defined order

* fix failing tests

* remove breaking line
Bbalduzz added a commit to Bbalduzz/fluentflet that referenced this pull request Dec 14, 2024
### `TextBox` Component
- Added new features:
  - `prefix` text support
  - `suffix` text support
- Added dynamic padding calculations based on prefix/suffix content
- Enhanced focus/blur handling:
  - Added opacity control for hint text
  - Improved hint text color management
  - Added explicit handling for hint text style changes during focus/blur states

### `Button` Component
- Reorganized state handling:
  - Reordered control states for better consistency. Flet version must be > `0.25.2` ([see why](flet-dev/flet#4556))
- State configurations now properly implement:
  - Hover states
  - Pressed states
  - Default states
  - Disabled states

### Navigation System
- Added new `NavigationType` enum with two modes:
  - `STANDARD`: Original layout that pushes content
  - `OVERLAY`: Navigation overlays the content
- Enhanced navigation panel styling:
  - Added blur effects for expanded state
  - Implemented border radius adjustments
  - Added shadow effects
  - Improved animation handling

### Window System
- Added `NavigationType` to exported symbols
- Modified default window behavior to support new navigation types
- Enhanced window layout management for both standard and overlay navigation modes

## Infrastructure Changes

### Dependencies
- Updated Flet dependency to match the new pypi library structure:
  - Old: `flet>=0.25.1`
  - New: `flet[all]>=0.25.2`

## API Changes and Deprecations
- Removed **deprecated** `right_icon` and `right_action` properties from `TextBox`
- Changed method of handling icon actions in TextBox to new action system
- Modified window navigation behavior to support new navigation types

## Performance Improvements
- Implemented icon availability caching in icon browser
- Added pre-calculated styles for common UI elements
- Optimized update patterns in components to reduce unnecessary rerenders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ControlState precedence issue with button states
2 participants