-
Notifications
You must be signed in to change notification settings - Fork 589
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: |
6662886
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://94551396.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.
| def handle_entry_mode_change(e: ft.TimePickerEntryModeChangeEvent): | ||
| page.add(ft.Text(f"TimePicker Entry mode changed to {e.entry_mode}")) | ||
| page.show_dialog(ft.SnackBar(f"Entry mode changed: {time_picker.entry_mode}")) | ||
| print(e, e.entry_mode) |
Copilot
AI
Nov 8, 2025
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 print statement appears to be a debugging artifact and should be removed before merging to production code.
| print(e, e.entry_mode) |
| dial_text_style: Optional[TextStyle] = None | ||
| """ | ||
| The [TextStyle][flet.TextStyle] for the numbers on the time selection dial. | ||
| The [`TextStyle`][[flet.TextStyle] for the numbers on the time selection dial. |
Copilot
AI
Nov 8, 2025
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 Markdown link syntax is malformed. It should be [TextStyle][flet.TextStyle] not [TextStyle][[flet.TextStyle] (note the double opening bracket).
| """ | ||
| Used to configure the [TextStyle][flet.TextStyle] for the helper text in the header. | ||
| Used to configure the [`TextStyle`][[flet.TextStyle] |
Copilot
AI
Nov 8, 2025
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 Markdown link syntax is malformed. It should be [TextStyle][flet.TextStyle] not [TextStyle][[flet.TextStyle] (note the double opening bracket).
| hour_minute_text_style: Optional[TextStyle] = None | ||
| """ | ||
| Used to configure the [TextStyle][flet.TextStyle] for the hour/minute controls. | ||
| Used to configure the [`TextStyle`][[flet.TextStyle] for the hour/minute controls. |
Copilot
AI
Nov 8, 2025
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 Markdown link syntax is malformed. It should be [TextStyle][flet.TextStyle] not [TextStyle][[flet.TextStyle] (note the double opening bracket).
| Used to configure the [`TextStyle`][[flet.TextStyle] for the hour/minute controls. | |
| Used to configure the [`TextStyle`][flet.TextStyle] for the hour/minute controls. |
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: