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

Allow independent theming of Persistent and Modal bottom sheets Background Color #39333

Merged
merged 6 commits into from Sep 6, 2019

Conversation

lisa-liao
Copy link
Contributor

Description

BottomSheetThemeData has an additional field modalBackgroundColor which makes it possible to set different background colors between persistent and modal bottom sheets.

Tests

I added the following tests:

  • Test for the theme prioritizing modalBackgroundColor, if specified, over backgroundColor

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • 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.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 27, 2019
Copy link
Contributor

@johnsonmh johnsonmh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@willlarche willlarche left a comment

Choose a reason for hiding this comment

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

Thank you!!!

/// Value for [BottomSheet.backgroundColor] when the Bottom sheet is presented
/// as a modal bottom sheet.
///
/// If null, [BottomSheet.backgroundColor] defaults to [backgroundColor].
Copy link
Contributor

Choose a reason for hiding this comment

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

The defaulting rules for modal bottom sheets shouldn't be documented here. And line 464 in bottom_sheet.dart doesn't default to the theme's backgroundColor when modalBackgroundColor is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -141,12 +141,16 @@ void main() {
expect(material.clipBehavior, clipBehavior);
});

testWidgets('BottomSheetThemeData.modalElevation takes priority over BottomSheetThemeData.elevation for modal bottom sheets', (WidgetTester tester) async {
testWidgets('Modal bottom sheet-specific parameters take priority over general bottom sheet parameters for modal bottom sheets', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the title is accurate then we should be verifying that a modal bottom sheet's background and elevation are defined by the bottom sheet theme's background and elevation properties when modalElevation and modalBackgroundColor are null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -461,7 +461,7 @@ Future<T> showModalBottomSheet<T>({
theme: Theme.of(context, shadowThemeOnly: true),
isScrollControlled: isScrollControlled,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
backgroundColor: backgroundColor,
backgroundColor: backgroundColor ?? Theme.of(context).bottomSheetTheme.modalBackgroundColor,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be:

 backgroundColor ?? Theme.of(context).bottomSheetTheme.modalBackgroundColor ?? Theme.of(context).bottomSheetTheme.backgroundColor;

It would be best to allow Theme.of(context).bottomSheetTheme to be null and to cache the value, so:

final BottomSheetThemeData theme = Theme.of(context).bottomSheetTheme;

backgroundColor: backgroundColor ?? theme?.modalBackgroundColor ?? theme?.backgroundColor;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 good however it looks like showBottomSheet doesn't document the elevation or color parameters?

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.

LGTM

@@ -427,6 +427,10 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
/// that a modal [BottomSheet] needs to be displayed above all other content
/// but the caller is inside another [Navigator].
///
/// The optional [backgroundColor], [elevation], [shape], and [clipBehavior]
/// parameters can be passed in to customize the appearance and behavior of
/// persistent bottom sheets.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're referring to modal bottom sheets here

@rami-a rami-a merged commit 8b90d9d into flutter:master Sep 6, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 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.

None yet

8 participants