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,22 +200,25 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> { ...@@ -200,22 +200,25 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), ),
margin: widget.margin, margin: widget.margin,
child: new Column( child: new SafeArea(
crossAxisAlignment: CrossAxisAlignment.stretch, bottom: false,
children: <Widget>[ child: new Column(
new Expanded( crossAxisAlignment: CrossAxisAlignment.stretch,
child: new _AccountPictures( children: <Widget>[
currentAccountPicture: widget.currentAccountPicture, new Expanded(
otherAccountsPictures: widget.otherAccountsPictures, child: new _AccountPictures(
) currentAccountPicture: widget.currentAccountPicture,
), otherAccountsPictures: widget.otherAccountsPictures,
new _AccountDetails( )
accountName: widget.accountName, ),
accountEmail: widget.accountEmail, new _AccountDetails(
isOpen: _isOpen, accountName: widget.accountName,
onTap: widget.onDetailsPressed == null ? null : _handleDetailsPressed, accountEmail: widget.accountEmail,
), isOpen: _isOpen,
], onTap: widget.onDetailsPressed == null ? null : _handleDetailsPressed,
),
],
),
), ),
); );
} }
......
...@@ -14,31 +14,41 @@ void main() { ...@@ -14,31 +14,41 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material( home: new MediaQuery(
child: new Center( data: const MediaQueryData(
child: new UserAccountsDrawerHeader( padding: const EdgeInsets.only(
currentAccountPicture: new CircleAvatar( left: 10.0,
key: avatarA, top: 20.0,
child: const Text('A'), right: 30.0,
), bottom: 40.0,
otherAccountsPictures: <Widget>[ ),
const CircleAvatar( ),
child: const Text('B'), child: new Material(
), child: new Center(
new CircleAvatar( child: new UserAccountsDrawerHeader(
key: avatarC, currentAccountPicture: new CircleAvatar(
child: const Text('C'), key: avatarA,
), child: const Text('A'),
new CircleAvatar(
key: avatarD,
child: const Text('D'),
), ),
const CircleAvatar( otherAccountsPictures: <Widget>[
child: const Text('E'), const CircleAvatar(
) child: const Text('B'),
], ),
accountName: const Text('name'), new CircleAvatar(
accountEmail: const Text('email'), key: avatarC,
child: const Text('C'),
),
new CircleAvatar(
key: avatarD,
child: const Text('D'),
),
const CircleAvatar(
child: const Text('E'),
)
],
accountName: const Text('name'),
accountEmail: const Text('email'),
),
), ),
), ),
), ),
...@@ -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