mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
parent
606f56221b
commit
0739dcea4b
@ -31,6 +31,7 @@ class DrawerHeader extends StatelessWidget {
|
||||
const DrawerHeader({
|
||||
Key key,
|
||||
this.decoration,
|
||||
this.margin: const EdgeInsets.only(bottom: 8.0),
|
||||
this.padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
|
||||
this.duration: const Duration(milliseconds: 250),
|
||||
this.curve: Curves.fastOutSlowIn,
|
||||
@ -53,6 +54,9 @@ class DrawerHeader extends StatelessWidget {
|
||||
/// If the child is null, the padding has no effect.
|
||||
final EdgeInsets padding;
|
||||
|
||||
/// The margin around the drawer header.
|
||||
final EdgeInsets margin;
|
||||
|
||||
/// The duration for animations of the [decoration].
|
||||
final Duration duration;
|
||||
|
||||
@ -72,7 +76,7 @@ class DrawerHeader extends StatelessWidget {
|
||||
final double statusBarHeight = MediaQuery.of(context).padding.top;
|
||||
return new Container(
|
||||
height: statusBarHeight + _kDrawerHeaderHeight,
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
margin: margin,
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
bottom: new BorderSide(
|
||||
|
||||
@ -135,6 +135,7 @@ class UserAccountsDrawerHeader extends StatefulWidget {
|
||||
UserAccountsDrawerHeader({
|
||||
Key key,
|
||||
this.decoration,
|
||||
this.margin: const EdgeInsets.only(bottom: 8.0),
|
||||
this.currentAccountPicture,
|
||||
this.otherAccountsPictures,
|
||||
@required this.accountName,
|
||||
@ -146,6 +147,9 @@ class UserAccountsDrawerHeader extends StatefulWidget {
|
||||
/// with its background color set to the current theme's primaryColor is used.
|
||||
final Decoration decoration;
|
||||
|
||||
/// The margin around the drawer header.
|
||||
final EdgeInsets margin;
|
||||
|
||||
/// A widget placed in the upper-left corner that represents the current
|
||||
/// user's account. Normally a [CircleAvatar].
|
||||
final Widget currentAccountPicture;
|
||||
@ -181,6 +185,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
|
||||
decoration: config.decoration ?? new BoxDecoration(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
margin: config.margin,
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
|
||||
@ -14,31 +14,33 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
new Material(
|
||||
child: new UserAccountsDrawerHeader(
|
||||
currentAccountPicture: new CircleAvatar(
|
||||
key: avatarA,
|
||||
child: new Text('A')
|
||||
child: new Center(
|
||||
child: new UserAccountsDrawerHeader(
|
||||
currentAccountPicture: new CircleAvatar(
|
||||
key: avatarA,
|
||||
child: new Text('A'),
|
||||
),
|
||||
otherAccountsPictures: <Widget>[
|
||||
new CircleAvatar(
|
||||
child: new Text('B'),
|
||||
),
|
||||
new CircleAvatar(
|
||||
key: avatarC,
|
||||
child: new Text('C'),
|
||||
),
|
||||
new CircleAvatar(
|
||||
key: avatarD,
|
||||
child: new Text('D'),
|
||||
),
|
||||
new CircleAvatar(
|
||||
child: new Text('E'),
|
||||
)
|
||||
],
|
||||
accountName: new Text("name"),
|
||||
accountEmail: new Text("email"),
|
||||
),
|
||||
otherAccountsPictures: <Widget>[
|
||||
new CircleAvatar(
|
||||
child: new Text('B')
|
||||
),
|
||||
new CircleAvatar(
|
||||
key: avatarC,
|
||||
child: new Text('C')
|
||||
),
|
||||
new CircleAvatar(
|
||||
key: avatarD,
|
||||
child: new Text('D')
|
||||
),
|
||||
new CircleAvatar(
|
||||
child: new Text('E')
|
||||
)
|
||||
],
|
||||
accountName: new Text("name"),
|
||||
accountEmail: new Text("email")
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('A'), findsOneWidget);
|
||||
@ -58,6 +60,9 @@ void main() {
|
||||
expect(box.size.width, equals(40.0));
|
||||
expect(box.size.height, equals(40.0));
|
||||
|
||||
box = tester.renderObject(find.byType(UserAccountsDrawerHeader));
|
||||
expect(box.size.height, equals(160.0 + 8.0 + 1.0)); // height + bottom margin + bottom edge)
|
||||
|
||||
final Point topLeft = tester.getTopLeft(find.byType(UserAccountsDrawerHeader));
|
||||
final Point topRight = tester.getTopRight(find.byType(UserAccountsDrawerHeader));
|
||||
|
||||
@ -80,19 +85,25 @@ void main() {
|
||||
Widget accountName,
|
||||
Widget accountEmail,
|
||||
VoidCallback onDetailsPressed,
|
||||
EdgeInsets margin,
|
||||
}) {
|
||||
return new Material(
|
||||
child: new UserAccountsDrawerHeader(
|
||||
currentAccountPicture: currentAccountPicture,
|
||||
otherAccountsPictures: otherAccountsPictures,
|
||||
accountName: accountName,
|
||||
accountEmail: accountEmail,
|
||||
onDetailsPressed: onDetailsPressed,
|
||||
child: new Center(
|
||||
child: new UserAccountsDrawerHeader(
|
||||
currentAccountPicture: currentAccountPicture,
|
||||
otherAccountsPictures: otherAccountsPictures,
|
||||
accountName: accountName,
|
||||
accountEmail: accountEmail,
|
||||
onDetailsPressed: onDetailsPressed,
|
||||
margin: margin,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
final RenderBox box = tester.renderObject(find.byType(UserAccountsDrawerHeader));
|
||||
expect(box.size.height, equals(160.0 + 1.0)); // height + bottom edge)
|
||||
expect(find.byType(Icon), findsNothing);
|
||||
|
||||
await tester.pumpWidget(buildFrame(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user