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
0d746ff1
Commit
0d746ff1
authored
Dec 16, 2016
by
Hans Muller
Committed by
GitHub
Dec 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AppBar Menu and action button center alignment (#7280)
parent
dbf1cfdb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+5
-2
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+36
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
0d746ff1
...
...
@@ -55,8 +55,11 @@ class _ToolbarLayout extends MultiChildLayoutDelegate {
if
(
hasChild
(
_ToolbarSlot
.
actions
))
{
final
BoxConstraints
constraints
=
new
BoxConstraints
.
loose
(
size
);
actionsWidth
=
layoutChild
(
_ToolbarSlot
.
actions
,
constraints
).
width
;
positionChild
(
_ToolbarSlot
.
actions
,
new
Offset
(
size
.
width
-
actionsWidth
,
0.0
));
final
Size
actionsSize
=
layoutChild
(
_ToolbarSlot
.
actions
,
constraints
);
final
double
actionsLeft
=
size
.
width
-
actionsSize
.
width
;
final
double
actionsTop
=
(
size
.
height
-
actionsSize
.
height
)
/
2.0
;
actionsWidth
=
actionsSize
.
width
;
positionChild
(
_ToolbarSlot
.
actions
,
new
Offset
(
actionsLeft
,
actionsTop
));
}
if
(
hasChild
(
_ToolbarSlot
.
title
))
{
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
0d746ff1
...
...
@@ -197,4 +197,40 @@ void main() {
Finder
title
=
find
.
text
(
'X'
);
expect
(
tester
.
getSize
(
title
).
isEmpty
,
isTrue
);
});
testWidgets
(
'AppBar actions are vertically centered'
,
(
WidgetTester
tester
)
async
{
UniqueKey
appBarKey
=
new
UniqueKey
();
UniqueKey
leadingKey
=
new
UniqueKey
();
UniqueKey
titleKey
=
new
UniqueKey
();
UniqueKey
action0Key
=
new
UniqueKey
();
UniqueKey
action1Key
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
appBar:
new
AppBar
(
key:
appBarKey
,
leading:
new
SizedBox
(
key:
leadingKey
,
height:
50.0
),
title:
new
SizedBox
(
key:
titleKey
,
height:
40.0
),
actions:
<
Widget
>[
new
SizedBox
(
key:
action0Key
,
height:
20.0
),
new
SizedBox
(
key:
action1Key
,
height:
30.0
),
],
),
),
)
);
// The vertical center of the widget with key, in global coordinates.
double
yCenter
(
Key
key
)
{
RenderBox
box
=
tester
.
renderObject
(
find
.
byKey
(
appBarKey
));
return
box
.
localToGlobal
(
new
Point
(
0.0
,
box
.
size
.
height
/
2.0
)).
y
;
}
expect
(
yCenter
(
appBarKey
),
equals
(
yCenter
(
leadingKey
)));
expect
(
yCenter
(
appBarKey
),
equals
(
yCenter
(
titleKey
)));
expect
(
yCenter
(
appBarKey
),
equals
(
yCenter
(
action0Key
)));
expect
(
yCenter
(
appBarKey
),
equals
(
yCenter
(
action1Key
)));
});
}
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