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

Added TabBar.splashFactory, TabBarTheme.splashFactory,overlayColor #96252

Merged
merged 3 commits into from
Jan 14, 2022

Conversation

HansMuller
Copy link
Contributor

Adds a splashFactory property to TabBar and adds splashFactory and overlayColor properties to TabBarTheme.

This enables defeating ink splashes by specifying splashFactory: NoSplash.splashFactory. The overlay color can be now be overridden for the pressed state, as well as the hovered and focused states (as before). For example, to create a TabBar that does not draw ink splashes, and only draws the default focused state highlight:

TabBar(
  splashFactory: NoSplash.splashFactory,
  overlayColor: MaterialStateProperty.resolveWith<Color?>(
    (Set<MaterialState> states) {
      // Use the default focused overlay color
      return states.contains(MaterialState.focused) ? null : Colors.transparent;
    }
  ),
  ...
)

Fixes #86661

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jan 6, 2022
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

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.

Nice. LGTM.



@immutable
class _LerpColors implements MaterialStateProperty<Color?> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I wonder if this might make a good candidate for a static function on MaterialStateProperty that could be used with any type.

@@ -54,6 +54,21 @@ RenderParagraph _iconRenderObject(WidgetTester tester, IconData icon) {
}

void main() {
test('TabBarTheme copyWith, ==, hashCode, defaults', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Funny that we didn't have this test already.

@HansMuller
Copy link
Contributor Author

HansMuller commented Jan 10, 2022

This PR failed a couple of internal tests that had configured InkWell.overlayColor with a MaterialStateProperty<Color> whose resolution depended on MaterialState.pressed. Previously this distinction was ignored and now it isn't. This caused a few golden image tests for widgets in the pressed state to fail.

Will break out the InkWell changes into a separate PR.

@pstromberg98
Copy link
Contributor

pstromberg98 commented Jan 10, 2022

@HansMuller I'm not super familiar with the material design spec but the PR looks good to me!

I thought I'd mention that setting the highlightColor to transparent in the nearest Theme ancestor seems to work. I'm surprised I didn't try that or if I was building with an older version of Flutter, I'm not sure. That being said I still think it makes more sense to utilize the MaterialStateProperty.pressed so I am still behind this PR!

@HansMuller HansMuller merged commit bbc68cd into flutter:master Jan 14, 2022
@HansMuller HansMuller deleted the tab_bar_splash_factory branch January 14, 2022 19:53
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jan 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jan 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jan 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to disable InkWell behavior in TabBar tabs
3 participants