[accessibility] Announce index of tab in tab bar (#10664)
* [accessibility] Announce index if tab in tab bar * added TODO
This commit is contained in:
committed by
GitHub
parent
1a1bbacf0d
commit
7158646ba7
@@ -729,14 +729,21 @@ class _TabBarState extends State<TabBar> {
|
||||
// Add the tap handler to each tab. If the tab bar is scrollable
|
||||
// then give all of the tabs equal flexibility so that their widths
|
||||
// reflect the intrinsic width of their labels.
|
||||
for (int index = 0; index < widget.tabs.length; index++) {
|
||||
final int tabCount = widget.tabs.length;
|
||||
for (int index = 0; index < tabCount; index++) {
|
||||
wrappedTabs[index] = new MergeSemantics(
|
||||
child: new Semantics(
|
||||
selected: index == _currentIndex,
|
||||
child: new InkWell(
|
||||
onTap: () { _handleTap(index); },
|
||||
child: wrappedTabs[index],
|
||||
),
|
||||
child: new Stack(
|
||||
children: <Widget>[
|
||||
new InkWell(
|
||||
onTap: () { _handleTap(index); },
|
||||
child: wrappedTabs[index],
|
||||
),
|
||||
new Semantics(
|
||||
selected: index == _currentIndex,
|
||||
// TODO(goderbauer): I10N-ify
|
||||
label: 'Tab ${index + 1} of $tabCount',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!widget.isScrollable)
|
||||
|
||||
@@ -940,14 +940,14 @@ void main() {
|
||||
id: 2,
|
||||
actions: SemanticsAction.tap.index,
|
||||
flags: SemanticsFlags.isSelected.index,
|
||||
label: 'TAB #0',
|
||||
label: 'TAB #0\nTab 1 of 2',
|
||||
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, 46.0),
|
||||
transform: new Matrix4.translationValues(0.0, 276.0, 0.0),
|
||||
),
|
||||
new TestSemantics(
|
||||
id: 4,
|
||||
id: 5,
|
||||
actions: SemanticsAction.tap.index,
|
||||
label: 'TAB #1',
|
||||
label: 'TAB #1\nTab 2 of 2',
|
||||
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, 46.0),
|
||||
transform: new Matrix4.translationValues(108.0, 276.0, 0.0),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user