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

[Slider] Add new tick visibility modes

Open pubiqq opened this issue 2 years ago • 11 comments

  • Resolves https://github.com/material-components/material-components-android/issues/1233 (taking into account the wishes of https://github.com/material-components/material-components-android/issues/1233#issuecomment-1201312042)
  • Resolves https://github.com/material-components/material-components-android/issues/4237

Highlights

  • New tick visibility API: Slider.getTickVisibilityMode(), Slider.setTickVisibilityMode(int), and app:tickVisibilityMode.
  • New tick visibility modes:
    • visibleAll - All tick marks will be drawn, even if they are spaced too densely and overlap each other.
    • autoLimit - (Default) All tick marks will be drawn if they are not spaced too densely. Otherwise, the maximum allowed number of tick marks will be drawn.
    • autoHide - All tick marks will be drawn if they are not spaced too densely. Otherwise, the tick marks will not be drawn.
    • hidden - Tick marks will not be drawn at all.
  • Slider.setTickVisible(boolean) is deprecated in favor of Slider.setTickVisibilityMode(int).
  • app:tickVisible is deprecated in favor of app:tickVisibilityMode.

Migration

  • Slider.setTickVisible(true) -> Slider.setTickVisibilityMode(TICK_VISIBILITY_AUTO_LIMIT)
  • Slider.setTickVisible(false) -> Slider.setTickVisibilityMode(TICK_VISIBILITY_HIDDEN)
  • app:tickVisible="true" -> app:tickVisibilityMode="autoLimit"
  • app:tickVisible="false" -> app:tickVisibilityMode="hidden"

pubiqq avatar Aug 08 '22 15:08 pubiqq

No problem. Thanks a lot!

pubiqq avatar Sep 29 '22 16:09 pubiqq

Sorry for the delay. I'm working on this now. : )

drchen avatar Nov 17 '22 21:11 drchen

I'm running into very weird issues when trying to merge the PR. Somehow the change blocks the argument validation from being done when running unit tests.

I don't really have time to debug it yet. If you can help check that on your end it will also be very helpful.

drchen avatar Dec 12 '22 15:12 drchen

Checked, fixed, and rebased.

pubiqq avatar Dec 13 '22 16:12 pubiqq

Hey thanks for bumping this!! Sorry I missed your fix during my vacation.

Sending this for internal review now.

drchen avatar Apr 27 '23 21:04 drchen

No problem. Feel free to review my other open PRs as well.

pubiqq avatar Apr 27 '23 21:04 pubiqq

Hi, during the internal review, people raised that we are not sure what is the use scenario of autoHide mode?

Do you have an example of that?

drchen avatar May 02 '23 17:05 drchen

Do you have an example of that?

https://github.com/material-components/material-components-android/issues/1233

As for me, I don't like the current default behavior either, because in the "dense" case ticks stop pointing to the position you can drag the slider to.

pubiqq avatar May 02 '23 18:05 pubiqq

Dan, can you provide some insights here? I think the latest conversation we had regarding this is we probably need designers' opinion. ^^;

drchen avatar Mar 14 '24 16:03 drchen

Just in case, I want to make it clear that this PR doesn't change the default behavior of the slider, but only adds two new strategies - autoHide (reason #1, reason #2) and visibleAll (I know this approach is not recommended by M3 specs, it's added mostly for symmetry with hidden).

pubiqq avatar Mar 14 '24 17:03 pubiqq

@drchen any update on this? I talked with our designers and they are not keen on adding this change, especially visibleAll, maybe removing it would be better.

paulfthomas avatar Apr 11 '24 15:04 paulfthomas

If you want, I can delete visibleAll. I already explained why it was added, but I don't need it either and I don't insist on keeping it.

However, the autoHide should remain, that's what this PR was created for (explanation). Moreover, I believe the new behavior should be made the default one because the current behavior is not just illogical and confusing but directly contradicts the description of stop indicators.

pubiqq avatar Apr 11 '24 17:04 pubiqq

Bump

pubiqq avatar Apr 23 '24 12:04 pubiqq