material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Feature Request] Add Neutral Button to MaterialDatePicker

Open DvTonder opened this issue 5 years ago • 23 comments

Use case: There are times when one wants to clear a selected date (i.e. I have a task with a due date, I want to use the MaterialDatePicker to display the current date, pick a new date OR clear the selected date.

The first two are currently supported, the 3rd requires either the ability to extend the class and override the onCreateView (not possible because the class is final) or adding support for a Neutral button.

DvTonder avatar May 26 '20 11:05 DvTonder

Thanks for this feature request! This is currently awaiting design feedback

melaniegoetz avatar Jun 16 '20 18:06 melaniegoetz

Any updates on this?

carlfindahl avatar Sep 08 '20 11:09 carlfindahl

Sample implementation. I did this by copying the full class into my codebase and adding neutral button support.

Screenshot_20201105-073151

DvTonder avatar Nov 05 '20 12:11 DvTonder

any update?

minas96 avatar Apr 24 '21 14:04 minas96

I would also love to see such an option, for the same reason as @DvTonder

tipa avatar May 16 '21 07:05 tipa

Same, any updates? We wanted to migrate from DatePickerDialog to MaterialDatePicker but need this button so I guess not for now.

astamato avatar May 28 '21 19:05 astamato

Any update? I've seen Google Apps using this pattern which made me think it was already implemented, but seems none of the google apps are using this MaterialDatePicker component. Am I missing some configuration?

leobrujah avatar Sep 28 '21 16:09 leobrujah

Hi folks,

Our designer is working on refining the date picker design. They are aware of the request and is adding the neutral button into their design. Please stay tuned.

drchen avatar May 11 '22 15:05 drchen

I've created a new pull request that rebases the changes against the most recent Material Components code base as of 18 December, 2023.

DvTonder avatar Dec 18 '22 17:12 DvTonder

Please please please please please can we have this? Jitpack.io is no longer building successfully the forked repo since Flamingo / Gradle 8 (something changed outside of my code) and my development has come to a halt. I cannot build my app any more

DvTonder avatar Apr 21 '23 20:04 DvTonder

Hi, the major problem of this feature request (and the relevant PR you made) is that it doesn't support the full screen mode. (Actually with your PR it crashes when you open the date picker in full screen.)

We've raised to our designers for their opinion about where to put this neutral button on the full screen picker but we don't really have a good answer yet.

If you really need this feature, can you try to support fullscreen picker as well. And I can grab a screenshot to ask if our designers are ok with that (at least for now, before we have a final design)?

Sorry for the long waiting!

drchen avatar Apr 22 '23 02:04 drchen

I will look into the full screen picker crash and update the pull request when fixed

DvTonder avatar Apr 22 '23 18:04 DvTonder

I have updated the code to include the clear button on the full screen picker as well. It was missing from the layout which caused an NPE. I picked the most logical spot for the clear button on the UI

WhatsApp Image 2023-04-22 at 17 49 19

DvTonder avatar Apr 22 '23 21:04 DvTonder

Hi, it has been 2 months since the update to the full screen view. Any updates?

Zhuinden avatar Jun 29 '23 13:06 Zhuinden

Hi,

So our designer provided a different design guidelines regarding the full screen mode, which requires a bit work to implement it and I apologize that we don't really have the capacity for that at the moment.

drchen avatar Jun 29 '23 14:06 drchen

Can the design guidelines be shared so I can try and implement it?

On Thu, Jun 29, 2023, 10:50 drchen @.***> wrote:

Hi,

So our designer provided a different design guidelines regarding the full screen mode, which requires a bit work to implement it and I apologize that we don't really have the capacity for that at the moment.

— Reply to this email directly, view it on GitHub https://github.com/material-components/material-components-android/issues/1332#issuecomment-1613319874, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHJ232ZPJIDYKFHDSORCGTXNWI2HANCNFSM4NKHGRAA . You are receiving this because you were mentioned.Message ID: <material-components/material-components-android/issues/1332/1613319874@ github.com>

DvTonder avatar Jun 29 '23 14:06 DvTonder

That will be great! Thank you so much!

The design suggestion is following the spec here: https://m3.material.io/components/date-pickers/specs#f25f68b7-1bb5-4248-829e-fe3cd3499dab And adding only the clear button to the bottom button bar (which doesn't really exist in the current implementation).

drchen avatar Jun 29 '23 15:06 drchen

To confirm:

Looking at the spec, it is basically adding 'cancel' and 'ok' (and 'clear) buttons in a button bar at the bottom of the full screen view, mimicking a dialog. The current full screen view does not have that.

Should be relatively easy to do, I think

On Thu, Jun 29, 2023, 11:08 drchen @.***> wrote:

That will be great! Thank you so much!

The design suggestion is following the spec here:

https://m3.material.io/components/date-pickers/specs#f25f68b7-1bb5-4248-829e-fe3cd3499dab And adding only the clear button to the bottom button bar.

— Reply to this email directly, view it on GitHub https://github.com/material-components/material-components-android/issues/1332#issuecomment-1613352550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHJ232QATTEWYSKMF6OHYLXNWLANANCNFSM4NKHGRAA . You are receiving this because you were mentioned.Message ID: <material-components/material-components-android/issues/1332/1613352550@ github.com>

DvTonder avatar Jun 29 '23 15:06 DvTonder

That's correct. : )

Thank you so much for contributing on this!

FYI after the change is made it may take a while internally for us to figure out a strategy to update the change to google apps, which has a lot of document work to do.

I would suggest to introduce this new style as a separate theme/style (and ignore neutral button in the original theme/style) which should make migration easier on our end.

drchen avatar Jun 29 '23 16:06 drchen

@drchen can you confirm this is how they intend the design to be?

I've implemented it though I still have to figure out how to do the style/theme stuff you mention. Not entirely sure how to tackle that yet... Any guidance would be appreciated

[EDITED with updated screenshots. I implemented the padding/margins as indicated in design]

Screenshot_20230703_112043

Screenshot_20230703_112353

DvTonder avatar Jul 03 '23 15:07 DvTonder

I'm using the MaterialDatePicker as a date range picker, and I tried setting setNegativeButtonText and addOnNegativeButtonClickListener to no avail, no neutral button shows up in the interface. So it's either a bug, or the method does nothing when the date picker is a range one, which is quite misleading... What's the expected behavior for these methods? I'd like the user to be able to clear the chosen dates. It would be great to have a neutral button for the date range picker too. I can make a feature request once I'm certain that this is not actually a bug, or a bug ticket then

Screenshot 2023-08-21 at 17 39 50

fabiorbap avatar Aug 21 '23 20:08 fabiorbap

I will check the code. I'm not sure if I implemented the clearing for the Range picker.

On Mon, Aug 21, 2023 at 4:40 PM fabiorbap @.***> wrote:

I'm using the MaterialDatePicker as a date range picker, and I tried setting setNegativeButtonText and addOnNegativeButtonClickListener to no avail, no neutral button shows up in the interface. So it's either a bug, or the method does nothing when the date picker is a range one, which is quite misleading... What's the expected behavior for these methods? I'd like the user to be able to clear the chosen dates [image: Screenshot 2023-08-21 at 17 39 50] https://user-images.githubusercontent.com/12398089/262148708-9038d94d-8d55-4e78-b1fe-525b2c25b51e.png

— Reply to this email directly, view it on GitHub https://github.com/material-components/material-components-android/issues/1332#issuecomment-1687012981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHJ235KGX47DBWKP5BF6W3XWPBT3ANCNFSM4NKHGRAA . You are receiving this because you were mentioned.Message ID: <material-components/material-components-android/issues/1332/1687012981@ github.com>

DvTonder avatar Sep 03 '23 15:09 DvTonder

I added the full screen version code to this pull request -> https://github.com/material-components/material-components-android/pull/3145 but I still have to do the 'style' enabled version

DvTonder avatar Sep 03 '23 15:09 DvTonder