Skip to content

Let translucent Cupertino bars have its scaffold children automatically pad their heights#13194

Merged
xster merged 4 commits intoflutter:masterfrom
xster:simple-sliver-padding
Nov 30, 2017
Merged

Let translucent Cupertino bars have its scaffold children automatically pad their heights#13194
xster merged 4 commits intoflutter:masterfrom
xster:simple-sliver-padding

Conversation

@xster
Copy link
Member

@xster xster commented Nov 24, 2017

#12913

  • Remove manual padding to account for obstructed area
  • Obstructed areas are signaled to scaffold children via MediaQuery
  • List/GridViews automatically consume and sliver pad MediaQuery in main axis direction

@cbracken, these are the semantic 'paddings' we talked about. Let me know if you rename them.

Next PR: #12912, use actual layout dimensions instead of self reported dimensions.

…ent nav and tab bars leave behind media query paddings in scaffolds.
@xster xster requested a review from cbracken November 24, 2017 02:50
@xster xster changed the title Let translucent Cupertino bars have its scaffold children automatically pad it Let translucent Cupertino bars have its scaffold children automatically pad their heights Nov 24, 2017
@xster xster force-pushed the simple-sliver-padding branch from a18b8e7 to 4b42a55 Compare November 24, 2017 03:13
/// Widget that fits in [CupertinoPageScaffold.navigationBar].
///
/// Must report its preferred size and whether it's opaque or translucent.
abstract class BaseCupertinoNavigationBar extends PreferredSizeWidget {
Copy link
Member

Choose a reason for hiding this comment

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

It'd be really nice to avoid this. It feels specific enough that I can't think of a great generalised class name. It would be nice to avoid tying it too closely to CupertinoNavigationBar and instead tie it to the underlying behaviour that it represents -- are we completely hiding what's below (in which case padding is applied one way) or not, in which case it's applied another.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@cbracken
Copy link
Member

LGTM for the behaviour -- discussed class naming a bit offline.

@xster
Copy link
Member Author

xster commented Nov 30, 2017

Time sensitive, submitting before flutter_tools test on mac finishes. Should be ok.

@xster xster merged commit 5c4ffa1 into flutter:master Nov 30, 2017
@xster xster deleted the simple-sliver-padding branch November 30, 2017 21:55
@xster
Copy link
Member Author

xster commented Nov 30, 2017

Last test completed

/// The scaffold assumes the nav bar will consume the [MediaQuery] top padding.
// TODO(xster): document its page transition animation when ready
final PreferredSizeWidget navigationBar;
final ObstructingPreferredSizeWidget navigationBar;
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 a breaking change, please make sure to announce changes like this on flutter-dev.

removeTop: true,
final MediaQueryData existingMediaQuery = MediaQuery.of(context);

// TODO(https://github.com/flutter/flutter/issues/12912):
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax is TODO(username): message, url

}

/// Widget that has a preferred size and reports whether it fully obstructs
/// widgets behind it.
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a lot more documentation here. imagine someone has never heard of this widget and they want to know why it exists, why to use it, how to use it (both on the implementing side and the consuming side), etc.

///
/// Content can slide under the [tabBar] when it's translucent.
/// Content can slide under the [tabBar] when it's translucent with a
/// [MediaQuery] padding hinting the bottom obstructed area.
Copy link
Contributor

Choose a reason for hiding this comment

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

hinting?

if (widget.tabBar != null) {
final MediaQueryData existingMediaQuery = MediaQuery.of(context);

// TODO(https://github.com/flutter/flutter/issues/12912):
Copy link
Contributor

Choose a reason for hiding this comment

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

todo syntax

final EdgeInsets mediaQueryVerticalPadding =
mediaQuery.padding.copyWith(left: 0.0, right: 0.0);
// Consume the main axis padding with SliverPadding.
effectivePadding = scrollDirection == Axis.vertical
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this just throw away the padding the user specified?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, i see, you only do this if padding is null. never mind.

@xster
Copy link
Member Author

xster commented Dec 1, 2017

Thanks for reviewing. Follow-ups in #13310

@tvolkert
Copy link
Contributor

tvolkert commented Dec 2, 2017

This has been identified as the culprit of test failures for internal Google customers and is blocking an internal roll of Flutter. See bug #70050180

@xster
Copy link
Member Author

xster commented Dec 2, 2017

Reverting. A global non-disable-able auto handling isn't flexible enough. There's a gap now for the list in the gallery's drawer demo.

xster added a commit to xster/flutter that referenced this pull request Dec 2, 2017
tvolkert pushed a commit that referenced this pull request Dec 2, 2017
@xster xster mentioned this pull request Dec 5, 2017
xster added a commit to xster/flutter that referenced this pull request Dec 8, 2017
…ly pad their heights (flutter#13194)

* Let lists automatically add sliver padding from media query. Translucent nav and tab bars leave behind media query paddings in scaffolds.

* tests

* const lint

* Rename base abstract class to generalized ObstructingPreferredSizeWidget
xster added a commit that referenced this pull request Dec 8, 2017
…ly pad their heights - second try (#13440)

* Let translucent Cupertino bars have its scaffold children automatically pad their heights (#13194)

* Let lists automatically add sliver padding from media query. Translucent nav and tab bars leave behind media query paddings in scaffolds.

* tests

* const lint

* Rename base abstract class to generalized ObstructingPreferredSizeWidget

* review

* More docs and comments from #13317
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
…ly pad their heights (flutter#13194)

* Let lists automatically add sliver padding from media query. Translucent nav and tab bars leave behind media query paddings in scaffolds.

* tests

* const lint

* Rename base abstract class to generalized ObstructingPreferredSizeWidget
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
…ly pad their heights - second try (flutter#13440)

* Let translucent Cupertino bars have its scaffold children automatically pad their heights (flutter#13194)

* Let lists automatically add sliver padding from media query. Translucent nav and tab bars leave behind media query paddings in scaffolds.

* tests

* const lint

* Rename base abstract class to generalized ObstructingPreferredSizeWidget

* review

* More docs and comments from flutter#13317
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants