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

Update segmented buttons to support Material 3 #103529

Closed
Tracked by #91605
darrenaustin opened this issue May 11, 2022 · 10 comments · Fixed by #113723
Closed
Tracked by #91605

Update segmented buttons to support Material 3 #103529

darrenaustin opened this issue May 11, 2022 · 10 comments · Fixed by #113723
Assignees
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@darrenaustin
Copy link
Contributor

As part of the Material 3 specification there are updates to the Segmented Button visuals:

Screen Shot 2022-05-11 at 1 09 18 PM

The Flutter Material library currently has a ToggleButtons class that we should either update to support Material 3 or build a new widget if they are not close enough in functionality.

@darrenaustin darrenaustin added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 11, 2022
@bernaferrari
Copy link
Contributor

It would be nice if the API aligned with the Cupertino segmented control, it looks probably more similar than ToggleButtons.

@guidezpl guidezpl changed the title Update Segmented Buttons to support Material 3 Update segmented buttons to support Material 3 May 24, 2022
@TahaTesser TahaTesser self-assigned this Jun 8, 2022
@rydmike
Copy link
Contributor

rydmike commented Jun 9, 2022

Probably better to build a new widget, can then also improve its API and features, plus name align it with the M3 name too.

ToggleButtons have some limitations, like does not implement VisualDensity and it is based on RawMaterialButton. Then add oddities like the border is drawn outside its content height/width constraints. It can be themed fairly close the SegmentedButtons look, but not quite.

@TahaTesser TahaTesser added this to To do in Nevercode via automation Jun 16, 2022
@TahaTesser TahaTesser moved this from To do to In progress in Nevercode Jun 16, 2022
@TahaTesser
Copy link
Member

TahaTesser commented Jun 16, 2022

cc: @rydmike

Thanks for the feedback!

ToggleButtons have some limitations, like does not implement VisualDensity

This looks to be true.

and it is based on RawMaterialButton.

ToggleButtons no longer contain RawMaterialButton. (I've replaced it in #101760)

Then add oddities like the border is drawn outside its content height/width constraints. It can be themed fairly close the SegmentedButtons look, but not quite.

Investigating this.

@TahaTesser
Copy link
Member

TahaTesser commented Jul 13, 2022

cc: @rydmike @darrenaustin @HansMuller

After reading Segmented buttons specs and some native Android testing.

  • In terms of functionality, there is no change. The single and multi-select functionality exist in both M2 and M3 versions
    (there is a check to toggle between only single and only multi-select in the specs, we can easily introduce this toggle if needed)
  • There is a new optional check icon to indicate the selected state.
  • Layout height is a little taller.
  • Slight default shape change and minor typography changes.

Aside from minor improvements stated in #103529 (comment) which are already required addressing in M2 ToggleButtons, there is no significant difference.

I will defer to other team members for the widget name update. (In my testing I noticed even Android API doesn't have an updated name for SegementedButtons, it simply refers to MaterialButtonToggleGroup with different style attributes for M2 and M3).

We also didn't introduce newly named widgets for regular buttons, for instance Filled or Filled Tonal, see Material 3 button types

@bernaferrari
Copy link
Contributor

Yes, there is FilledButton now. #107382

@TahaTesser
Copy link
Member

Yes, there is FilledButton now. #107382

Oh nice, didn't know. It makes sense it needed some styling to achieve the FilledButton appearance
Screenshot 2022-07-13 at 17 08 42

but this is not the case for ToggleButtons, migration will be based on tokens and won't need any custom style to get SegmentedButtons appearance and functionality is the same.

@darrenaustin
Copy link
Contributor Author

After looking more closely at this, I think we should create a new SegmentedButton API that combines the best of the ToggleButton and CupertinoSegmentedControl APIs. It would of course be driven by M3 tokens by default, but would hopefully be configurable enough to be able to pull off Cupertino styles with just theme data. I have already started work on this, so if you don't mind @TahaTesser, I will assign this to myself.

@darrenaustin darrenaustin self-assigned this Sep 21, 2022
@TahaTesser TahaTesser removed their assignment Sep 21, 2022
@rydmike
Copy link
Contributor

rydmike commented Sep 21, 2022

Thanks @darrenaustin, I also think that is a good call. Looking forward to seeing the results! 👍🏻

@TahaTesser
Copy link
Member

TahaTesser commented Sep 21, 2022

@darrenaustin It sounds good! Definitely a bigger project, thanks for taking this.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
No open projects
Status: Done
Nevercode
  
In progress
Development

Successfully merging a pull request may close this issue.

4 participants