Unverified Commit f39a847c authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Apply media padding in UserAccountsDrawerHeader (#13619)

Applies top, left, right media padding to avoid placing content within
the safe area insets (e.g. iPhone X notch area in landscape
orientation).
parent f00c9023
...@@ -200,6 +200,8 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> { ...@@ -200,6 +200,8 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), ),
margin: widget.margin, margin: widget.margin,
child: new SafeArea(
bottom: false,
child: new Column( child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
...@@ -217,6 +219,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> { ...@@ -217,6 +219,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
), ),
], ],
), ),
),
); );
} }
} }
...@@ -14,7 +14,16 @@ void main() { ...@@ -14,7 +14,16 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material( home: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.only(
left: 10.0,
top: 20.0,
right: 30.0,
bottom: 40.0,
),
),
child: new Material(
child: new Center( child: new Center(
child: new UserAccountsDrawerHeader( child: new UserAccountsDrawerHeader(
currentAccountPicture: new CircleAvatar( currentAccountPicture: new CircleAvatar(
...@@ -43,6 +52,7 @@ void main() { ...@@ -43,6 +52,7 @@ void main() {
), ),
), ),
), ),
),
); );
expect(find.text('A'), findsOneWidget); expect(find.text('A'), findsOneWidget);
...@@ -62,8 +72,9 @@ void main() { ...@@ -62,8 +72,9 @@ void main() {
expect(box.size.width, equals(40.0)); expect(box.size.width, equals(40.0));
expect(box.size.height, equals(40.0)); expect(box.size.height, equals(40.0));
// Verify height = height + top padding + bottom margin + bottom edge)
box = tester.renderObject(find.byType(UserAccountsDrawerHeader)); box = tester.renderObject(find.byType(UserAccountsDrawerHeader));
expect(box.size.height, equals(160.0 + 8.0 + 1.0)); // height + bottom margin + bottom edge) expect(box.size.height, equals(160.0 + 20.0 + 8.0 + 1.0));
final Offset topLeft = tester.getTopLeft(find.byType(UserAccountsDrawerHeader)); final Offset topLeft = tester.getTopLeft(find.byType(UserAccountsDrawerHeader));
final Offset topRight = tester.getTopRight(find.byType(UserAccountsDrawerHeader)); final Offset topRight = tester.getTopRight(find.byType(UserAccountsDrawerHeader));
...@@ -72,10 +83,10 @@ void main() { ...@@ -72,10 +83,10 @@ void main() {
final Offset avatarDTopRight = tester.getTopRight(find.byKey(avatarD)); final Offset avatarDTopRight = tester.getTopRight(find.byKey(avatarD));
final Offset avatarCTopRight = tester.getTopRight(find.byKey(avatarC)); final Offset avatarCTopRight = tester.getTopRight(find.byKey(avatarC));
expect(avatarATopLeft.dx - topLeft.dx, equals(16.0)); expect(avatarATopLeft.dx - topLeft.dx, equals(16.0 + 10.0)); // left padding
expect(avatarATopLeft.dy - topLeft.dy, equals(16.0)); expect(avatarATopLeft.dy - topLeft.dy, equals(16.0 + 20.0)); // add top padding
expect(topRight.dx - avatarDTopRight.dx, equals(16.0)); expect(topRight.dx - avatarDTopRight.dx, equals(16.0 + 30.0)); // right padding
expect(avatarDTopRight.dy - topRight.dy, equals(16.0)); expect(avatarDTopRight.dy - topRight.dy, equals(16.0 + 20.0)); // add top padding
expect(avatarDTopRight.dx - avatarCTopRight.dx, equals(40.0 + 16.0)); // size + space between expect(avatarDTopRight.dx - avatarCTopRight.dx, equals(40.0 + 16.0)); // size + space between
}); });
......
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