-
Notifications
You must be signed in to change notification settings - Fork 25k
Support of spinnerMode property to allow spinner datepicker on Android #10339
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
Conversation
…datepicker is shown as a spinner, not the calenderview.
|
By analyzing the blame information on this pull request, we identified @AaaChiuuu to be a potential reviewer. |
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
| final DatePickerDialog dialog = | ||
| new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); | ||
| DatePickerDialog dialog; | ||
| if (args != null && args.containsKey(DatePickerDialogModule.ARG_SPINNERMODE) && args.getBoolean(DatePickerDialogModule.ARG_SPINNERMODE)) { |
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.
do we need args.containsKey(DatePickerDialogModule.ARG_SPINNERMODE)?
args.getBoolean(DatePickerDialogModule.ARG_SPINNERMODE) defaults to false
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.
Indeed, we don't need that condition.
No need for check if args contains property DatePickerDialogModule.ARG_SPINNERMODE, getBoolean defaults to false when no prop is found.
|
Does using https://developer.android.com/reference/android/widget/DatePicker.html#setSpinnersShown(boolean) works instead of using an old holo theme? It would be better if there ends up being a material style spinner date picker. |
|
@SilVdB do you still plan to ship this PR? |
|
Just merged #10932 which should provide the same functionality. |
Motivation
Since Android 5.0 (Material UI), the DatePicker component (https://developer.android.com/reference/android/widget/DatePicker.html) supports two modes:
We wanted to be able to use the spinner mode, since some of our Android users were complaining about the calendar mode being confusing and causing too much cognitive strain.
Solution
I discovered that the easiest way to accomplish this is described here: http://stackoverflow.com/questions/27709668/hide-calenderview-from-datepicker-programatically-in-api-21/31610267#31610267
I added a property Boolean
spinnerModeto the datepicker module (java) that decides wether or not the style suggested above is applied, resulting in a spinner in stead of a calendar view.Test plan (required)
When opening a datepicker on Android, simply pass the property like this:
DatePickerAndroid.open({ date: Date.now(), spinnerMode: true})The resulting datepicker looks like this:

When setting spinnerMode to false (or not passing it at all), the datepicker looks like this:
