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
70f21de9
Unverified
Commit
70f21de9
authored
Sep 17, 2020
by
chunhtai
Committed by
GitHub
Sep 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reland always adds alert label for alert dialog in Android (#66057)
parent
0cf1b407
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
19 deletions
+78
-19
main_test.dart
...ests/android_semantics_testing/test_driver/main_test.dart
+2
-2
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+17
-16
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+59
-1
No files found.
dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
View file @
70f21de9
...
...
@@ -613,8 +613,8 @@ void main() {
isEnabled:
true
,
isFocusable:
true
,
actions:
<
AndroidSemanticsAction
>[
if
(
item
==
'
Body1
'
)
AndroidSemanticsAction
.
clearAccessibilityFocus
,
if
(
item
!=
'
Body1
'
)
AndroidSemanticsAction
.
accessibilityFocus
,
if
(
item
==
'
Title
'
)
AndroidSemanticsAction
.
clearAccessibilityFocus
,
if
(
item
!=
'
Title
'
)
AndroidSemanticsAction
.
accessibilityFocus
,
],
),
reason:
"Alert
$item
button doesn't have the right semantics"
);
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
70f21de9
...
...
@@ -413,9 +413,11 @@ class AlertDialog extends StatelessWidget {
/// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the dialog is opened and closed.
///
/// If this label is not provided, a semantic label will be inferred from the
/// [title] if it is not null. If there is no title, the label will be taken
/// from [MaterialLocalizations.alertDialogLabel].
/// In iOS, if this label is not provided, a semantic label will be inferred
/// from the [title] if it is not null.
///
/// In Android, if this label is not provided, the dialog will use the
/// [MaterialLocalizations.alertDialogLabel] as its label.
///
/// See also:
///
...
...
@@ -455,18 +457,15 @@ class AlertDialog extends StatelessWidget {
final
DialogTheme
dialogTheme
=
DialogTheme
.
of
(
context
);
String
label
=
semanticLabel
;
if
(
title
==
null
)
{
switch
(
theme
.
platform
)
{
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
macOS
:
label
=
semanticLabel
;
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
label
=
semanticLabel
??
MaterialLocalizations
.
of
(
context
)?.
alertDialogLabel
;
}
switch
(
theme
.
platform
)
{
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
macOS
:
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
label
??=
MaterialLocalizations
.
of
(
context
)?.
alertDialogLabel
;
}
// The paddingScaleFactor is used to adjust the padding of Dialog's
...
...
@@ -491,7 +490,7 @@ class AlertDialog extends StatelessWidget {
style:
titleTextStyle
??
dialogTheme
.
titleTextStyle
??
theme
.
textTheme
.
headline6
,
child:
Semantics
(
child:
title
,
namesRoute:
true
,
namesRoute:
label
==
null
,
container:
true
,
),
),
...
...
@@ -569,6 +568,8 @@ class AlertDialog extends StatelessWidget {
if
(
label
!=
null
)
dialogChild
=
Semantics
(
scopesRoute:
true
,
explicitChildNodes:
true
,
namesRoute:
true
,
label:
label
,
child:
dialogChild
,
...
...
packages/flutter/test/material/dialog_test.dart
View file @
70f21de9
...
...
@@ -1275,10 +1275,12 @@ void main() {
));
});
testWidgets
(
'
Dialog widget contains route semantics from title
'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
AlertDialog widget contains route semantics from title for iOS
'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
...
...
@@ -1321,6 +1323,62 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'AlertDialog widget always contains alert route semantics for android'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
android
),
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Center
(
child:
ElevatedButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
showDialog
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
const
AlertDialog
(
title:
Text
(
'Title'
),
content:
Text
(
'Y'
),
actions:
<
Widget
>[],
);
},
);
},
),
);
},
),
),
),
);
expect
(
semantics
,
isNot
(
includesNodeWith
(
label:
'Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
)));
expect
(
semantics
,
isNot
(
includesNodeWith
(
label:
'Alert'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
scopesRoute
],
)));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
// It does not use 'Title' as route semantics
expect
(
semantics
,
isNot
(
includesNodeWith
(
label:
'Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
)));
expect
(
semantics
,
includesNodeWith
(
label:
'Alert'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
,
SemanticsFlag
.
scopesRoute
],
));
semantics
.
dispose
();
});
testWidgets
(
'Dismissible.confirmDismiss defers to an AlertDialog'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
List
<
int
>
dismissedItems
=
<
int
>[];
...
...
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