flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.72k stars 27.37k forks source link

Allow `Slider` to be "slide only" like YouTube mobile progress bar #113370

Closed liumcse closed 1 year ago

liumcse commented 2 years ago

Use case

I would like to request a feature on the Slider widget where you can configure it to be "slide only", so that users can only change the value by tap-and-drag. If users just tap anywhere without dragging, it's no-op.

It's similar to the progress bar on YouTube app, you tap anywhere on the progress bar it won't change the video position - you have to slide. Here's a recording to YouTube's sliding behavior: https://drive.google.com/file/d/1kYEIxFB02E-avJCYsk5KWUPtANqzP_C_/view?usp=share_link

Proposal

/// Option 1: A boolean parameter
Slider(
  slideOnly: true
);

/// Option 2: An enum for interaction style
Slider(
  interactionStyle: SliderInteractionStyle.DRAG_ONLY;
);

enum SliderInteractionStyle {
  DEFAULT,
  DRAG_ONLY,
  // ...
}
Piinks commented 2 years ago

This might be good to have as an enum, specifying what kind of slider interaction is permissible.

Piinks commented 1 year ago

Hey @werainkhatri! Great to see you again. Thanks for picking this up. :)

liumcse commented 1 year ago

Thank you @werainkhatri for picking this up! I've updated the issue to include a recording. Thank you!

werainkhatri commented 1 year ago

Thanks for picking this up. :)

new API features have kinda become my choice of issue to pick. sorry for delaying this tho, wasn't able to make time for writing a design doc as there are many ways to approach the issue while trying to code it up.

I've updated the issue to include a recording

thanks, that was very helpful!

finally, i have written one, please check it out and comment any questions / suggestions / feedback on the content / structure. TIA.

Design Doc link: https://flutter.dev/go/permissible-slider-interaction

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.