Commit 25dd365
[Android] Implement material3 support for TimePicker (#33646)
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Description of Change
<!-- Enter description of the fix in this section -->
This pull request introduces a new Material3-based time picker for
Android and updates the handler registration and platform-specific
extensions to support it. The main goal is to enable the use of
`TimePickerHandler2` and `MauiMaterialTimePicker` when Material3 is
enabled, while maintaining compatibility with the existing time picker
otherwise.
### Material3 Time Picker Integration
* Added new `TimePickerHandler2` class for Android, implementing a
Material3-style time picker dialog, with custom mapping and event
handling for properties such as time, format, background, and open/close
state.
(`src/Core/src/Handlers/TimePicker/TimePickerHandler2.Android.cs`)
* Introduced `MauiMaterialTimePicker` control for Android, which wraps
the Material3 time picker UI and exposes methods for showing/hiding the
picker and updating its appearance.
(`src/Core/src/Platform/Android/MauiMaterialTimePicker.cs`)
### Handler Registration Updates
* Modified `AddControlsHandlers` method to register `TimePickerHandler2`
for Android when Material3 is enabled, and fall back to the original
handler otherwise.
(`src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs`)
[[1]](diffhunk://#diff-66e353858f3298f672f1eb103758a50e379019a1d8efe1b845de3779e7323b8bR72-R83)
[[2]](diffhunk://#diff-66e353858f3298f672f1eb103758a50e379019a1d8efe1b845de3779e7323b8bL90)
### Platform Extension Methods
* Added extension methods for updating format, time, and text color for
`MauiMaterialTimePicker`, mirroring existing methods for the legacy time
picker, and ensuring correct formatting and appearance.
(`src/Core/src/Platform/Android/TimePickerExtensions.cs`)
Material Design Spec -
[TimePicker](https://m3.material.io/components/time-pickers/specs)
### Issues Fixed
<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->
Fixes #33645
### Output
| Material 2 |Material 3 |
|----------|----------|
| <img
src="https://github.com/user-attachments/assets/13cf453c-93e4-4009-a465-9ed9975d9d18">
| <img
src="https://github.com/user-attachments/assets/577cd1d1-79fe-4348-856e-8658ea969fd9">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->1 parent 81dbe0e commit 25dd365
24 files changed
Lines changed: 783 additions & 9 deletions
File tree
- src
- Controls
- src/Core/Hosting
- tests
- TestCases.Android.Tests/snapshots/android-notch-36
- Core/src
- Handlers/TimePicker
- Platform/Android
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| |||
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
90 | | - | |
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
| |||
0 commit comments