google / horologist

Horologist is a group of libraries that aim to supplement Wear OS developers with features that are commonly required by developers but not yet available.
https://google.github.io/horologist/
Apache License 2.0
543 stars 87 forks source link

Observable TimePicker state without onTimeConfirm press #1931

Open cjrcodes opened 6 months ago

cjrcodes commented 6 months ago

Add the ability to get the current value of TimePicker without having to click the confirm button and having to using onTimeConfirm to get the new value

Example use case: Using TimePicker as a timer only using the hours and minutes, I want to dynamically update a projected time of when the alarm of the timer will sound off, this will be reflected via a Text composable

Time: 12:00 PM TimePicker: 00:05 Projected time: 12:05 PM

User switches the value on the TimePicker to 01:32, the projected time now reflects this dynamically as the TimePicker state is able to be observed without onTimeConfirm

Time: 12:00 PM TimePicker: 01:32 Projected time: 01:32 PM

User clicks confirm on the TimePicker and the timer starts

yschimke commented 6 months ago

Should we copy the approach of Material3 TimePicker, with TimePickerState?

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/TimePicker.kt;l=606?q=TimePicker

yschimke commented 6 months ago

cc @rajat4064g @BowerSteve