Skip to content

Commit

Permalink
fix accessibility issues (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii-Borodenko authored Dec 13, 2023
1 parent faf151a commit 049e4de
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 67 deletions.
2 changes: 1 addition & 1 deletion lib/src/screens/settings/display_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DisplaySettingsPage extends BasePage {
},
),
if (responsiveLayoutUtil.shouldRenderMobileUI && DeviceInfo.instance.isMobile)
SettingsThemeChoicesCell(_displaySettingsViewModel),
Semantics(label: S.current.color_theme, child: SettingsThemeChoicesCell(_displaySettingsViewModel)),
],
),
);
Expand Down
100 changes: 52 additions & 48 deletions lib/src/screens/settings/widgets/settings_theme_choice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,57 +54,61 @@ class SettingsThemeChoicesCell extends StatelessWidget {

return Padding(
padding: EdgeInsets.all(5),
child: GestureDetector(
onTap: () {
_displaySettingsViewModel.setTheme(e);
},
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cellRadius),
border: isSelected
? Border.all(
color: Theme.of(context).primaryColor)
: null,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor
.withOpacity(
currentTheme.brightness == Brightness.light
? 0.1
: 0.3),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(cellRadius),
bottomLeft: Radius.circular(cellRadius)),
color: e.themeData.primaryColor,
child: Semantics(
label: e.toString(),
selected: isSelected,
child: GestureDetector(
onTap: () {
_displaySettingsViewModel.setTheme(e);
},
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cellRadius),
border: isSelected
? Border.all(
color: Theme.of(context).primaryColor)
: null,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor
.withOpacity(
currentTheme.brightness == Brightness.light
? 0.1
: 0.3),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(cellRadius),
bottomLeft: Radius.circular(cellRadius)),
color: e.themeData.primaryColor,
),
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
color: e.themeData.colorScheme.background,
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
color: e.themeData.colorScheme.background,
),
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(cellRadius),
bottomRight: Radius.circular(cellRadius)),
color: e.themeData.cardColor,
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(cellRadius),
bottomRight: Radius.circular(cellRadius)),
color: e.themeData.cardColor,
),
),
),
],
],
),
),
),
),
Expand Down
40 changes: 22 additions & 18 deletions lib/src/widgets/standard_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@ class StandardSwitch extends StatefulWidget {
class StandardSwitchState extends State<StandardSwitch> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: widget.onTaped,
child: AnimatedContainer(
padding: EdgeInsets.only(left: 2.0, right: 2.0),
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
duration: Duration(milliseconds: 250),
width: 50,
height: 28,
decoration: BoxDecoration(
color: widget.value
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor,
borderRadius: BorderRadius.all(Radius.circular(14.0))),
child: Container(
width: 24.0,
height: 24.0,

return Semantics(
toggled: widget.value,
child: GestureDetector(
onTap: widget.onTaped,
child: AnimatedContainer(
padding: EdgeInsets.only(left: 2.0, right: 2.0),
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
duration: Duration(milliseconds: 250),
width: 50,
height: 28,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle),
color: widget.value
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor,
borderRadius: BorderRadius.all(Radius.circular(14.0))),
child: Container(
width: 24.0,
height: 24.0,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle),
),
),
),
);
Expand Down

0 comments on commit 049e4de

Please sign in to comment.