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
fad18d6c
Unverified
Commit
fad18d6c
authored
Feb 03, 2021
by
burekas7
Committed by
GitHub
Feb 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UserAccountsDrawerHeader] New option for changing profiles images size (#73105)
parent
deb5e40f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
38 deletions
+73
-38
user_accounts_drawer_header.dart
...flutter/lib/src/material/user_accounts_drawer_header.dart
+25
-11
user_accounts_drawer_header_test.dart
...utter/test/material/user_accounts_drawer_header_test.dart
+48
-27
No files found.
packages/flutter/lib/src/material/user_accounts_drawer_header.dart
View file @
fad18d6c
...
...
@@ -19,10 +19,14 @@ class _AccountPictures extends StatelessWidget {
Key
?
key
,
this
.
currentAccountPicture
,
this
.
otherAccountsPictures
,
this
.
currentAccountPictureSize
,
this
.
otherAccountsPicturesSize
,
})
:
super
(
key:
key
);
final
Widget
?
currentAccountPicture
;
final
List
<
Widget
>?
otherAccountsPictures
;
final
Size
?
currentAccountPictureSize
;
final
Size
?
otherAccountsPicturesSize
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -37,12 +41,13 @@ class _AccountPictures extends StatelessWidget {
padding:
const
EdgeInsetsDirectional
.
only
(
start:
8.0
),
child:
Semantics
(
container:
true
,
child:
Container
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
bottom:
8.0
),
width:
48.0
,
height:
48.0
,
child:
picture
,
),
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
bottom:
8.0
),
child:
SizedBox
.
fromSize
(
size:
otherAccountsPicturesSize
,
child:
picture
,
),
),
),
);
}).
toList
(),
...
...
@@ -52,9 +57,8 @@ class _AccountPictures extends StatelessWidget {
top:
0.0
,
child:
Semantics
(
explicitChildNodes:
true
,
child:
SizedBox
(
width:
72.0
,
height:
72.0
,
child:
SizedBox
.
fromSize
(
size:
currentAccountPictureSize
,
child:
currentAccountPicture
,
),
),
...
...
@@ -181,8 +185,8 @@ class _AccountDetailsState extends State<_AccountDetails> with SingleTickerProvi
Icons
.
arrow_drop_down
,
color:
widget
.
arrowColor
,
semanticLabel:
widget
.
isOpen
?
localizations
.
hideAccountsLabel
:
localizations
.
showAccountsLabel
,
?
localizations
.
hideAccountsLabel
:
localizations
.
showAccountsLabel
,
),
),
),
...
...
@@ -298,6 +302,8 @@ class UserAccountsDrawerHeader extends StatefulWidget {
this
.
margin
=
const
EdgeInsets
.
only
(
bottom:
8.0
),
this
.
currentAccountPicture
,
this
.
otherAccountsPictures
,
this
.
currentAccountPictureSize
=
const
Size
.
square
(
72.0
),
this
.
otherAccountsPicturesSize
=
const
Size
.
square
(
40.0
),
required
this
.
accountName
,
required
this
.
accountEmail
,
this
.
onDetailsPressed
,
...
...
@@ -320,6 +326,12 @@ class UserAccountsDrawerHeader extends StatefulWidget {
/// upper-right corner. Normally a list of [CircleAvatar] widgets.
final
List
<
Widget
>?
otherAccountsPictures
;
/// The size of the [currentAccountPicture].
final
Size
currentAccountPictureSize
;
/// The size of each widget in [otherAccountsPicturesSize].
final
Size
otherAccountsPicturesSize
;
/// A widget that represents the user's current account name. It is
/// displayed on the left, below the [currentAccountPicture].
final
Widget
?
accountName
;
...
...
@@ -373,6 +385,8 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
child:
_AccountPictures
(
currentAccountPicture:
widget
.
currentAccountPicture
,
otherAccountsPictures:
widget
.
otherAccountsPictures
,
currentAccountPictureSize:
widget
.
currentAccountPictureSize
,
otherAccountsPicturesSize:
widget
.
otherAccountsPicturesSize
,
),
),
),
...
...
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
fad18d6c
...
...
@@ -14,10 +14,12 @@ const Key avatarD = Key('D');
Future
<
void
>
pumpTestWidget
(
WidgetTester
tester
,
{
bool
withName
=
true
,
bool
withEmail
=
true
,
bool
withOnDetailsPressedHandler
=
true
,
})
async
{
bool
withName
=
true
,
bool
withEmail
=
true
,
bool
withOnDetailsPressedHandler
=
true
,
Size
otherAccountsPictureSize
=
const
Size
.
square
(
40.0
),
Size
currentAccountPictureSize
=
const
Size
.
square
(
72.0
),
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
@@ -33,6 +35,8 @@ Future<void> pumpTestWidget(
child:
Center
(
child:
UserAccountsDrawerHeader
(
onDetailsPressed:
withOnDetailsPressedHandler
?
()
{
}
:
null
,
currentAccountPictureSize:
currentAccountPictureSize
,
otherAccountsPicturesSize:
otherAccountsPictureSize
,
currentAccountPicture:
const
ExcludeSemantics
(
child:
CircleAvatar
(
key:
avatarA
,
...
...
@@ -104,6 +108,23 @@ void main() {
expect
(
avatarDTopRight
.
dx
-
avatarCTopRight
.
dx
,
equals
(
40.0
+
16.0
));
// size + space between
});
testWidgets
(
'UserAccountsDrawerHeader change default size test'
,
(
WidgetTester
tester
)
async
{
const
Size
currentAccountPictureSize
=
Size
.
square
(
60.0
);
const
Size
otherAccountsPictureSize
=
Size
.
square
(
30.0
);
await
pumpTestWidget
(
tester
,
currentAccountPictureSize:
currentAccountPictureSize
,
otherAccountsPictureSize:
otherAccountsPictureSize
,
);
final
RenderBox
currentAccountRenderBox
=
tester
.
renderObject
(
find
.
byKey
(
avatarA
));
final
RenderBox
otherAccountRenderBox
=
tester
.
renderObject
(
find
.
byKey
(
avatarC
));
expect
(
currentAccountRenderBox
.
size
,
currentAccountPictureSize
);
expect
(
otherAccountRenderBox
.
size
,
otherAccountsPictureSize
);
});
testWidgets
(
'UserAccountsDrawerHeader icon rotation test'
,
(
WidgetTester
tester
)
async
{
await
pumpTestWidget
(
tester
);
Transform
transformWidget
=
tester
.
firstWidget
(
find
.
byType
(
Transform
));
...
...
@@ -480,37 +501,37 @@ void main() {
TestSemantics
(
children:
<
TestSemantics
>[
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
],
children:
<
TestSemantics
>[
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isFocusable
],
label:
'Signed in
\n
name
\n
email'
,
textDirection:
TextDirection
.
ltr
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
],
children:
<
TestSemantics
>[
TestSemantics
(
label:
r'B'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
label:
r'C'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
label:
r'D'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
r'Show accounts'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isFocusable
],
label:
'Signed in
\n
name
\n
email'
,
textDirection:
TextDirection
.
ltr
,
children:
<
TestSemantics
>[
TestSemantics
(
label:
r'B'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
label:
r'C'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
label:
r'D'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
r'Show accounts'
,
textDirection:
TextDirection
.
ltr
,
),
],
),
],
),
],
),
],
),
],
),
],
...
...
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