Unverified Commit 71021b47 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Use greater of viewInsets, padding for Scaffold bottom padding (#13423)

Scaffold bottom padding now applies the maximum of window
viewInsets.bottom (typically used for iOS safe areas) and padding.bottom
(typically used for keyboard height).
parent 5f7ef896
...@@ -834,6 +834,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -834,6 +834,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasDirectionality(context)); assert(debugCheckHasDirectionality(context));
final EdgeInsets padding = MediaQuery.of(context).padding; final EdgeInsets padding = MediaQuery.of(context).padding;
final EdgeInsets viewInsets = MediaQuery.of(context).viewInsets;
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextDirection textDirection = Directionality.of(context); final TextDirection textDirection = Directionality.of(context);
...@@ -1038,7 +1039,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -1038,7 +1039,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
children: children, children: children,
delegate: new _ScaffoldLayout( delegate: new _ScaffoldLayout(
statusBarHeight: padding.top, statusBarHeight: padding.top,
bottomPadding: widget.resizeToAvoidBottomPadding ? padding.bottom : 0.0, bottomPadding: widget.resizeToAvoidBottomPadding ? math.max(padding.bottom, viewInsets.bottom) : 0.0,
endPadding: endPadding, endPadding: endPadding,
textDirection: textDirection, textDirection: textDirection,
), ),
...@@ -1157,4 +1158,4 @@ class _ScaffoldScope extends InheritedWidget { ...@@ -1157,4 +1158,4 @@ class _ScaffoldScope extends InheritedWidget {
bool updateShouldNotify(_ScaffoldScope oldWidget) { bool updateShouldNotify(_ScaffoldScope oldWidget) {
return hasDrawer != oldWidget.hasDrawer; return hasDrawer != oldWidget.hasDrawer;
} }
} }
\ No newline at end of file
...@@ -59,6 +59,41 @@ void main() { ...@@ -59,6 +59,41 @@ void main() {
expect(bodyBox.size, equals(const Size(800.0, 544.0))); expect(bodyBox.size, equals(const Size(800.0, 544.0)));
}); });
testWidgets('Scaffold bottom padding is the greater of window padding or view inset', (WidgetTester tester) async {
final Key bodyKey = new UniqueKey();
await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.only(bottom: 50.0),
viewInsets: const EdgeInsets.only(bottom: 100.0),
),
child: new Scaffold(
body: new Container(key: bodyKey),
),
),
));
final RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
expect(bodyBox.size, equals(const Size(800.0, 500.0)));
await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.only(bottom: 200.0),
viewInsets: const EdgeInsets.only(bottom: 100.0),
),
child: new Scaffold(
body: new Container(key: bodyKey),
),
),
));
expect(bodyBox.size, equals(const Size(800.0, 400.0)));
});
testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async { testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async {
final Key bodyKey = new UniqueKey(); final Key bodyKey = new UniqueKey();
await tester.pumpWidget(new Directionality( await tester.pumpWidget(new Directionality(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment