v1: DateRangePicker and more integration tests#5642
Conversation
Introduces an integration test for DatePicker theme customization with a golden screenshot for macOS. Updates docstrings for Theme class to clarify DataTableTheme and DatePickerTheme usage. Also refines ListTile hover_color docstring to specify when it takes effect.
DateRangePicker-related theme properties have been commented out in both Dart and Python implementations. This change likely reflects that these properties are not yet supported or are pending future implementation.
Introduced DateRangePicker control for both Dart and Python SDKs, including its registration in FletCoreExtension and Python __init__.py. This enables Material-style date range selection dialogs with customizable properties and event handling.
Introduces the DateRangePicker control to the Python SDK, including its implementation, example usage, documentation, and integration tests. Updates the Dart backend to support new properties and events for date range selection. Adds related documentation and navigation entry in mkdocs.
Updated the image path and size in the DateRangePicker documentation. Modified mkdocs.yml to include test images from integration_tests. Refactored date_range_picker.py to import DatePickerEntryMode from the material.date_picker module instead of defining it locally.
Uncommented and activated all DateRangePicker theme properties in both Dart and Python implementations, allowing full customization of elevation, background, header, shape, and selection colors. Also improved event handling in the Dart DateRangePicker control by passing the selected range to 'change' and 'dismiss' events.
Updated the 'basic' DateRangePicker test and golden image, and added a new 'properties1' test with corresponding screenshot. The new test covers various DateRangePicker properties to improve test coverage and reliability.
Renamed properties1.png to properties_calendar.png and added properties_input.png for input mode. Modified test_date_range_picker.py to capture screenshots for both calendar and input modes, improving test coverage for date picker entry modes.
Introduces a new integration test for the DateRangePicker theme on macOS, including a golden screenshot for visual regression. This ensures custom theme properties are correctly applied and rendered.
Deploying flet-docs with
|
| Latest commit: |
937a703
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3fd20270.flet-docs.pages.dev |
| Branch Preview URL: | https://inesa-v1-integration-tests-p.flet-docs.pages.dev |
| --8<-- "../../examples/controls/date_range_picker/basic.py" | ||
| ``` | ||
|
|
||
| {width="60%"} |
There was a problem hiding this comment.
I won't suggest we use references to golden images folder. The image for this example should be in examples/controls/daterangepicker/media. You could basically copy the golden image in there.
| - source_dir: integration_tests | ||
| target_url_path: test-images | ||
| include_exts: [".png", ".gif", ".svg"] |
There was a problem hiding this comment.
Can be removed when addressing #5642 (comment).
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet/src/flet/controls/material/list_tile.py
Outdated
Show resolved
Hide resolved
| locale: Optional[Locale] = None | ||
| """ | ||
| An optional locale argument can be used to set the locale for the date picker. It | ||
| defaults to the ambient locale provided by Localizations. | ||
| """ | ||
|
|
There was a problem hiding this comment.
Any reason for this change?
There was a problem hiding this comment.
We currently don't have locale in DatePicker control, so it's being configured for the whole page via page.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for the DateRangePicker control with Material-style theming, integrates it into both Python and Dart SDKs, and includes comprehensive testing.
- Adds DateRangePicker control with full customization properties for date range selection
- Extends Theme API with improved documentation and removes deprecated locale field from DatePickerTheme
- Provides integration tests, documentation, and examples for the new control
Reviewed Changes
Copilot reviewed 14 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/python/packages/flet/src/flet/controls/theme.py |
Removes locale field from DatePickerTheme and adds documentation for theme properties |
sdk/python/packages/flet/src/flet/controls/material/list_tile.py |
Clarifies hover_color behavior documentation |
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py |
Implements new DateRangePicker control with comprehensive properties |
sdk/python/packages/flet/src/flet/controls/material/date_picker.py |
Updates DatePicker documentation for consistency |
sdk/python/packages/flet/src/flet/__init__.py |
Registers DateRangePicker in Python package exports |
sdk/python/packages/flet/mkdocs.yml |
Adds DateRangePicker documentation and test image support |
integration_tests/controls/test_date_range_picker_theme.py |
Tests DateRangePicker theme rendering |
integration_tests/controls/test_date_range_picker.py |
Tests DateRangePicker functionality and properties |
integration_tests/controls/test_date_picker_theme.py |
Tests DatePicker theme rendering |
docs/controls/daterangepicker.md |
Provides DateRangePicker documentation page |
examples/controls/date_range_picker/basic.py |
Basic example demonstrating DateRangePicker usage |
packages/flet/lib/src/utils/theme.dart |
Comments out locale parsing in Dart theme implementation |
packages/flet/lib/src/flet_core_extension.dart |
Registers DateRangePicker in Dart SDK |
packages/flet/lib/src/controls/date_range_picker.dart |
Implements DateRangePicker control in Dart |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Show resolved
Hide resolved
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Outdated
Show resolved
Hide resolved
Corrected references and improved clarity in docstrings for DateRangePicker and ListTile controls. Updated event handler type annotations in the date_range_picker example for better type safety.
Replaced specific class references in docstrings with generic [(c).] links in DateRangePicker and ListTile controls. This change improves maintainability and consistency in documentation references.
Set 'inherited_members' to false in mkdocs.yml to exclude inherited members from documentation. Updated docstrings in date_range_picker.py and divider.py for improved clarity and accuracy.
Simplified the on_tap_down event handler type in the Container control to only accept TapEvent, removing support for Event. Also removed outdated documentation regarding the event argument type.
Description
Test Code
# Test code for the review of this PRType of change
Checklist
Screenshots
Additional details
Summary by Sourcery
Add Material-style DateRangePicker support with theming, register it in SDKs, remove obsolete locale setting, and provide examples and integration tests
New Features:
Enhancements:
Documentation:
Tests:
Chores: