Skip to content

added scrimColor property in Scaffold widget#31025

Merged
HansMuller merged 14 commits intoflutter:masterfrom
diegoveloper:scrim_color_scaffold
May 1, 2019
Merged

added scrimColor property in Scaffold widget#31025
HansMuller merged 14 commits intoflutter:masterfrom
diegoveloper:scrim_color_scaffold

Conversation

@diegoveloper
Copy link
Member

@diegoveloper diegoveloper commented Apr 14, 2019

Description

Based on this issue reported in StackOverflow: https://stackoverflow.com/questions/55669516/flutter-change-color-of-drawer-scrim, it is necessary to have the option to change the background color when we use the Drawer.

In Android we have the option to do it using this method https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html#setScrimColor(int)
Reviewing the source code of Scaffold and Drawer, I see that the color black54 was used by default with no option to change it.

With this change the color and also kept the black54 by default in case no value is entered.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

@ghost ghost added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 15, 2019
Copy link
Contributor

@rami-a rami-a left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, this looks great! Please take a look at and address my comments when you've got a chance.

Copy link
Contributor

@rami-a rami-a left a comment

Choose a reason for hiding this comment

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

Just a couple more minor comments on your test, thanks!

Additionally, please fix the analyzer errors, looks like the error is:

Whitespace detected at the end of source code lines.

@rami-a
Copy link
Contributor

rami-a commented Apr 26, 2019

Looks like the analyzer job is still failing:

packages/flutter/lib/src/material/drawer.dart:225:  /// 
packages/flutter/lib/src/material/scaffold.dart:988:  /// 

White space in those 2 files on those lines. I think you just want to make sure there's no whitespace after the ///

@diegoveloper
Copy link
Member Author

updated now! done

Copy link
Contributor

@rami-a rami-a left a comment

Choose a reason for hiding this comment

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

Awesome, looks good to me! Passing it off to @HansMuller for a final look

@rami-a rami-a requested a review from HansMuller April 26, 2019 21:29
@rami-a
Copy link
Contributor

rami-a commented Apr 29, 2019

Hey @diegoveloper it looks like some tests are failing drawer_test. You can see more details in the full logs on cirrus. Could you please run these tests locally and see if you can diagnose the problem. Thanks!

@diegoveloper
Copy link
Member Author

diegoveloper commented Apr 29, 2019

@rami-a I see the test failing is the material/scaffold_test.dart this test specifically 'Dual Drawer Opening'.

I fixed the test, I found a bug in the change I made when there is no Color to drawerScrimColor , I had to add the default value inside Scaffold instead of DrawerController

@override
void initState() {
super.initState();
_color = ColorTween(begin: Colors.transparent, end: widget.scrimColor);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you still want to keep a default color for widget.scrimColor, since the tween expects both arguments to not be null.

Copy link
Member Author

Choose a reason for hiding this comment

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

you are right, done!

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 good. We're not asserting that scrimColor (et al) are non-null everywhere, which is OK. It would be a little simpler to let the scrimColor properties default to null and then in the one place where the color is needed, provide a default:

 _color = ColorTween(begin: Colors.transparent, end: widget.scrimColor ?? Colors.black54);

Other than that, I think we should be about ready to land this change.

});
}

Container _getContainerScaffold(WidgetTester tester) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need to factor this out. It could be a local function within the one test that needs it, or it could be just be inlined there.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay :), done

@HansMuller HansMuller merged commit d8bb880 into flutter:master May 1, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants