fix accessibility issues (#1224)

Serhii committed Dec 13, 2023 at 17:27 UTC 049e4def274132fe2e902a7c7d6d36e5e776a63c
3 files changed +75 -67
lib/src/screens/settings/display_settings_page.dart
+1 -1
@@ -76,7 +76,7 @@ class DisplaySettingsPage extends BasePage {
76 },
77 ),
78 if (responsiveLayoutUtil.shouldRenderMobileUI && DeviceInfo.instance.isMobile)
79 - SettingsThemeChoicesCell(_displaySettingsViewModel),
79 + Semantics(label: S.current.color_theme, child: SettingsThemeChoicesCell(_displaySettingsViewModel)),
80 ],
81 ),
82 );
lib/src/screens/settings/widgets/settings_theme_choice.dart
+52 -48
@@ -54,57 +54,61 @@ class SettingsThemeChoicesCell extends StatelessWidget {
54
55 return Padding(
56 padding: EdgeInsets.all(5),
57 - child: GestureDetector(
58 - onTap: () {
59 - _displaySettingsViewModel.setTheme(e);
60 - },
61 - child: Container(
62 - padding: EdgeInsets.all(5),
63 - decoration: BoxDecoration(
64 - borderRadius: BorderRadius.circular(cellRadius),
65 - border: isSelected
66 - ? Border.all(
67 - color: Theme.of(context).primaryColor)
68 - : null,
69 - color: Theme.of(context)
70 - .extension<CakeTextTheme>()!
71 - .secondaryTextColor
72 - .withOpacity(
73 - currentTheme.brightness == Brightness.light
74 - ? 0.1
75 - : 0.3),
76 - ),
77 - child: Row(
78 - mainAxisAlignment: MainAxisAlignment.center,
79 - children: [
80 - Container(
81 - padding: EdgeInsets.symmetric(
82 - horizontal: cellWidth, vertical: cellHeight),
83 - decoration: BoxDecoration(
84 - borderRadius: BorderRadius.only(
85 - topLeft: Radius.circular(cellRadius),
86 - bottomLeft: Radius.circular(cellRadius)),
87 - color: e.themeData.primaryColor,
57 + child: Semantics(
58 + label: e.toString(),
59 + selected: isSelected,
60 + child: GestureDetector(
61 + onTap: () {
62 + _displaySettingsViewModel.setTheme(e);
63 + },
64 + child: Container(
65 + padding: EdgeInsets.all(5),
66 + decoration: BoxDecoration(
67 + borderRadius: BorderRadius.circular(cellRadius),
68 + border: isSelected
69 + ? Border.all(
70 + color: Theme.of(context).primaryColor)
71 + : null,
72 + color: Theme.of(context)
73 + .extension<CakeTextTheme>()!
74 + .secondaryTextColor
75 + .withOpacity(
76 + currentTheme.brightness == Brightness.light
77 + ? 0.1
78 + : 0.3),
79 + ),
80 + child: Row(
81 + mainAxisAlignment: MainAxisAlignment.center,
82 + children: [
83 + Container(
84 + padding: EdgeInsets.symmetric(
85 + horizontal: cellWidth, vertical: cellHeight),
86 + decoration: BoxDecoration(
87 + borderRadius: BorderRadius.only(
88 + topLeft: Radius.circular(cellRadius),
89 + bottomLeft: Radius.circular(cellRadius)),
90 + color: e.themeData.primaryColor,
91 + ),
92 ),
89 - ),
90 - Container(
91 - padding: EdgeInsets.symmetric(
92 - horizontal: cellWidth, vertical: cellHeight),
93 - decoration: BoxDecoration(
94 - color: e.themeData.colorScheme.background,
93 + Container(
94 + padding: EdgeInsets.symmetric(
95 + horizontal: cellWidth, vertical: cellHeight),
96 + decoration: BoxDecoration(
97 + color: e.themeData.colorScheme.background,
98 + ),
99 ),
96 - ),
97 - Container(
98 - padding: EdgeInsets.symmetric(
99 - horizontal: cellWidth, vertical: cellHeight),
100 - decoration: BoxDecoration(
101 - borderRadius: BorderRadius.only(
102 - topRight: Radius.circular(cellRadius),
103 - bottomRight: Radius.circular(cellRadius)),
104 - color: e.themeData.cardColor,
100 + Container(
101 + padding: EdgeInsets.symmetric(
102 + horizontal: cellWidth, vertical: cellHeight),
103 + decoration: BoxDecoration(
104 + borderRadius: BorderRadius.only(
105 + topRight: Radius.circular(cellRadius),
106 + bottomRight: Radius.circular(cellRadius)),
107 + color: e.themeData.cardColor,
108 + ),
109 ),
106 - ),
107 - ],
110 + ],
111 + ),
112 ),
113 ),
114 ),
lib/src/widgets/standard_switch.dart
+22 -18
@@ -14,25 +14,29 @@ class StandardSwitch extends StatefulWidget {
14 class StandardSwitchState extends State<StandardSwitch> {
15 @override
16 Widget build(BuildContext context) {
17 - return GestureDetector(
18 - onTap: widget.onTaped,
19 - child: AnimatedContainer(
20 - padding: EdgeInsets.only(left: 2.0, right: 2.0),
21 - alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
22 - duration: Duration(milliseconds: 250),
23 - width: 50,
24 - height: 28,
25 - decoration: BoxDecoration(
26 - color: widget.value
27 - ? Theme.of(context).primaryColor
28 - : Theme.of(context).disabledColor,
29 - borderRadius: BorderRadius.all(Radius.circular(14.0))),
30 - child: Container(
31 - width: 24.0,
32 - height: 24.0,
17 +
18 + return Semantics(
19 + toggled: widget.value,
20 + child: GestureDetector(
21 + onTap: widget.onTaped,
22 + child: AnimatedContainer(
23 + padding: EdgeInsets.only(left: 2.0, right: 2.0),
24 + alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
25 + duration: Duration(milliseconds: 250),
26 + width: 50,
27 + height: 28,
28 decoration: BoxDecoration(
34 - color: Colors.white,
35 - shape: BoxShape.circle),
29 + color: widget.value
30 + ? Theme.of(context).primaryColor
31 + : Theme.of(context).disabledColor,
32 + borderRadius: BorderRadius.all(Radius.circular(14.0))),
33 + child: Container(
34 + width: 24.0,
35 + height: 24.0,
36 + decoration: BoxDecoration(
37 + color: Colors.white,
38 + shape: BoxShape.circle),
39 + ),
40 ),
41 ),
42 );