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
Show 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 {
...
@@ -19,10 +19,14 @@ class _AccountPictures extends StatelessWidget {
Key
?
key
,
Key
?
key
,
this
.
currentAccountPicture
,
this
.
currentAccountPicture
,
this
.
otherAccountsPictures
,
this
.
otherAccountsPictures
,
this
.
currentAccountPictureSize
,
this
.
otherAccountsPicturesSize
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
Widget
?
currentAccountPicture
;
final
Widget
?
currentAccountPicture
;
final
List
<
Widget
>?
otherAccountsPictures
;
final
List
<
Widget
>?
otherAccountsPictures
;
final
Size
?
currentAccountPictureSize
;
final
Size
?
otherAccountsPicturesSize
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -37,13 +41,14 @@ class _AccountPictures extends StatelessWidget {
...
@@ -37,13 +41,14 @@ class _AccountPictures extends StatelessWidget {
padding:
const
EdgeInsetsDirectional
.
only
(
start:
8.0
),
padding:
const
EdgeInsetsDirectional
.
only
(
start:
8.0
),
child:
Semantics
(
child:
Semantics
(
container:
true
,
container:
true
,
child:
Container
(
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
bottom:
8.0
),
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
bottom:
8.0
),
width:
48.0
,
child:
SizedBox
.
fromSize
(
height:
48.0
,
size:
otherAccountsPicturesSize
,
child:
picture
,
child:
picture
,
),
),
),
),
),
);
);
}).
toList
(),
}).
toList
(),
),
),
...
@@ -52,9 +57,8 @@ class _AccountPictures extends StatelessWidget {
...
@@ -52,9 +57,8 @@ class _AccountPictures extends StatelessWidget {
top:
0.0
,
top:
0.0
,
child:
Semantics
(
child:
Semantics
(
explicitChildNodes:
true
,
explicitChildNodes:
true
,
child:
SizedBox
(
child:
SizedBox
.
fromSize
(
width:
72.0
,
size:
currentAccountPictureSize
,
height:
72.0
,
child:
currentAccountPicture
,
child:
currentAccountPicture
,
),
),
),
),
...
@@ -298,6 +302,8 @@ class UserAccountsDrawerHeader extends StatefulWidget {
...
@@ -298,6 +302,8 @@ class UserAccountsDrawerHeader extends StatefulWidget {
this
.
margin
=
const
EdgeInsets
.
only
(
bottom:
8.0
),
this
.
margin
=
const
EdgeInsets
.
only
(
bottom:
8.0
),
this
.
currentAccountPicture
,
this
.
currentAccountPicture
,
this
.
otherAccountsPictures
,
this
.
otherAccountsPictures
,
this
.
currentAccountPictureSize
=
const
Size
.
square
(
72.0
),
this
.
otherAccountsPicturesSize
=
const
Size
.
square
(
40.0
),
required
this
.
accountName
,
required
this
.
accountName
,
required
this
.
accountEmail
,
required
this
.
accountEmail
,
this
.
onDetailsPressed
,
this
.
onDetailsPressed
,
...
@@ -320,6 +326,12 @@ class UserAccountsDrawerHeader extends StatefulWidget {
...
@@ -320,6 +326,12 @@ class UserAccountsDrawerHeader extends StatefulWidget {
/// upper-right corner. Normally a list of [CircleAvatar] widgets.
/// upper-right corner. Normally a list of [CircleAvatar] widgets.
final
List
<
Widget
>?
otherAccountsPictures
;
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
/// A widget that represents the user's current account name. It is
/// displayed on the left, below the [currentAccountPicture].
/// displayed on the left, below the [currentAccountPicture].
final
Widget
?
accountName
;
final
Widget
?
accountName
;
...
@@ -373,6 +385,8 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
...
@@ -373,6 +385,8 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
child:
_AccountPictures
(
child:
_AccountPictures
(
currentAccountPicture:
widget
.
currentAccountPicture
,
currentAccountPicture:
widget
.
currentAccountPicture
,
otherAccountsPictures:
widget
.
otherAccountsPictures
,
otherAccountsPictures:
widget
.
otherAccountsPictures
,
currentAccountPictureSize:
widget
.
currentAccountPictureSize
,
otherAccountsPicturesSize:
widget
.
otherAccountsPicturesSize
,
),
),
),
),
),
),
...
...
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
fad18d6c
...
@@ -17,7 +17,9 @@ Future<void> pumpTestWidget(
...
@@ -17,7 +17,9 @@ Future<void> pumpTestWidget(
bool
withName
=
true
,
bool
withName
=
true
,
bool
withEmail
=
true
,
bool
withEmail
=
true
,
bool
withOnDetailsPressedHandler
=
true
,
bool
withOnDetailsPressedHandler
=
true
,
})
async
{
Size
otherAccountsPictureSize
=
const
Size
.
square
(
40.0
),
Size
currentAccountPictureSize
=
const
Size
.
square
(
72.0
),
})
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
MediaQuery
(
home:
MediaQuery
(
...
@@ -33,6 +35,8 @@ Future<void> pumpTestWidget(
...
@@ -33,6 +35,8 @@ Future<void> pumpTestWidget(
child:
Center
(
child:
Center
(
child:
UserAccountsDrawerHeader
(
child:
UserAccountsDrawerHeader
(
onDetailsPressed:
withOnDetailsPressedHandler
?
()
{
}
:
null
,
onDetailsPressed:
withOnDetailsPressedHandler
?
()
{
}
:
null
,
currentAccountPictureSize:
currentAccountPictureSize
,
otherAccountsPicturesSize:
otherAccountsPictureSize
,
currentAccountPicture:
const
ExcludeSemantics
(
currentAccountPicture:
const
ExcludeSemantics
(
child:
CircleAvatar
(
child:
CircleAvatar
(
key:
avatarA
,
key:
avatarA
,
...
@@ -104,6 +108,23 @@ void main() {
...
@@ -104,6 +108,23 @@ void main() {
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
});
});
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
{
testWidgets
(
'UserAccountsDrawerHeader icon rotation test'
,
(
WidgetTester
tester
)
async
{
await
pumpTestWidget
(
tester
);
await
pumpTestWidget
(
tester
);
Transform
transformWidget
=
tester
.
firstWidget
(
find
.
byType
(
Transform
));
Transform
transformWidget
=
tester
.
firstWidget
(
find
.
byType
(
Transform
));
...
...
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