Skip to content
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

Introduce ButtonStyle equivalent customisation for Slider and RangeSlider #126068

Open
2 tasks done
TahaTesser opened this issue May 4, 2023 · 5 comments
Open
2 tasks done
Labels
c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@TahaTesser
Copy link
Member

TahaTesser commented May 4, 2023

Is there an existing issue for this?

Use case

Customizing Slider and RangeSlider should be as easy as customizing buttons. Currently customizing Slider and RangeSlider is complex and messy.

Right now just to customize the border radius of the slider components such as track or value indicator you need to copy the source code for that component and modify its radius. We don't do this for any other widget.

Some slider components have radius customization but others don't. it'd be better to have consistent customization as we have for different material buttons.

this.overlayShape,
this.tickMarkShape,
this.thumbShape,
this.trackShape,
this.valueIndicatorShape,
this.rangeTickMarkShape,
this.rangeThumbShape,
this.rangeTrackShape,
this.rangeValueIndicatorShape,

There are separate active, inactive, and disabled colors to be provided. These should be using material states.

this.activeTrackColor,
this.inactiveTrackColor,
this.secondaryActiveTrackColor,
this.disabledActiveTrackColor,
this.disabledInactiveTrackColor,
this.disabledSecondaryActiveTrackColor,
this.activeTickMarkColor,
this.inactiveTickMarkColor,
this.disabledActiveTickMarkColor,
this.disabledInactiveTickMarkColor,

slider_theme.dart:

  1. A lot of component code is repeated with only slight variation.
  2. Default component values are hard coded and not available in a single config class.
  3. Many components aren't customizable and require copying the source code for minor and major customizable.

Proposal

  • Introduce a ButtonStyle equivalent customization class for Slider and RangeSlider
  • Add something similar to ButtonStyle.from when you want to just customize default components such as radius, size, elevation, etc.
  • Regular style class to take entire custom shape components like the current SliderThemeData.
  • Add material state support track color, mark color, and value indicator color.
  • Make it as simple as possible to customize any default components of Slider and RangeSlider while keeping the ability to provide your own custom shapes.

I will implement this as part of #125329

@TahaTesser
Copy link
Member Author

cc: @HansMuller @Piinks
Any feedback would be appreciated.

@TahaTesser TahaTesser added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 4, 2023
@TahaTesser TahaTesser self-assigned this May 4, 2023
@TahaTesser TahaTesser added the c: proposal A detailed proposal for a change to Flutter label May 4, 2023
@Piinks
Copy link
Contributor

Piinks commented May 4, 2023

Would this mean eventually deprecating and removing the properties above?
I think this is a good idea, @HansMuller and @guidezpl may have some material specific thoughts though. :)

@HansMuller
Copy link
Contributor

HansMuller commented May 4, 2023

I think this is a nice idea. It will require some careful planning. A design doc would be helpful.

I agree with @Piinks about deprecating old redundant API however I don't think we want to introduce changes that cannot be flutter fixed (i.e. that can't be migrated automatically), even if that means leaving some of the old API behind. In that sense this would be unlike the migration to the ButtonStyle et al. API.

@guidezpl
Copy link
Member

guidezpl commented May 4, 2023

I think this is a nice idea. It will require some careful planning. A design doc would be helpful.

I agree with @Piinks about deprecating old redundant API however I don't think we want to introduce changes that cannot be flutter fixed (i.e. that can't be migrated automatically), even if that means leaving some of the old API behind. In that sense this would be unlike the migration to the ButtonStyle et al. API.

+1

@TahaTesser
Copy link
Member Author

I think this is a nice idea. It will require some careful planning. A design doc would be helpful.

Thank you! I'm definitely going to create a design doc.

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@TahaTesser TahaTesser removed their assignment Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

No branches or pull requests

5 participants