Skip to content

Commit 1b96b02

Browse files
Rishika-devmarcnause
authored andcommitted
fix: Expose selected state in digital wave controls
The SQR1-SQR4 and Freq/Phase/Duty buttons of the digital wave generator showed which option is active only through their background colour, so screen readers could not tell which one was selected. Wrap each button label in Semantics(selected:), using the same condition that already picks its colour. The label's semantics merge into the button, and the rendering and button behaviour are unchanged. Addresses #3348
1 parent 4c4ab60 commit 1b96b02

1 file changed

Lines changed: 68 additions & 35 deletions

File tree

‎lib/view/widgets/digital_waveform_controls.dart‎

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
4646
borderRadius: BorderRadius.circular(6),
4747
),
4848
),
49-
child: Text(
50-
appLocalizations.sqr1.toUpperCase(),
51-
style: TextStyle(
52-
color: Colors.white,
53-
fontSize: 14,
49+
child: Semantics(
50+
selected:
51+
waveGeneratorStateProvider.selectedDigitalWave ==
52+
WaveConst.sqr1,
53+
child: Text(
54+
appLocalizations.sqr1.toUpperCase(),
55+
style: TextStyle(
56+
color: Colors.white,
57+
fontSize: 14,
58+
),
5459
),
5560
),
5661
onPressed: () => {
@@ -74,11 +79,16 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
7479
borderRadius: BorderRadius.circular(6),
7580
),
7681
),
77-
child: Text(
78-
appLocalizations.sqr2.toUpperCase(),
79-
style: TextStyle(
80-
color: Colors.white,
81-
fontSize: 14,
82+
child: Semantics(
83+
selected:
84+
waveGeneratorStateProvider.selectedDigitalWave ==
85+
WaveConst.sqr2,
86+
child: Text(
87+
appLocalizations.sqr2.toUpperCase(),
88+
style: TextStyle(
89+
color: Colors.white,
90+
fontSize: 14,
91+
),
8292
),
8393
),
8494
onPressed: () => {
@@ -102,11 +112,16 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
102112
borderRadius: BorderRadius.circular(6),
103113
),
104114
),
105-
child: Text(
106-
appLocalizations.sqr3.toUpperCase(),
107-
style: TextStyle(
108-
color: Colors.white,
109-
fontSize: 14,
115+
child: Semantics(
116+
selected:
117+
waveGeneratorStateProvider.selectedDigitalWave ==
118+
WaveConst.sqr3,
119+
child: Text(
120+
appLocalizations.sqr3.toUpperCase(),
121+
style: TextStyle(
122+
color: Colors.white,
123+
fontSize: 14,
124+
),
110125
),
111126
),
112127
onPressed: () => {
@@ -130,11 +145,16 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
130145
borderRadius: BorderRadius.circular(6),
131146
),
132147
),
133-
child: Text(
134-
appLocalizations.sqr4.toUpperCase(),
135-
style: TextStyle(
136-
color: Colors.white,
137-
fontSize: 14,
148+
child: Semantics(
149+
selected:
150+
waveGeneratorStateProvider.selectedDigitalWave ==
151+
WaveConst.sqr4,
152+
child: Text(
153+
appLocalizations.sqr4.toUpperCase(),
154+
style: TextStyle(
155+
color: Colors.white,
156+
fontSize: 14,
157+
),
138158
),
139159
),
140160
onPressed: () => {
@@ -167,11 +187,15 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
167187
borderRadius: BorderRadius.circular(6),
168188
),
169189
),
170-
child: Text(
171-
appLocalizations.freq,
172-
style: TextStyle(
173-
color: Colors.white,
174-
fontSize: 14,
190+
child: Semantics(
191+
selected: waveGeneratorStateProvider.propSelected ==
192+
WaveConst.frequency,
193+
child: Text(
194+
appLocalizations.freq,
195+
style: TextStyle(
196+
color: Colors.white,
197+
fontSize: 14,
198+
),
175199
),
176200
),
177201
onPressed: () => {
@@ -198,11 +222,16 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
198222
borderRadius: BorderRadius.circular(6),
199223
),
200224
),
201-
child: Text(
202-
appLocalizations.phase,
203-
style: TextStyle(
204-
color: Colors.white,
205-
fontSize: 14,
225+
child: Semantics(
226+
selected:
227+
waveGeneratorStateProvider.propSelected ==
228+
WaveConst.phase,
229+
child: Text(
230+
appLocalizations.phase,
231+
style: TextStyle(
232+
color: Colors.white,
233+
fontSize: 14,
234+
),
206235
),
207236
),
208237
onPressed: () => {
@@ -228,11 +257,15 @@ class _DigitalWaveformControlsState extends State<DigitalWaveformControls> {
228257
borderRadius: BorderRadius.circular(6),
229258
),
230259
),
231-
child: Text(
232-
appLocalizations.duty,
233-
style: TextStyle(
234-
color: Colors.white,
235-
fontSize: 14,
260+
child: Semantics(
261+
selected: waveGeneratorStateProvider.propSelected ==
262+
WaveConst.duty,
263+
child: Text(
264+
appLocalizations.duty,
265+
style: TextStyle(
266+
color: Colors.white,
267+
fontSize: 14,
268+
),
236269
),
237270
),
238271
onPressed: () => {

0 commit comments

Comments
 (0)