-
Notifications
You must be signed in to change notification settings - Fork 590
feat: custom TimePicker hour formats
#5790
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
TimePicker time formatsTimePicker hour formats
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: |
493dd99
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a3802eaa.flet-docs.pages.dev |
| Branch Preview URL: | https://timepicker-time-format.flet-docs.pages.dev |
|
Two issues left:
|
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 adds support for controlling the hour format (12-hour vs 24-hour) in the TimePicker control. The implementation introduces a new TimePickerHourFormat enum with three values: SYSTEM, H12, and H24, and adds a corresponding hour_format property to the TimePicker control.
Key changes:
- New
TimePickerHourFormatenum with system/12h/24h options - Updated
TimePickerwithhour_formatproperty and improved documentation - Added
always_use_24_hour_formattoPageMediaDatafor system-level hour format detection - Enhanced documentation with examples demonstrating hour format usage
Reviewed Changes
Copilot reviewed 16 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/python/packages/flet/src/flet/controls/theme.py |
Fixed Markdown link syntax in docstrings for TextStyle references |
sdk/python/packages/flet/src/flet/controls/material/time_picker.py |
Added TimePickerHourFormat enum, updated TimePicker class with hour_format property and improved documentation |
sdk/python/packages/flet/src/flet/controls/base_page.py |
Added always_use_24_hour_format field to PageMediaData |
sdk/python/packages/flet/src/flet/__init__.py |
Exported new TimePickerHourFormat enum |
sdk/python/packages/flet/mkdocs.yml |
Added documentation page for TimePickerHourFormat |
sdk/python/examples/controls/time_picker/basic.py |
Updated example with improved code quality |
sdk/python/examples/controls/time_picker/hour_formats.py |
New example demonstrating hour format functionality |
packages/flet/lib/src/controls/time_picker.dart |
Dart implementation for hour format support using MediaQuery |
packages/flet/lib/src/protocol/page_media_data.dart |
Added alwaysUse24HourFormat field to protocol |
packages/flet/lib/src/widgets/page_media.dart |
Updated to read alwaysUse24HourFormat from MediaQuery |
| Integration test files | Added comprehensive tests for different hour formats |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
sdk/python/packages/flet/integration_tests/examples/material/test_time_picker.py
Outdated
Show resolved
Hide resolved
# Conflicts: # sdk/python/packages/flet/integration_tests/controls/material/test_time_picker.py # sdk/python/packages/flet/integration_tests/examples/material/test_time_picker.py
Enhanced the tester API to allow specifying the index of a control when multiple matches are found. Updated Dart and Python tester interfaces, finder logic, and integration tests to support and utilize this capability, enabling more precise UI automation and testing.
…flet into timepicker-time-format
The call to resize_page in test_hour_formats is no longer awaited, likely because the function is now synchronous. This aligns the test with the updated API.
Refreshed golden images for macOS time picker hour formats and added new images for additional formats. Modified test_time_picker.py to improve the _select_clock helper, ensuring more comprehensive screenshot coverage and interaction consistency.
…flet into timepicker-time-format
Refreshed the golden PNG images for basic, 12-hour, and 24-hour time picker integration tests on macOS to reflect recent UI or rendering changes.
Refreshed basic.png and image_for_docs.png in the golden images for the macOS time picker integration tests to reflect recent UI or rendering changes.
Fix #5185
Example
Summary by Sourcery
Enable custom hour formatting in TimePicker by introducing a new hour_format option and propagating the platform's 24-hour preference, refactor entry_mode API, and update documentation and tests accordingly
New Features:
Enhancements:
Documentation:
Tests: