[MaterialTimePicker] Add Input validation
See original GitHub issueIs your feature request related to a problem? Please describe.
Many times, apps need users to select a date+time in the past/future. MaterialDatePicker
solves this problem by having the option to add constraints with a validator. TimePicker doesn’t allow any such option.
Describe the solution you’d like
An addConstraints
implementation for MaterialTimePicker
. I understand that it won’t be possible to simply extend CalendarConstraints
for this because the time picker is only concerned with time but an option to add constraints in the form of (say) constraintBefore(int hour, int minute)
and constraintAfter(int hour, int minute)
can be added.
Describe alternatives you’ve considered
The present alternative to this I am using is to manually check the time from the TimePicker
and reset the time if it doesn’t fall within the required constraints. (Say I only allow time to be selected in the past, but user has entered a future time. I reset the displayed time to the current time). But this leaves room for a bad UX where the user can get confused or not even realize their selected time has been changed.
Additional context An example implementation can be this library I found on Github
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:6 (2 by maintainers)
Hi I think disabling OK button is feasible since it has less UX impact. Regarding your suggestion - we may need to consult with our UX designers and see what they think, which, may take a much longer time.
I’ll raise the idea internally first and check if we can add support to disable OK button first.
Just so we know, are time constraints a “in progress” work currently?