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

Migrate IconButton to Material 3 - Part 2 #106437

Merged

Conversation

QuncCccccc
Copy link
Contributor

@QuncCccccc QuncCccccc commented Jun 22, 2022

resolves #103528

Screen Shot 2022-06-22 at 12 26 16 PM

Screen Shot 2022-06-22 at 12 27 09 PM

This PR is the second part of the IconButton migration. In this PR, a IconButton can be turned into a "toggle button" by using isSelected parameter.

The boolean isSelected is a new parameter in IconButton class. The button will be non-toggle button by default if isSelected is not set; otherwise, the button will show the selection state based on the value of isSelected.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels. labels Jun 22, 2022
@QuncCccccc QuncCccccc changed the title Migrate IconButton to Material 3 - Part 2 Migrate IconButton to Material 3 - Part 2 Jun 22, 2022
@QuncCccccc QuncCccccc force-pushed the migrate_icon_button_to_toggle_button branch from 1fb49cc to b14a273 Compare June 22, 2022 20:44
@QuncCccccc QuncCccccc marked this pull request as ready for review June 22, 2022 21:43
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good. Nice work.

I have some comments and questions below.

Comment on lines +22 to +25
// Desktop and web platforms have a compact visual density by default.
// To see buttons with circular background on desktop/web, the "visualDensity"
// needs to be set to "VisualDensity.standard".
visualDensity: VisualDensity.standard,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for this PR, but thinking more about this, perhaps we should have the IconButton override the density that is used by ButtonStyledButton to always use standard, as I am not sure it makes sense to apply density to icon buttons. We should talk with @gspencergoog about this.

Comment on lines 32 to 35
StandardIconButtons(),
FilledIconButtons(),
FilledTonalIconButtons(),
OutlinedIconButtons(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of common code for each of these button types. In fact it looks like the only difference is the ButtonStyle. Perhaps it would be simpler to have a single DemoIconToggleButton class that you pass in different ButtonStyles to instead of multiple classes doing the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks for the suggestion! I added the change. Please let me know if there's any questions:)

examples/api/lib/material/icon_button/icon_button.3.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/icon_button.dart Outdated Show resolved Hide resolved
examples/api/lib/material/icon_button/icon_button.3.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/icon_button.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/icon_button.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/icon_button.dart Outdated Show resolved Hide resolved
packages/flutter/test/material/icon_button_test.dart Outdated Show resolved Hide resolved
@QuncCccccc QuncCccccc force-pushed the migrate_icon_button_to_toggle_button branch from b14a273 to 92b0d01 Compare June 28, 2022 05:42
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work. Just a minor doc update below. Thx.

packages/flutter/lib/src/material/icon_button.dart Outdated Show resolved Hide resolved
@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 1, 2022
@QuncCccccc QuncCccccc force-pushed the migrate_icon_button_to_toggle_button branch from c7d455c to 63b3be9 Compare July 6, 2022 16:54
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 6, 2022

  • The status or check suite tree status luci-flutter has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 6, 2022
@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 6, 2022
@auto-submit auto-submit bot merged commit 16bbef1 into flutter:master Jul 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jul 7, 2022
camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update IconButton to support Material 3
2 participants