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
7ff13ca4
Unverified
Commit
7ff13ca4
authored
Oct 01, 2021
by
Fernando Moraes
Committed by
GitHub
Oct 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update TabPageSelector Semantics Label Localization (#87430)
parent
0e72f992
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
27 deletions
+176
-27
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+2
-1
page_selector_test.dart
packages/flutter/test/material/page_selector_test.dart
+33
-26
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+83
-0
tabs_test.dart
packages/flutter_localizations/test/material/tabs_test.dart
+58
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
7ff13ca4
...
...
@@ -1604,6 +1604,7 @@ class TabPageSelector extends StatelessWidget {
final
ColorTween
selectedColorTween
=
ColorTween
(
begin:
fixColor
,
end:
fixSelectedColor
);
final
ColorTween
previousColorTween
=
ColorTween
(
begin:
fixSelectedColor
,
end:
fixColor
);
final
TabController
?
tabController
=
controller
??
DefaultTabController
.
of
(
context
);
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
assert
(()
{
if
(
tabController
==
null
)
{
throw
FlutterError
(
...
...
@@ -1624,7 +1625,7 @@ class TabPageSelector extends StatelessWidget {
animation:
animation
,
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Semantics
(
label:
'Page
${tabController.index + 1}
of
${tabController.length}
'
,
label:
localizations
.
tabLabel
(
tabIndex:
tabController
.
index
+
1
,
tabCount:
tabController
.
length
)
,
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
List
<
Widget
>.
generate
(
tabController
.
length
,
(
int
tabIndex
)
{
...
...
packages/flutter/test/material/page_selector_test.dart
View file @
7ff13ca4
...
...
@@ -9,7 +9,13 @@ const Color kSelectedColor = Color(0xFF00FF00);
const
Color
kUnselectedColor
=
Colors
.
transparent
;
Widget
buildFrame
(
TabController
tabController
,
{
Color
?
color
,
Color
?
selectedColor
,
double
indicatorSize
=
12.0
})
{
return
Directionality
(
return
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Theme
(
data:
ThemeData
(
colorScheme:
const
ColorScheme
.
light
().
copyWith
(
secondary:
kSelectedColor
)),
...
...
@@ -42,6 +48,7 @@ Widget buildFrame(TabController tabController, { Color? color, Color? selectedCo
),
),
),
),
);
}
...
...
packages/flutter/test/material/tabs_test.dart
View file @
7ff13ca4
...
...
@@ -3857,6 +3857,89 @@ void main() {
final
Tab
firstTab
=
tester
.
widget
(
find
.
widgetWithIcon
(
Tab
,
Icons
.
check
));
expect
(
firstTab
.
height
,
85
);
});
testWidgets
(
'Test semantics of TabPageSelector'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TabController
controller
=
TabController
(
vsync:
const
TestVSync
(),
length:
2
,
initialIndex:
0
,
);
await
tester
.
pumpWidget
(
boilerplate
(
child:
Column
(
children:
<
Widget
>[
TabBar
(
controller:
controller
,
indicatorWeight:
30.0
,
tabs:
const
<
Widget
>[
Tab
(
text:
'TAB1'
),
Tab
(
text:
'TAB2'
)],
),
Flexible
(
child:
TabBarView
(
controller:
controller
,
children:
const
<
Widget
>[
Text
(
'PAGE1'
),
Text
(
'PAGE2'
)],
),
),
Expanded
(
child:
TabPageSelector
(
controller:
controller
)
),
],
),
),
);
final
TestSemantics
expectedSemantics
=
TestSemantics
.
root
(
children:
<
TestSemantics
>[
TestSemantics
.
rootChild
(
label:
'Tab 1 of 2'
,
id:
1
,
rect:
TestSemantics
.
fullScreen
,
children:
<
TestSemantics
>[
TestSemantics
(
label:
'TAB1
\n
Tab 1 of 2'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isFocusable
,
SemanticsFlag
.
isSelected
],
id:
2
,
rect:
TestSemantics
.
fullScreen
,
actions:
1
,
),
TestSemantics
(
label:
'TAB2
\n
Tab 2 of 2'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isFocusable
],
id:
3
,
rect:
TestSemantics
.
fullScreen
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
),
TestSemantics
(
id:
4
,
rect:
TestSemantics
.
fullScreen
,
children:
<
TestSemantics
>[
TestSemantics
(
id:
6
,
rect:
TestSemantics
.
fullScreen
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
scrollLeft
],
children:
<
TestSemantics
>[
TestSemantics
(
id:
5
,
rect:
TestSemantics
.
fullScreen
,
label:
'PAGE1'
),
]
),
],
),
],
),
],
);
expect
(
semantics
,
hasSemantics
(
expectedSemantics
,
ignoreRect:
true
,
ignoreTransform:
true
));
semantics
.
dispose
();
});
}
class
KeepAliveInk
extends
StatefulWidget
{
...
...
packages/flutter_localizations/test/material/tabs_test.dart
0 → 100644
View file @
7ff13ca4
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_localizations/flutter_localizations.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Test semantics of TabPageSelector in pt-BR'
,
(
WidgetTester
tester
)
async
{
final
TabController
controller
=
TabController
(
vsync:
const
TestVSync
(),
length:
2
,
initialIndex:
0
,
);
await
tester
.
pumpWidget
(
Localizations
(
locale:
const
Locale
(
'pt'
,
'BR'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
GlobalMaterialLocalizations
.
delegate
,
GlobalWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Column
(
children:
<
Widget
>[
TabBar
(
controller:
controller
,
indicatorWeight:
30.0
,
tabs:
const
<
Widget
>[
Tab
(
text:
'TAB1'
),
Tab
(
text:
'TAB2'
)],
),
Flexible
(
child:
TabBarView
(
controller:
controller
,
children:
const
<
Widget
>[
Text
(
'PAGE1'
),
Text
(
'PAGE2'
)],
),
),
Expanded
(
child:
TabPageSelector
(
controller:
controller
)),
],
),
),
),
),
);
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
expect
(
tester
.
getSemantics
(
find
.
byType
(
TabPageSelector
)),
matchesSemantics
(
label:
'Guia 1 de 2'
));
handle
.
dispose
();
});
}
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