Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0739dcea
Commit
0739dcea
authored
Mar 24, 2017
by
Collin Jackson
Committed by
GitHub
Mar 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #9003 Make DrawerHeader margin configurable (#9006)
parent
606f5622
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
31 deletions
+51
-31
drawer_header.dart
packages/flutter/lib/src/material/drawer_header.dart
+5
-1
user_accounts_drawer_header.dart
...flutter/lib/src/material/user_accounts_drawer_header.dart
+5
-0
user_accounts_drawer_header_test.dart
...utter/test/material/user_accounts_drawer_header_test.dart
+41
-30
No files found.
packages/flutter/lib/src/material/drawer_header.dart
View file @
0739dcea
...
...
@@ -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
(
...
...
packages/flutter/lib/src/material/user_accounts_drawer_header.dart
View file @
0739dcea
...
...
@@ -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
>[
...
...
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
0739dcea
...
...
@@ -14,31 +14,33 @@ void main() {
await
tester
.
pumpWidget
(
new
Material
(
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'
)
child:
new
Center
(
child:
new
UserAccountsDrawerHeader
(
currentAccountPicture:
new
CircleAvatar
(
key:
avatarA
,
child:
new
Text
(
'A'
),
),
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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment