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
cc256c3e
Unverified
Commit
cc256c3e
authored
Dec 07, 2022
by
chunhtai
Committed by
GitHub
Dec 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Use semantics label for backbutton and closebutton for Android" (#116675)
This reverts commit
68ce1aea
.
parent
68ce1aea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
134 deletions
+12
-134
back_button.dart
packages/flutter/lib/src/material/back_button.dart
+9
-42
semantics_debugger.dart
packages/flutter/lib/src/widgets/semantics_debugger.dart
+1
-5
back_button_test.dart
packages/flutter/test/material/back_button_test.dart
+2
-59
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+0
-28
No files found.
packages/flutter/lib/src/material/back_button.dart
View file @
cc256c3e
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'debug.dart'
;
import
'debug.dart'
;
...
@@ -28,39 +27,22 @@ class BackButtonIcon extends StatelessWidget {
...
@@ -28,39 +27,22 @@ class BackButtonIcon extends StatelessWidget {
/// the current platform (as obtained from the [Theme]).
/// the current platform (as obtained from the [Theme]).
const
BackButtonIcon
({
super
.
key
});
const
BackButtonIcon
({
super
.
key
});
@override
/// Returns the appropriate "back" icon for the given `platform`.
Widget
build
(
BuildContext
context
)
{
static
IconData
_getIconData
(
TargetPlatform
platform
)
{
final
String
?
semanticsLabel
;
switch
(
platform
)
{
final
IconData
data
;
switch
(
Theme
.
of
(
context
).
platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
data
=
Icons
.
arrow_back
;
break
;
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
macOS
:
data
=
Icons
.
arrow_back_ios
;
break
;
}
// This can't use the platform from Theme because it is the Android OS that
// expects the duplicated tooltip and label.
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
android
:
semanticsLabel
=
MaterialLocalizations
.
of
(
context
).
backButtonTooltip
;
break
;
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
windows
:
return
Icons
.
arrow_back
;
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
macOS
:
semanticsLabel
=
null
;
return
Icons
.
arrow_back_ios
;
break
;
}
}
return
Icon
(
data
,
semanticLabel:
semanticsLabel
);
}
}
@override
Widget
build
(
BuildContext
context
)
=>
Icon
(
_getIconData
(
Theme
.
of
(
context
).
platform
));
}
}
/// A Material Design back button.
/// A Material Design back button.
...
@@ -167,23 +149,8 @@ class CloseButton extends StatelessWidget {
...
@@ -167,23 +149,8 @@ class CloseButton extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
String
?
semanticsLabel
;
// This can't use the platform from Theme because it is the Android OS that
// expects the duplicated tooltip and label.
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
semanticsLabel
=
MaterialLocalizations
.
of
(
context
).
closeButtonTooltip
;
break
;
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
macOS
:
semanticsLabel
=
null
;
break
;
}
return
IconButton
(
return
IconButton
(
icon:
Icon
(
Icons
.
close
,
semanticLabel:
semanticsLabel
),
icon:
const
Icon
(
Icons
.
close
),
color:
color
,
color:
color
,
tooltip:
MaterialLocalizations
.
of
(
context
).
closeButtonTooltip
,
tooltip:
MaterialLocalizations
.
of
(
context
).
closeButtonTooltip
,
onPressed:
()
{
onPressed:
()
{
...
...
packages/flutter/lib/src/widgets/semantics_debugger.dart
View file @
cc256c3e
...
@@ -288,14 +288,10 @@ class _SemanticsDebuggerPainter extends CustomPainter {
...
@@ -288,14 +288,10 @@ class _SemanticsDebuggerPainter extends CustomPainter {
assert
(
data
.
attributedLabel
!=
null
);
assert
(
data
.
attributedLabel
!=
null
);
final
String
message
;
final
String
message
;
// Android will avoid pronouncing duplicating tooltip and label.
// Therefore, having two identical strings is the same as having a single
// string.
final
bool
shouldIgnoreDuplicatedLabel
=
defaultTargetPlatform
==
TargetPlatform
.
android
&&
data
.
attributedLabel
.
string
==
data
.
tooltip
;
final
String
tooltipAndLabel
=
<
String
>[
final
String
tooltipAndLabel
=
<
String
>[
if
(
data
.
tooltip
.
isNotEmpty
)
if
(
data
.
tooltip
.
isNotEmpty
)
data
.
tooltip
,
data
.
tooltip
,
if
(
data
.
attributedLabel
.
string
.
isNotEmpty
&&
!
shouldIgnoreDuplicatedLabel
)
if
(
data
.
attributedLabel
.
string
.
isNotEmpty
)
data
.
attributedLabel
.
string
,
data
.
attributedLabel
.
string
,
].
join
(
'
\n
'
);
].
join
(
'
\n
'
);
if
(
tooltipAndLabel
.
isEmpty
)
{
if
(
tooltipAndLabel
.
isEmpty
)
{
...
...
packages/flutter/test/material/back_button_test.dart
View file @
cc256c3e
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -153,65 +152,9 @@ void main() {
...
@@ -153,65 +152,9 @@ void main() {
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pushNamed
(
'/next'
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pushNamed
(
'/next'
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
final
String
?
expectedLabel
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
expectedLabel
=
'Back'
;
break
;
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
expectedLabel
=
null
;
}
expect
(
tester
.
getSemantics
(
find
.
byType
(
BackButton
)),
matchesSemantics
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
BackButton
)),
matchesSemantics
(
tooltip:
'Back'
,
tooltip:
'Back'
,
label:
expectedLabel
,
isButton:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
hasTapAction:
true
,
isFocusable:
true
,
));
handle
.
dispose
();
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'CloseButton semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
const
Material
(
child:
Text
(
'Home'
)),
routes:
<
String
,
WidgetBuilder
>{
'/next'
:
(
BuildContext
context
)
{
return
const
Material
(
child:
Center
(
child:
CloseButton
(),
),
);
},
},
),
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pushNamed
(
'/next'
);
await
tester
.
pumpAndSettle
();
final
String
?
expectedLabel
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
expectedLabel
=
'Close'
;
break
;
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
expectedLabel
=
null
;
}
expect
(
tester
.
getSemantics
(
find
.
byType
(
CloseButton
)),
matchesSemantics
(
tooltip:
'Close'
,
label:
expectedLabel
,
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
@@ -219,7 +162,7 @@ void main() {
...
@@ -219,7 +162,7 @@ void main() {
isFocusable:
true
,
isFocusable:
true
,
));
));
handle
.
dispose
();
handle
.
dispose
();
}
,
variant:
TargetPlatformVariant
.
all
()
);
});
testWidgets
(
'CloseButton color'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'CloseButton color'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
cc256c3e
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -439,33 +438,6 @@ void main() {
...
@@ -439,33 +438,6 @@ void main() {
);
);
});
});
testWidgets
(
'SemanticsDebugger ignores duplicated label and tooltip for Android'
,
(
WidgetTester
tester
)
async
{
final
Key
child
=
UniqueKey
();
final
Key
debugger
=
UniqueKey
();
final
bool
isPlatformAndroid
=
defaultTargetPlatform
==
TargetPlatform
.
android
;
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SemanticsDebugger
(
key:
debugger
,
child:
Material
(
child:
Semantics
(
container:
true
,
key:
child
,
label:
'text'
,
tooltip:
'text'
,
),
),
),
),
);
expect
(
_getMessageShownInSemanticsDebugger
(
widgetKey:
child
,
debuggerKey:
debugger
,
tester:
tester
),
isPlatformAndroid
?
'text'
:
'text
\n
text'
,
);
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'SemanticsDebugger textfield'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'SemanticsDebugger textfield'
,
(
WidgetTester
tester
)
async
{
final
UniqueKey
textField
=
UniqueKey
();
final
UniqueKey
textField
=
UniqueKey
();
final
UniqueKey
debugger
=
UniqueKey
();
final
UniqueKey
debugger
=
UniqueKey
();
...
...
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