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
e186a164
Unverified
Commit
e186a164
authored
Jun 08, 2018
by
Jonah Williams
Committed by
GitHub
Jun 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'header' SemanticsFlag to AppBar, NavBar (#18289)
parent
b8c81e46
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
22 deletions
+139
-22
nav_bar.dart
packages/flutter/lib/src/cupertino/nav_bar.dart
+6
-3
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+10
-4
nav_bar_test.dart
packages/flutter/test/cupertino/nav_bar_test.dart
+64
-0
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+8
-2
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+15
-4
sliver_semantics_test.dart
packages/flutter/test/widgets/sliver_semantics_test.dart
+36
-9
No files found.
packages/flutter/lib/src/cupertino/nav_bar.dart
View file @
e186a164
...
...
@@ -147,7 +147,7 @@ class CupertinoNavigationBar extends StatelessWidget implements ObstructingPrefe
child:
new
_CupertinoPersistentNavigationBar
(
leading:
leading
,
automaticallyImplyLeading:
automaticallyImplyLeading
,
middle:
middle
,
middle:
new
Semantics
(
child:
middle
,
header:
true
)
,
trailing:
trailing
,
actionsForegroundColor:
actionsForegroundColor
,
),
...
...
@@ -491,7 +491,7 @@ class _CupertinoLargeTitleNavigationBarSliverDelegate
new
_CupertinoPersistentNavigationBar
(
leading:
leading
,
automaticallyImplyLeading:
automaticallyImplyLeading
,
middle:
middle
??
title
,
middle:
new
Semantics
(
child:
middle
??
title
,
header:
true
)
,
trailing:
trailing
,
// If middle widget exists, always show it. Otherwise, show title
// when collapsed.
...
...
@@ -533,7 +533,10 @@ class _CupertinoLargeTitleNavigationBarSliverDelegate
child:
new
SafeArea
(
top:
false
,
bottom:
false
,
child:
title
,
child:
new
Semantics
(
header:
true
,
child:
title
,
),
),
),
),
...
...
packages/flutter/lib/src/material/app_bar.dart
View file @
e186a164
...
...
@@ -393,20 +393,24 @@ class _AppBarState extends State<AppBar> {
Widget
title
=
widget
.
title
;
if
(
title
!=
null
)
{
bool
namesRoute
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
title
=
new
Semantics
(
namesRoute:
true
,
child:
title
)
;
namesRoute
=
true
;
break
;
case
TargetPlatform
.
iOS
:
break
;
}
title
=
new
DefaultTextStyle
(
style:
centerStyle
,
softWrap:
false
,
overflow:
TextOverflow
.
ellipsis
,
child:
title
,
child:
new
Semantics
(
namesRoute:
namesRoute
,
child:
title
,
header:
true
,
),
);
}
...
...
@@ -626,7 +630,9 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
automaticallyImplyLeading:
automaticallyImplyLeading
,
title:
title
,
actions:
actions
,
flexibleSpace:
flexibleSpace
,
flexibleSpace:
(
title
==
null
&&
flexibleSpace
!=
null
)
?
new
Semantics
(
child:
flexibleSpace
,
header:
true
)
:
flexibleSpace
,
bottom:
bottom
,
elevation:
forceElevated
||
overlapsContent
||
(
pinned
&&
shrinkOffset
>
maxExtent
-
minExtent
)
?
elevation
??
4.0
:
0.0
,
backgroundColor:
backgroundColor
,
...
...
packages/flutter/test/cupertino/nav_bar_test.dart
View file @
e186a164
...
...
@@ -8,6 +8,8 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
hide
TypeMatcher
;
import
'../widgets/semantics_tester.dart'
;
int
count
=
0
;
void
main
(
)
{
...
...
@@ -567,6 +569,68 @@ void main() {
expect
(
decoration
.
border
,
isNull
);
});
testWidgets
(
'CupertinoSliverNavigationBar has semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
new
WidgetsApp
(
color:
const
Color
(
0xFFFFFFFF
),
onGenerateRoute:
(
RouteSettings
settings
)
{
return
new
CupertinoPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
{
return
new
CupertinoPageScaffold
(
child:
new
CustomScrollView
(
slivers:
const
<
Widget
>[
const
CupertinoSliverNavigationBar
(
largeTitle:
const
Text
(
'Large Title'
),
border:
null
,
),
],
),
);
},
);
}
));
expect
(
semantics
.
nodesWith
(
label:
'Large Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
],
textDirection:
TextDirection
.
ltr
,
),
hasLength
(
1
));
semantics
.
dispose
();
});
testWidgets
(
'CupertinoNavigationBar has semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
new
WidgetsApp
(
color:
const
Color
(
0xFFFFFFFF
),
onGenerateRoute:
(
RouteSettings
settings
)
{
return
new
CupertinoPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
{
return
new
CupertinoPageScaffold
(
navigationBar:
const
CupertinoNavigationBar
(
middle:
const
Text
(
'Fixed Title'
),
),
child:
new
Container
(),
);
},
);
}
));
expect
(
semantics
.
nodesWith
(
label:
'Fixed Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHeader
],
textDirection:
TextDirection
.
ltr
,
),
hasLength
(
1
));
semantics
.
dispose
();
});
testWidgets
(
'Border can be overridden in sliver nav bar'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
e186a164
...
...
@@ -1214,7 +1214,10 @@ void main() {
textDirection:
TextDirection
.
ltr
,
),
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Title'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -1297,7 +1300,10 @@ void main() {
textDirection:
TextDirection
.
rtl
,
),
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Title'
,
textDirection:
TextDirection
.
rtl
,
),
...
...
packages/flutter/test/widgets/navigator_test.dart
View file @
e186a164
...
...
@@ -789,7 +789,10 @@ void main() {
));
expect
(
semantics
,
includesNodeWith
(
label:
'Page 1'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
));
await
tester
.
tap
(
find
.
text
(
'1'
));
// pushNamed('/A')
...
...
@@ -801,7 +804,10 @@ void main() {
));
expect
(
semantics
,
includesNodeWith
(
label:
'Page 2'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
));
await
tester
.
tap
(
find
.
text
(
'2'
));
// pushNamed('/B/C')
...
...
@@ -809,11 +815,16 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
semantics
,
includesNodeWith
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
scopesRoute
,
],
));
expect
(
semantics
,
includesNodeWith
(
label:
'Page 3'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
));
...
...
packages/flutter/test/widgets/sliver_semantics_test.dart
View file @
e186a164
...
...
@@ -79,7 +79,10 @@ void _tests() {
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
8
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Semantics Test with Slivers'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -140,7 +143,10 @@ void _tests() {
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
8
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Semantics Test with Slivers'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -219,7 +225,10 @@ void _tests() {
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
8
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Semantics Test with Slivers'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -458,7 +467,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'AppBar'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -557,7 +569,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'AppBar'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -693,7 +708,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'AppBar'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -791,7 +809,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'AppBar'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -883,7 +904,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Forward app bar'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -986,7 +1010,10 @@ void _tests() {
tags:
<
SemanticsTag
>[
RenderViewport
.
excludeFromScrolling
],
children:
<
TestSemantics
>[
new
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
isHeader
,
],
label:
'Backward app bar'
,
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