Skip to content

Commit 160ff6a

Browse files
fix(#218): add Semantics() widget to tabs for accessibility
1 parent ddb58b0 commit 160ff6a

File tree

7 files changed

+51
-30
lines changed

7 files changed

+51
-30
lines changed

lib/src/style/fixed_circle_tab_style.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ class FixedCircleTabStyle extends InnerBuilder {
7373
var children = noLabel
7474
? <Widget>[icon]
7575
: <Widget>[icon, Text(item.title ?? '', style: textStyle)];
76-
return Container(
77-
padding: EdgeInsets.only(bottom: 2),
78-
child: Column(
79-
mainAxisAlignment: MainAxisAlignment.center,
80-
children: children,
76+
return Semantics(
77+
label: item.title,
78+
child: Container(
79+
padding: EdgeInsets.only(bottom: 2),
80+
child: Column(
81+
mainAxisAlignment: MainAxisAlignment.center,
82+
children: children,
83+
),
8184
),
8285
);
8386
}

lib/src/style/fixed_tab_style.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ class FixedTabStyle extends InnerBuilder {
6767
var children = noLabel
6868
? <Widget>[icon]
6969
: <Widget>[icon, Text(item.title ?? '', style: textStyle)];
70-
return Container(
71-
padding: EdgeInsets.only(bottom: 2),
72-
child: Column(
73-
mainAxisAlignment: MainAxisAlignment.end,
74-
children: children,
70+
return Semantics(
71+
label: item.title,
72+
child: Container(
73+
padding: EdgeInsets.only(bottom: 2),
74+
child: Column(
75+
mainAxisAlignment: MainAxisAlignment.end,
76+
children: children,
77+
),
7578
),
7679
);
7780
}

lib/src/style/flip_tab_style.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ class FlipTabStyle extends InnerBuilder {
7575
curve: curve,
7676
);
7777
}
78-
return Center(
79-
child: BlendImageIcon(
80-
item.icon,
81-
color: item.blend ? color : null,
82-
size: style.iconSize,
78+
return Semantics(
79+
label: item.title,
80+
child: Center(
81+
child: BlendImageIcon(
82+
item.icon,
83+
color: item.blend ? color : null,
84+
size: style.iconSize,
85+
),
8386
),
8487
);
8588
}

lib/src/style/react_circle_tab_style.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ class ReactCircleTabStyle extends InnerBuilder {
7878
if (!noLabel) {
7979
children.add(Text(item.title ?? '', style: textStyle));
8080
}
81-
return Container(
82-
padding: EdgeInsets.only(bottom: 2),
83-
child: Column(
84-
mainAxisAlignment: MainAxisAlignment.center,
85-
children: children,
81+
return Semantics(
82+
label: item.title,
83+
child: Container(
84+
padding: EdgeInsets.only(bottom: 2),
85+
child: Column(
86+
mainAxisAlignment: MainAxisAlignment.center,
87+
children: children,
88+
),
8689
),
8790
);
8891
}

lib/src/style/react_tab_style.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ class ReactTabStyle extends InnerBuilder {
7373
children.add(Text(item.title ?? '',
7474
style: style.textStyle(color, item.fontFamily)));
7575
}
76-
return Container(
77-
padding: const EdgeInsets.only(bottom: 2),
78-
child: Column(
79-
mainAxisAlignment:
80-
noLabel ? MainAxisAlignment.center : MainAxisAlignment.end,
81-
children: children,
76+
return Semantics(
77+
label: item.title,
78+
child: Container(
79+
padding: const EdgeInsets.only(bottom: 2),
80+
child: Column(
81+
mainAxisAlignment:
82+
noLabel ? MainAxisAlignment.center : MainAxisAlignment.end,
83+
children: children,
84+
),
8285
),
8386
);
8487
}

lib/src/style/textin_tab_style.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ class TextInTabStyle extends InnerBuilder {
6363
);
6464
}
6565

66-
return Center(
67-
child: BlendImageIcon(item.icon,
68-
size: style.iconSize, color: item.blend ? color : null),
66+
return Semantics(
67+
label: item.title,
68+
child: Center(
69+
child: BlendImageIcon(item.icon,
70+
size: style.iconSize, color: item.blend ? color : null),
71+
),
6972
);
7073
}
7174
}

lib/src/style/titled_tab_style.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class TitledTabStyle extends InnerBuilder {
9797
],
9898
);
9999
}
100-
return Center(child: Text(item.title ?? '', style: textStyle));
100+
return Semantics(
101+
label: item.title,
102+
child: Center(child: Text(item.title ?? '', style: textStyle)),
103+
);
101104
}
102105
}

0 commit comments

Comments
 (0)