-
Notifications
You must be signed in to change notification settings - Fork 607
v1: Declarative approach in Flet revised #5657
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Introduces the bind method for associating a content builder with the Page and the before_update method to process and validate views before updating. Ensures views have unique routes and handles various return types from the content builder.
Renamed StateViewControl to ModelViewControl in Dart and updated references. Added a new Python components module with a fiber-based component system and use_state hook. Updated Python imports and Page class to support component-based rendering via the new render function.
Introduces the ModelView control to the Flet Python SDK, including lifecycle methods such as build, render, and before_update. This control manages its content and handles a '_frozen' attribute for state management.
Introduces Observable, ObservableList, and ObservableDict classes for reactive field change notifications in Python. Cleans up test_dataclasses.py imports and adds an equality test for Foo dataclass.
The Observable class was moved from the reactive to the components module, and is now exported in the package's __init__.py. Internal collection wrapping logic was refactored for clarity. Added comprehensive tests for Observable behavior in test_observable.py.
Moved components.py from controls to a new components directory and split out hooks (use_state, use_context, use_effect, use_memo) into separate files. Updated imports in __init__.py and page.py to reflect new module structure. Minor type improvements and debug print added in component.py.
Added constants for component type and body property. Updated parent, get, child, and children methods to properly unwrap and handle component controls, ensuring correct property access and visibility logic.
Refactored the component system to use a new _Component class and Renderer for managing state and rendering, replacing the previous Fiber-based approach. Added a method to Context to permanently disable auto-update behavior, and updated Page to use the new _Component for view rendering, ensuring auto-update is disabled after initial render.
Corrects the logic for assigning routes to views in the Page.render method by ensuring proper unwrapping of view components before accessing or setting the route attribute.
Introduces a scheduler for component updates via Session, allowing components to queue updates instead of immediate execution. Refactors use_state to use schedule_update, and moves service fields in Page for better organization. Also adds session lifecycle management for the scheduler.
Improves handling of component state in Python and Dart, refactors patching logic to support parent and path context, and updates tests for component diffing. The changes enhance component rendering, state management, and patch propagation, making the framework more robust and maintainable.
Introduces a generic hook system with use_hook and resets hook cursor before rendering. Refactors use_state to use the new hook mechanism, simplifying state management and reducing duplicated logic.
Refactored the sunflower example to use ft.Observable for state management and updated to use @ft.component for components. Enhanced the component system to support Observable subscriptions, automatic updates, and improved integration with the Renderer. Updated page rendering logic to use Renderer for component rendering.
Renamed the State class to AppModel and seed_view to SeedView in the Sunflower example for clarity and consistency. Updated usages accordingly. Also, set the default value of the View.route property to '/' in the core view implementation.
Replaces use_state with state and introduces effect hook in the component system. Removes unused use_effect.py and use_state.py files. Updates __init__.py exports and enhances component lifecycle to support effect hooks. Adds comprehensive tests for dataclass and regular class equality.
Introduces detailed logging across component, object patch, and session modules to aid debugging. Refactors effect scheduling in components to use a new schedule_effect method, with effects now processed in the session's update scheduler. Updates test cases to cover overriding controls with a component. Minor improvements to state subscription management and page update flow.
Moved StateHook and EffectHook to a new hooks.py module and refactored the component system to use use_state and use_effect hooks instead of state and effect. Updated imports, internal APIs, and tests to use the new Component class and hook functions. Improved state copying and subscription management for components.
Introduces a ComponentOwned base class to manage component ownership via weak references. Observable subscriptions are now tracked as objects (ObservableSubscription) instead of disposer functions, improving lifecycle management and clarity. Hooks now inherit from ComponentOwned, and StateHook/EffectHook are updated accordingly. Refactors use_state and use_effect to support the new subscription model and ownership tracking.
Replaces argument comparison in component memoization with a hash-based approach for improved reliability and performance. Updates the memo decorator to set memoization state via the renderer. Adds __repr__ to Observable to include version info. Includes new and updated tests for argument hashing and observable representation.
Eliminated debug log statements that output parent and grandparent control information during event triggering, reducing unnecessary log noise.
Implemented the use_context and create_context functions in flet.components.use_context, enabling context management for components. Updated __init__.py to export these new functions.
Adds support for context providers and consumers in the component system. Context values are now pushed and popped on the renderer during rendering, and components can access the nearest context value up the tree using use_context. Introduces ContextHook and updates state migration and rendering logic to handle context stacks.
Introduces use_memo and use_callback hooks for memoization in components. Refactors shallow argument comparison logic into a new utils.py module and updates component and hook internals to use the new utilities. Also updates use_effect to use 'setup' instead of 'fn' for clarity and consistency.
Introduces on_mounted, on_unmounted, and on_updated lifecycle hooks to the public API and updates use_effect to support cleanup callbacks and flexible dependencies. Also adds a _migrate_state method to TextField for improved state migration, and minor ordering fix in EffectHook dataclass.
Refactored EffectHook and related scheduling to support asynchronous setup and cleanup functions. Updated the effect scheduling mechanism to distinguish between setup and cleanup, and to properly handle coroutine functions using asyncio tasks. This enables use_effect, on_mounted, on_unmounted, and on_updated hooks to work with both synchronous and asynchronous functions.
Introduced the 'observable' decorator for easier Observable usage and added aliases (effect, mounted, unmounted, updated) for use_effect and related lifecycle hooks. Updated __init__.py to export these new utilities.
Introduces a top menu to the Minesweeper app, displaying a mine count, a face emoji that changes based on game state, and a new game button. Also updates square unrevealed color for improved UI consistency and adds required image assets.
Enhanced get_event_field_type to better resolve type annotations, especially for forward references, by merging global namespaces from base modules. Added new tests to verify correct type resolution for Page events and forward references.
Added BEVEL_RAISED and BEVEL_SUNKEN border styles for enhanced visual feedback on squares and containers. Updated alignment, sizing, and layout for better appearance and responsiveness. Added instructional text and improved container structure for the game board and menu.
Refactored Dart and Python code to allow page media and size updates to target specific views, enabling multi-view support. Updated PageMedia and backend logic to pass view context, and improved build command to support platform-specific Flutter build arguments. Also fixed imports for Protocol and removed unused ParamSpec import.
Introduces isPyodideMode() utility and replaces isFletWebPyodideMode() references in Dart code. Adds 'pyodide' property to backend and propagates it to the Python Page control, enabling detection and handling of Pyodide (WebAssembly) mode throughout the stack.
Changed the condition to trigger add view events so that it now triggers if 'triggerAddViewEvent' is null or Pyodide mode is active, instead of only when both are true. This ensures correct event handling in Pyodide environments.
Introduces entryPointBaseUrl to the Flet config and updates Python worker initialization to use this base URL. Also updates initialData scripts in index.html for better demonstration of multi-view functionality.
Corrects the path construction for the Python worker by adding a missing slash before 'python-worker.js', ensuring the worker loads correctly regardless of the base URL format.
When the player wins, all unflagged mines are now automatically flagged. This improves user experience by visually confirming all mines after a win.
Introduces an async timer that starts on the first click and updates every second while the game is running. The timer is displayed in the UI, and is properly cancelled when a new game is started.
Refactored the screenshot logic to capture and validate context before and after awaiting, ensuring the widget is still mounted and context is valid. This prevents potential errors when taking screenshots if the widget is unmounted during the delay.
Bump Pyodide CDN URLs from v0.27.7 to v0.28.3 in AppVeyor config, web client, and CLI build command to use the latest Pyodide release.
This reverts commit 83c9866.
The unused private variable _dpr was removed from the _PageControlState class to clean up the code.
Renamed badge and date picker related test files and golden images from the 'golden' directory to the 'material' directory for better organization. Also changed the pytest 'loop_scope' for test_divider_radius from 'module' to 'function' in test_divider.py.
Moved app and test files into dedicated subdirectories under integration_tests/apps for better organization. Updated macOS integration test workflow to use new test suite paths and improved artifact naming.
Replaces slashes in matrix.suite with dashes and stores the result in SAFE_SUITE to ensure valid artifact names when uploading failure screenshots in GitHub Actions.
Refactors Checkbox, CupertinoCheckbox, Switch, and CupertinoSwitch controls to properly manage ListTileClicks notifier listeners. Listeners are now updated in didChangeDependencies and removed in dispose, preventing potential memory leaks and ensuring correct behavior when the inherited notifier changes.
Renamed the test file to use a leading underscore, possibly to change its discovery or execution behavior in the test suite.
Added support for invoking methods on CupertinoTextFieldControl via addInvokeMethodListener. Implemented a handler for the 'focus' method to programmatically request focus on the text field.
Switches the GitHub Actions runner from macos-14 to macos-15 for integration tests and renames the screenshot upload step to 'Prepare failure screenshots' for clarity.
Changed test imports to use relative imports for app modules in integration tests. Added missing __init__.py files to autoupdate, counter, finders, and hello_world app test directories. Also updated the macOS integration test workflow to run on macos-14 and re-enabled all test suites.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.