Skip to content

Conversation

InesaFitsner
Copy link
Contributor

@InesaFitsner InesaFitsner commented Sep 16, 2025

Description

Test Code

# Test code for the review of this PR

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

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:

  • Introduce DateRangePicker control in Python and Dart SDKs with full customization properties

Enhancements:

  • Extend Theme API to include DataTable and DatePicker theme entries and remove deprecated locale from DatePickerTheme
  • Register DateRangePicker in core extensions and expose it in the Python package
  • Clarify ListTile hover_color behavior in documentation

Documentation:

  • Add DateRangePicker documentation page and basic example
  • Update mkdocs configuration to include test images and navigation entry for DateRangePicker

Tests:

  • Add integration tests for DateRangePicker functionality and theme rendering for both DatePicker and DateRangePicker

Chores:

  • Remove locale field and parsing logic from DatePickerTheme

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.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

Copy link

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

--8<-- "../../examples/controls/date_range_picker/basic.py"
```

![basic](../test-images/controls/golden/macos/date_range_picker/basic.png){width="60%"}
Copy link
Contributor

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):
Copy link
Contributor

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?

Comment on lines +149 to +151
- source_dir: integration_tests
target_url_path: test-images
include_exts: [".png", ".gif", ".svg"]
Copy link
Contributor

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",
Copy link
Contributor

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`.
Copy link
Contributor

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]

Comment on lines +118 to +119
The tile's color when hovered. Only takes effect if `toggle_inputs` is True or if
`on_click` is provided.
Copy link
Contributor

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.

Comment on lines -2076 to -2081
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.
"""

Copy link
Contributor

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?

@ndonkoHenri ndonkoHenri requested a review from Copilot September 17, 2025 05:09
Copy link
Contributor

@Copilot Copilot AI left a 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.

Comment on lines +178 to +181
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.
Copy link
Preview

Copilot AI Sep 17, 2025

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.

Suggested change
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.

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]
Copy link
Preview

Copilot AI Sep 17, 2025

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]
Copy link
Preview

Copilot AI Sep 17, 2025

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.

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.

2 participants