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
3a40d0ee
Unverified
Commit
3a40d0ee
authored
Mar 09, 2018
by
Michael Goderbauer
Committed by
GitHub
Mar 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support SemanticsFlag for Header (#15255)
parent
96ce9d64
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
207 additions
and
1 deletion
+207
-1
home.dart
examples/flutter_gallery/lib/gallery/home.dart
+4
-1
custom_paint.dart
packages/flutter/lib/src/rendering/custom_paint.dart
+15
-0
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+57
-0
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+39
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+12
-0
custom_painter_test.dart
packages/flutter/test/widgets/custom_painter_test.dart
+47
-0
semantics_test.dart
packages/flutter/test/widgets/semantics_test.dart
+33
-0
No files found.
examples/flutter_gallery/lib/gallery/home.dart
View file @
3a40d0ee
...
...
@@ -152,9 +152,12 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
child:
new
SafeArea
(
top:
false
,
bottom:
false
,
child:
new
Semantics
(
header:
true
,
child:
new
Text
(
galleryItem
.
category
,
style:
headerStyle
),
),
),
),
)
);
category
=
galleryItem
.
category
;
...
...
packages/flutter/lib/src/rendering/custom_paint.dart
View file @
3a40d0ee
...
...
@@ -817,6 +817,21 @@ class RenderCustomPaint extends RenderProxyBox {
if
(
properties
.
button
!=
null
)
{
config
.
isButton
=
properties
.
button
;
}
if
(
properties
.
textField
!=
null
)
{
config
.
isTextField
=
properties
.
textField
;
}
if
(
properties
.
focused
!=
null
)
{
config
.
isFocused
=
properties
.
focused
;
}
if
(
properties
.
enabled
!=
null
)
{
config
.
isEnabled
=
properties
.
enabled
;
}
if
(
properties
.
inMutuallyExclusiveGroup
!=
null
)
{
config
.
isInMutuallyExclusiveGroup
=
properties
.
inMutuallyExclusiveGroup
;
}
if
(
properties
.
header
!=
null
)
{
config
.
isHeader
=
properties
.
header
;
}
if
(
properties
.
label
!=
null
)
{
config
.
label
=
properties
.
label
;
}
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
3a40d0ee
...
...
@@ -3015,6 +3015,10 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
bool
checked
,
bool
selected
,
bool
button
,
bool
header
,
bool
textField
,
bool
focused
,
bool
inMutuallyExclusiveGroup
,
String
label
,
String
value
,
String
increasedValue
,
...
...
@@ -3045,6 +3049,10 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
_checked
=
checked
,
_selected
=
selected
,
_button
=
button
,
_header
=
header
,
_textField
=
textField
,
_focused
=
focused
,
_inMutuallyExclusiveGroup
=
inMutuallyExclusiveGroup
,
_label
=
label
,
_value
=
value
,
_increasedValue
=
increasedValue
,
...
...
@@ -3152,6 +3160,47 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
markNeedsSemanticsUpdate
();
}
/// If non-null, sets the [SemanticsNode.isHeader] semantic to the given value.
bool
get
header
=>
_header
;
bool
_header
;
set
header
(
bool
value
)
{
if
(
header
==
value
)
return
;
_header
=
value
;
markNeedsSemanticsUpdate
();
}
/// If non-null, sets the [SemanticsNode.isTextField] semantic to the given value.
bool
get
textField
=>
_textField
;
bool
_textField
;
set
textField
(
bool
value
)
{
if
(
textField
==
value
)
return
;
_textField
=
value
;
markNeedsSemanticsUpdate
();
}
/// If non-null, sets the [SemanticsNode.isFocused] semantic to the given value.
bool
get
focused
=>
_focused
;
bool
_focused
;
set
focused
(
bool
value
)
{
if
(
focused
==
value
)
return
;
_focused
=
value
;
markNeedsSemanticsUpdate
();
}
/// If non-null, sets the [SemanticsNode.isInMutuallyExclusiveGroup] semantic
/// to the given value.
bool
get
inMutuallyExclusiveGroup
=>
_inMutuallyExclusiveGroup
;
bool
_inMutuallyExclusiveGroup
;
set
inMutuallyExclusiveGroup
(
bool
value
)
{
if
(
inMutuallyExclusiveGroup
==
value
)
return
;
_inMutuallyExclusiveGroup
=
value
;
markNeedsSemanticsUpdate
();
}
/// If non-null, sets the [SemanticsNode.label] semantic to the given value.
///
/// The reading direction is given by [textDirection].
...
...
@@ -3581,6 +3630,14 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
config
.
isSelected
=
selected
;
if
(
button
!=
null
)
config
.
isButton
=
button
;
if
(
header
!=
null
)
config
.
isHeader
=
header
;
if
(
textField
!=
null
)
config
.
isTextField
=
textField
;
if
(
focused
!=
null
)
config
.
isFocused
=
focused
;
if
(
inMutuallyExclusiveGroup
!=
null
)
config
.
isInMutuallyExclusiveGroup
=
inMutuallyExclusiveGroup
;
if
(
label
!=
null
)
config
.
label
=
label
;
if
(
value
!=
null
)
...
...
packages/flutter/lib/src/semantics/semantics.dart
View file @
3a40d0ee
...
...
@@ -315,6 +315,10 @@ class SemanticsProperties extends DiagnosticableTree {
this
.
checked
,
this
.
selected
,
this
.
button
,
this
.
header
,
this
.
textField
,
this
.
focused
,
this
.
inMutuallyExclusiveGroup
,
this
.
label
,
this
.
value
,
this
.
increasedValue
,
...
...
@@ -366,6 +370,35 @@ class SemanticsProperties extends DiagnosticableTree {
/// is focused.
final
bool
button
;
/// If non-null, indicates that this subtree represents a header.
///
/// A header divides into sections. For example, an address book application
/// might define headers A, B, C, etc. to divide the list of alphabetically
/// sorted contacts into sections.
final
bool
header
;
/// If non-null, indicates that this subtree represents a text field.
///
/// TalkBack/VoiceOver provide special affordances to enter text into a
/// text field.
final
bool
textField
;
/// If non-null, whether the node currently holds input focus.
///
/// At most one node in the tree should hold input focus at any point in time.
///
/// Input focus (indicates that the node will receive keyboard events) is not
/// to be confused with accessibility focus. Accessibility focus is the
/// green/black rectangular that TalkBack/VoiceOver on the screen and is
/// separate from input focus.
final
bool
focused
;
/// If non-null, whether a semantic node is in a mutually exclusive group.
///
/// For example, a radio button is in a mutually exclusive group because only
/// one radio button in that group can be marked as [checked].
final
bool
inMutuallyExclusiveGroup
;
/// Provides a textual description of the widget.
///
/// If a label is provided, there must either by an ambient [Directionality]
...
...
@@ -2365,6 +2398,12 @@ class SemanticsConfiguration {
_setFlag
(
SemanticsFlag
.
isButton
,
value
);
}
/// Whether the owning [RenderObject] is a header (true) or not (false).
bool
get
isHeader
=>
_hasFlag
(
SemanticsFlag
.
isHeader
);
set
isHeader
(
bool
value
)
{
_setFlag
(
SemanticsFlag
.
isHeader
,
value
);
}
/// Whether the owning [RenderObject] is a text field.
bool
get
isTextField
=>
_hasFlag
(
SemanticsFlag
.
isTextField
);
set
isTextField
(
bool
value
)
{
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
3a40d0ee
...
...
@@ -4847,6 +4847,10 @@ class Semantics extends SingleChildRenderObjectWidget {
bool
checked
,
bool
selected
,
bool
button
,
bool
header
,
bool
textField
,
bool
focused
,
bool
inMutuallyExclusiveGroup
,
String
label
,
String
value
,
String
increasedValue
,
...
...
@@ -4881,6 +4885,10 @@ class Semantics extends SingleChildRenderObjectWidget {
checked:
checked
,
selected:
selected
,
button:
button
,
header:
header
,
textField:
textField
,
focused:
focused
,
inMutuallyExclusiveGroup:
inMutuallyExclusiveGroup
,
label:
label
,
value:
value
,
increasedValue:
increasedValue
,
...
...
@@ -4960,6 +4968,10 @@ class Semantics extends SingleChildRenderObjectWidget {
checked:
properties
.
checked
,
selected:
properties
.
selected
,
button:
properties
.
button
,
header:
properties
.
header
,
textField:
properties
.
textField
,
focused:
properties
.
focused
,
inMutuallyExclusiveGroup:
properties
.
inMutuallyExclusiveGroup
,
label:
properties
.
label
,
value:
properties
.
value
,
increasedValue:
properties
.
increasedValue
,
...
...
packages/flutter/test/widgets/custom_painter_test.dart
View file @
3a40d0ee
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:ui'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -397,6 +398,52 @@ void _defineTests() {
semantics
.
dispose
();
});
testWidgets
(
'Supports all flags'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
new
CustomPaint
(
painter:
new
_PainterWithSemantics
(
semantics:
new
CustomPainterSemantics
(
key:
const
ValueKey
<
int
>(
1
),
rect:
new
Rect
.
fromLTRB
(
1.0
,
2.0
,
3.0
,
4.0
),
properties:
const
SemanticsProperties
(
enabled:
true
,
checked:
true
,
selected:
true
,
button:
true
,
textField:
true
,
focused:
true
,
inMutuallyExclusiveGroup:
true
,
header:
true
,
),
),
),
));
const
int
expectedId
=
2
;
final
TestSemantics
expectedSemantics
=
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
id:
1
,
previousNodeId:
-
1
,
nextNodeId:
expectedId
,
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
id:
expectedId
,
rect:
TestSemantics
.
fullScreen
,
flags:
SemanticsFlag
.
values
.
values
.
toList
(),
previousNodeId:
1
,
nextNodeId:
-
1
,
),
]
),
],
);
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreRect:
true
,
ignoreTransform:
true
));
semantics
.
dispose
();
});
group
(
'diffing'
,
()
{
testWidgets
(
'complains about duplicate keys'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semanticsTester
=
new
SemanticsTester
(
tester
);
...
...
packages/flutter/test/widgets/semantics_test.dart
View file @
3a40d0ee
...
...
@@ -449,6 +449,39 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Semantics widget supports all flags'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
new
Semantics
(
container:
true
,
// flags
enabled:
true
,
checked:
true
,
selected:
true
,
button:
true
,
textField:
true
,
focused:
true
,
inMutuallyExclusiveGroup:
true
,
header:
true
,
)
);
final
TestSemantics
expectedSemantics
=
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
rect:
TestSemantics
.
fullScreen
,
flags:
SemanticsFlag
.
values
.
values
.
toList
(),
previousNodeId:
-
1
,
nextNodeId:
-
1
,
),
],
);
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreId:
true
));
semantics
.
dispose
();
});
testWidgets
(
'Actions can be replaced without triggering semantics update'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
int
semanticsUpdateCount
=
0
;
...
...
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