Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AppBar: Use MaterialType.transparency if background color is transpar… #102055

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

Closed
wants to merge 2 commits into from

Conversation

monkeyswarm
Copy link
Contributor

@monkeyswarm monkeyswarm commented Apr 18, 2022

…ent and elevation is zero

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.
#101248

If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].

Pre-launch Checklist

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

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 18, 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 (don't just cc him here, he won't see it! He's on Discord!).

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.

@google-cla
Copy link

google-cla bot commented Apr 18, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@551178611

This comment was marked as spam.

@monkeyswarm
Copy link
Contributor Author

@goderbauer @HansMuller Please route to a reviewer, this is for internal customer 'june', thanks.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This looks OK to me.

@darrenaustin - does this mesh OK with the AppBar changes you're working on?

@HansMuller HansMuller requested a review from darrenaustin April 18, 2022 18:06
@monkeyswarm
Copy link
Contributor Author

PTAL @darrenaustin, thanks.

@HansMuller
Copy link
Contributor

Allowing events to pass through the AppBar seems reasonable in this case, although it's likely to be a subtle breaking change for extendBodyBehindAppBar: true apps that have configured their AppBar's backgroundColor and elevation this way. It would probably be better to expose this feature with a new AppBar property, so that apps could opt-in. Maybe expose this feature with hitTestBehavior valued property, like GestureDetector. Default would be HitTestBehavior.opaque.

Just FTR: Apparently the reason the setting the AppBar's Material.type to MaterialType.transparency works is that the Material widget's ink splash renderer (_RenderInkFeatures) uses the material type to define the value of hitTestSelf.

?? _defaultElevation;
// Sets MaterialType to 'transparency' if background color is transparent
// and elevation is zero.
final MaterialType materialType = backgroundColor == const Color(0x00000000) && elevation == 0.0
Copy link

Choose a reason for hiding this comment

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

what if the color is something like transparent blue (Colors.blue.withOpacity(0.0) for example)? does flutter/dart:ui already convert it to transparent black or would it be the actual color with 0 alpha/opacity? because if it's the latter then this check would potentially fail

@HansMuller
Copy link
Contributor

I'm going to close this because #102055 (comment). We should probably enable this feature, assuming that it needs enabling, with a new AppBar flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer: june 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.

5 participants