-
Notifications
You must be signed in to change notification settings - Fork 579
v1: DateRangePicker and more integration tests #5642
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
base: main
Are you sure you want to change the base?
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine
Deploying flet-docs with
|
Latest commit: |
45830ae
|
Status: | ✅ Deploy successful! |
Preview URL: | https://6b8f941a.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
ft.Text(f"End Date changed: {e.control.end_value.strftime('%m/%d/%Y')}"), | ||
) | ||
|
||
def handle_dismissal(e): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please type annotate e
in both functions?
- source_dir: integration_tests | ||
target_url_path: test-images | ||
include_exts: [".png", ".gif", ".svg"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed when addressing #5642 (comment).
) | ||
|
||
__all__ = [ | ||
"DatePickerEntryMode", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't defined in this file.
error_invalid_text: Optional[str] = None | ||
""" | ||
The error message displayed below the TextField if the date is earlier than | ||
`first_date` or later than `last_date`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props could be cross-referenced.
[y][flet.X.y]
The tile's color when hovered. Only takes effect if `toggle_inputs` is True or if | ||
`on_click` is provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props can be cross referenced.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Called when user clicks confirm button. | ||
[`value`][flet.DatePicker.value] is updated with selected date. | ||
The `data` property of the event handler argument contains the selected date. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly references DatePicker.value
instead of the appropriate DateRangePicker properties. It should reference start_value
and end_value
and mention that the data contains the selected date range, not a single date.
Called when user clicks confirm button. | |
[`value`][flet.DatePicker.value] is updated with selected date. | |
The `data` property of the event handler argument contains the selected date. | |
Called when user clicks the confirm button. | |
[`start_value`][flet.DateRangePicker.start_value] and [`end_value`][flet.DateRangePicker.end_value] are updated with the selected date range. | |
The `data` property of the event handler argument contains the selected date range (start and end dates). |
Copilot uses AI. Check for mistakes.
sdk/python/packages/flet/src/flet/controls/material/date_range_picker.py
Show resolved
Hide resolved
switch_to_calendar_icon: Optional[IconData] = None | ||
""" | ||
The name of the icon displayed in the corner of the dialog when | ||
[`date_picker_entry_mode`][flet.DatePicker.date_picker_entry_mode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link incorrectly references flet.DatePicker.date_picker_entry_mode
but should reference flet.DateRangePicker.date_picker_entry_mode
since this is documentation for DateRangePicker.
Copilot uses AI. Check for mistakes.
switch_to_input_icon: Optional[IconData] = None | ||
""" | ||
The name of the icon displayed in the corner of the dialog when | ||
[`date_picker_entry_mode`][flet.DatePicker.date_picker_entry_mode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link incorrectly references flet.DatePicker.date_picker_entry_mode
but should reference flet.DateRangePicker.date_picker_entry_mode
since this is documentation for DateRangePicker.
Copilot uses AI. Check for mistakes.
Description
Test Code
# Test code for the review of this PR
Type 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: