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
5b30b393
Unverified
Commit
5b30b393
authored
Jul 31, 2018
by
Jonah Williams
Committed by
GitHub
Jul 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure bottom nav bar always contributes labels (#19934)
parent
3a6228be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
10 deletions
+109
-10
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+1
-0
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+21
-2
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+14
-1
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+70
-7
proxy_box_test.dart
packages/flutter/test/rendering/proxy_box_test.dart
+2
-0
semantics_and_children_test.dart
...s/flutter/test/rendering/semantics_and_children_test.dart
+1
-0
No files found.
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
5b30b393
...
...
@@ -242,6 +242,7 @@ class _BottomNavigationTile extends StatelessWidget {
).
evaluate
(
animation
),
),
child:
new
FadeTransition
(
alwaysIncludeSemantics:
true
,
opacity:
animation
,
child:
DefaultTextStyle
.
merge
(
style:
const
TextStyle
(
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
5b30b393
...
...
@@ -792,7 +792,14 @@ class RenderAnimatedOpacity extends RenderProxyBox {
/// Creates a partially transparent render object.
///
/// The [opacity] argument must not be null.
RenderAnimatedOpacity
({
@required
Animation
<
double
>
opacity
,
RenderBox
child
})
:
super
(
child
)
{
RenderAnimatedOpacity
({
@required
Animation
<
double
>
opacity
,
bool
alwaysIncludeSemantics
=
false
,
RenderBox
child
,
})
:
assert
(
opacity
!=
null
),
assert
(
alwaysIncludeSemantics
!=
null
),
_alwaysIncludeSemantics
=
alwaysIncludeSemantics
,
super
(
child
)
{
this
.
opacity
=
opacity
;
}
...
...
@@ -823,6 +830,18 @@ class RenderAnimatedOpacity extends RenderProxyBox {
_updateOpacity
();
}
/// Whether child semantics are included regardless of the opacity.
///
/// Defaults to false.
bool
get
alwaysIncludeSemantics
=>
_alwaysIncludeSemantics
;
bool
_alwaysIncludeSemantics
;
set
alwaysIncludeSemantics
(
bool
value
)
{
if
(
value
==
_alwaysIncludeSemantics
)
return
;
_alwaysIncludeSemantics
=
value
;
markNeedsSemanticsUpdate
();
}
@override
void
attach
(
PipelineOwner
owner
)
{
super
.
attach
(
owner
);
...
...
@@ -866,7 +885,7 @@ class RenderAnimatedOpacity extends RenderProxyBox {
@override
void
visitChildrenForSemantics
(
RenderObjectVisitor
visitor
)
{
if
(
child
!=
null
&&
_alpha
!=
0
)
if
(
child
!=
null
&&
(
_alpha
!=
0
||
alwaysIncludeSemantics
)
)
visitor
(
child
);
}
...
...
packages/flutter/lib/src/widgets/transitions.dart
View file @
5b30b393
...
...
@@ -342,6 +342,7 @@ class FadeTransition extends SingleChildRenderObjectWidget {
Key
key
,
@required
this
.
opacity
,
Widget
child
,
this
.
alwaysIncludeSemantics
=
false
,
})
:
super
(
key:
key
,
child:
child
);
/// The animation that controls the opacity of the child.
...
...
@@ -352,17 +353,29 @@ class FadeTransition extends SingleChildRenderObjectWidget {
/// completely transparent.
final
Animation
<
double
>
opacity
;
/// Whether the semantic information of the children is always included.
///
/// Defaults to false.
///
/// When true, regardless of the opacity settings the child semantic
/// information is exposed as if the widget were fully visible. This is
/// useful in cases where labels may be hidden during animations that
/// would otherwise contribute relevant semantics.
final
bool
alwaysIncludeSemantics
;
@override
RenderAnimatedOpacity
createRenderObject
(
BuildContext
context
)
{
return
new
RenderAnimatedOpacity
(
opacity:
opacity
,
alwaysIncludeSemantics:
alwaysIncludeSemantics
,
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderAnimatedOpacity
renderObject
)
{
renderObject
..
opacity
=
opacity
;
..
opacity
=
opacity
..
alwaysIncludeSemantics
=
alwaysIncludeSemantics
;
}
@override
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
5b30b393
...
...
@@ -539,7 +539,7 @@ void main() {
expect
(
find
.
byKey
(
stroked
),
findsOneWidget
);
});
testWidgets
(
'BottomNavigationBar semantics'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar
.fixed
semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
...
...
@@ -567,13 +567,10 @@ void main() {
final
TestSemantics
expected
=
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
1
,
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
2
,
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
3
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isSelected
,
SemanticsFlag
.
isHeader
,
...
...
@@ -583,7 +580,6 @@ void main() {
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
id:
4
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
,
],
...
...
@@ -592,7 +588,6 @@ void main() {
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
id:
5
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
,
],
...
...
@@ -606,7 +601,75 @@ void main() {
),
],
);
expect
(
semantics
,
hasSemantics
(
expected
,
ignoreTransform:
true
,
ignoreRect:
true
));
expect
(
semantics
,
hasSemantics
(
expected
,
ignoreId:
true
,
ignoreTransform:
true
,
ignoreRect:
true
));
semantics
.
dispose
();
});
testWidgets
(
'BottomNavigationBar.shifting semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
boilerplate
(
textDirection:
TextDirection
.
ltr
,
bottomNavigationBar:
new
BottomNavigationBar
(
type:
BottomNavigationBarType
.
shifting
,
items:
const
<
BottomNavigationBarItem
>[
const
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
ac_unit
),
title:
const
Text
(
'AC'
),
),
const
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
access_alarm
),
title:
const
Text
(
'Alarm'
),
),
const
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
hot_tub
),
title:
const
Text
(
'Hot Tub'
),
),
],
),
),
);
final
TestSemantics
expected
=
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
children:
<
TestSemantics
>[
new
TestSemantics
(
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isSelected
,
SemanticsFlag
.
isHeader
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
'AC
\n
Tab 1 of 3'
,
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
'Alarm
\n
Tab 2 of 3'
,
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
'Hot Tub
\n
Tab 3 of 3'
,
textDirection:
TextDirection
.
ltr
,
),
],
),
],
),
],
);
expect
(
semantics
,
hasSemantics
(
expected
,
ignoreId:
true
,
ignoreTransform:
true
,
ignoreRect:
true
));
semantics
.
dispose
();
});
...
...
packages/flutter/test/rendering/proxy_box_test.dart
View file @
5b30b393
...
...
@@ -219,6 +219,7 @@ void main() {
)..
value
=
0.0
;
final
RenderAnimatedOpacity
renderAnimatedOpacity
=
new
RenderAnimatedOpacity
(
alwaysIncludeSemantics:
false
,
opacity:
opacityAnimation
,
child:
new
RenderSizedBox
(
const
Size
(
1.0
,
1.0
)),
// size doesn't matter
);
...
...
@@ -233,6 +234,7 @@ void main() {
)..
value
=
1.0
;
final
RenderAnimatedOpacity
renderAnimatedOpacity
=
new
RenderAnimatedOpacity
(
alwaysIncludeSemantics:
false
,
opacity:
opacityAnimation
,
child:
new
RenderSizedBox
(
const
Size
(
1.0
,
1.0
)),
// size doesn't matter
);
...
...
packages/flutter/test/rendering/semantics_and_children_test.dart
View file @
5b30b393
...
...
@@ -43,6 +43,7 @@ void main() {
test
(
'RenderOpacity and children and semantics'
,
()
{
final
AnimationController
controller
=
new
AnimationController
(
vsync:
const
TestVSync
());
final
RenderAnimatedOpacity
box
=
new
RenderAnimatedOpacity
(
alwaysIncludeSemantics:
false
,
opacity:
controller
,
child:
new
RenderParagraph
(
const
TextSpan
(),
...
...
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