Commit 55f48f72 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Persistent bottom sheet should not overlap app bar (#6076)

The spec forbids persistent bottom sheets from overlapping the app bar. There
are also some fancy scroll-linked effects that we're supposed to do with
persistent bottom sheets, but those will need to wait for another patch.

Fixes #5143
parent 16305ad5
......@@ -120,7 +120,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
Size snackBarSize = Size.zero;
if (hasChild(_ScaffoldSlot.bottomSheet)) {
bottomSheetSize = layoutChild(_ScaffoldSlot.bottomSheet, fullWidthConstraints);
bottomSheetSize = layoutChild(_ScaffoldSlot.bottomSheet, fullWidthConstraints.copyWith(maxHeight: contentBottom - contentTop));
positionChild(_ScaffoldSlot.bottomSheet, new Offset((size.width - bottomSheetSize.width) / 2.0, bottom - bottomSheetSize.height));
}
......
......@@ -196,4 +196,46 @@ void main() {
await tester.pump(new Duration(seconds: 1));
expect(scrollableKey.currentState.scrollOffset, equals(500.0));
});
testWidgets('Bottom sheet cannot overlap app bar', (WidgetTester tester) async {
Key sheetKey = new UniqueKey();
await tester.pumpWidget(
new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.android),
home: new Scaffold(
appBar: new AppBar(
title: new Text('Title')
),
body: new Builder(
builder: (BuildContext context) {
return new GestureDetector(
onTap: () {
Scaffold.of(context).showBottomSheet((BuildContext context) {
return new Container(
key: sheetKey,
decoration: new BoxDecoration(backgroundColor: Colors.blue[500])
);
});
},
child: new Text('X')
);
}
)
)
)
);
await tester.tap(find.text('X'));
await tester.pump(); // start animation
await tester.pump(const Duration(seconds: 1));
RenderBox appBarBox = tester.renderObject(find.byType(AppBar));
RenderBox sheetBox = tester.renderObject(find.byKey(sheetKey));
Point appBarBottomRight = appBarBox.localToGlobal(appBarBox.size.bottomRight(Point.origin));
Point sheetTopRight = sheetBox.localToGlobal(sheetBox.size.topRight(Point.origin));
expect(appBarBottomRight, equals(sheetTopRight));
});
}
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