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

Apply media bottom padding in BottomNavigationBar #13431

Merged
merged 1 commit into from
Dec 8, 2017

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented Dec 7, 2017

Updates scaffold to expose bottom padding to the associated
BottonNavigationBar (if present). BottomNavigationBar is now responsible
for adjusting itself to account for bottom padding.

This change is necessary to support the updated BottomNavigationBar
layout for the iPhone X.

Fixes #12099 once the associated engine roll lands.

@@ -930,6 +933,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
removeLeftPadding: false,
removeTopPadding: true,
removeRightPadding: false,
removeBottomPadding: false,
Copy link
Member

Choose a reason for hiding this comment

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

bah, github doesn't let me comment on unchanged lines. You'd want to remove the bottom padding from the body now no? Since it's 'consumed'.

Copy link
Member Author

@cbracken cbracken Dec 7, 2017

Choose a reason for hiding this comment

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

The body already does remove the bottom padding if necessary (line 861). Bottom padding removal is defaulted to widget.resizeToAvoidBottomPadding in _addIfNonNull() (lines 812-833).

Once we've moved fully to viewInsets on the engine side that'll go away and, I'll make that a @required param to make the call sites clearer.

Copy link
Member

Choose a reason for hiding this comment

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

If in the ultimate future, resizeToAvoidBottomPadding is gone, don't we still need to explicitly set removebottompadding to true if bottom tab bar != null?

Copy link
Member Author

@cbracken cbracken Dec 7, 2017

Choose a reason for hiding this comment

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

In the future, the padding is the safe area padding so we don't want to remove it, we want the nav bar to adapt itself for the additional padding.

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 in #13437

@@ -436,6 +436,8 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
@override
Widget build(BuildContext context) {
assert(debugCheckHasDirectionality(context));

final double bottomPadding = math.max(MediaQuery.of(context).padding.bottom - _kBottomMargin, 0.0);
Copy link
Member Author

@cbracken cbracken Dec 7, 2017

Choose a reason for hiding this comment

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

FWIW: not entirely thrilled with this. An alternative would be to deal with this in the individual item widgets where we deal with bottom margin. It's not much less convoluted to do it in those two places though, and applying it as a const bottom padding results in an easier-to-follow tree. Ideas welcome :)

Copy link
Member

Choose a reason for hiding this comment

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

I think consolidating here is fine. Though some comment / const renaming might help future readers. Something like we only need to shift up if the partial obstruction may intersect with interactive parts of this widget, liberally generalized by this const (feel free to do all this in a different PR).

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the 2 names needs some additional differentiation too. They're both called bottom padding which is a bit confusing when one is a outer container padding and one is an inner layout padding.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I'll update the names.

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.

);

const double labelBottomMargin = 8.0; // _kBottomMargin in implementation.
const double additionalPadding = 40.0 - labelBottomMargin;
Copy link
Member

@xster xster Dec 7, 2017

Choose a reason for hiding this comment

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

<not a real comment>Ha, you even called this 'additional' padding here :)</>

Copy link
Member Author

Choose a reason for hiding this comment

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

Stole the name and used it in place of bottomPadding internally.

@xster
Copy link
Member

xster commented Dec 7, 2017

LGTM, feel free to respond/address everything in a separate PR if this unblocks you

@cbracken
Copy link
Member Author

cbracken commented Dec 8, 2017

Switching over to viewInsets and making removeBottomPadding required done in #13437.

Updates scaffold to expose bottom padding to the associated
BottonNavigationBar (if present). BottomNavigationBar is now responsible
for adjusting itself to account for bottom padding.

This change is necessary to support the updated BottomNavigationBar
layout for the iPhone X.
@cbracken cbracken merged commit 276cbb1 into flutter:master Dec 8, 2017
@cbracken cbracken deleted the iphone_x-bottom-nav-bar branch December 8, 2017 02:15
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
Updates scaffold to expose bottom padding to the associated
BottonNavigationBar (if present). BottomNavigationBar is now responsible
for adjusting itself to account for bottom padding.

This change is necessary to support the updated BottomNavigationBar
layout for the iPhone X.
@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.

iPhone X: Additional bottom padding for BottomNavigationBar
3 participants