From 7607eebd388b521306cc9e77c8a6d8819009f68f Mon Sep 17 00:00:00 2001 From: Ben Hills Date: Sat, 27 Apr 2024 16:44:15 +0100 Subject: [PATCH] Fix semantics on layout selector to read selected button. --- lib/ui/widgets/layout_selector.dart | 41 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/ui/widgets/layout_selector.dart b/lib/ui/widgets/layout_selector.dart index 3a238216..102134c6 100644 --- a/lib/ui/widgets/layout_selector.dart +++ b/lib/ui/widgets/layout_selector.dart @@ -64,9 +64,11 @@ class _LayoutSelectorWidgetState extends State { size: 18, ), ), - Text( - L.of(context)!.layout_label, - style: Theme.of(context).textTheme.titleMedium, + ExcludeSemantics( + child: Text( + L.of(context)!.layout_label, + style: Theme.of(context).textTheme.titleMedium, + ), ), ], )), @@ -82,10 +84,13 @@ class _LayoutSelectorWidgetState extends State { style: OutlinedButton.styleFrom( backgroundColor: mode == 0 ? Theme.of(context).primaryColor : null, ), - child: Icon( - Icons.list, - semanticLabel: L.of(context)!.semantics_layout_option_list, - color: mode == 0 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + child: Semantics( + selected: mode == 0, + label: L.of(context)!.semantics_layout_option_list, + child: Icon( + Icons.list, + color: mode == 0 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + ), ), ), ), @@ -100,10 +105,13 @@ class _LayoutSelectorWidgetState extends State { style: OutlinedButton.styleFrom( backgroundColor: mode == 1 ? Theme.of(context).primaryColor : null, ), - child: Icon( - Icons.grid_on, - semanticLabel: L.of(context)!.semantics_layout_option_compact_grid, - color: mode == 1 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + child: Semantics( + selected: mode == 1, + label: L.of(context)!.semantics_layout_option_compact_grid, + child: Icon( + Icons.grid_on, + color: mode == 1 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + ), ), ), ), @@ -118,10 +126,13 @@ class _LayoutSelectorWidgetState extends State { style: OutlinedButton.styleFrom( backgroundColor: mode == 2 ? Theme.of(context).primaryColor : null, ), - child: Icon( - Icons.grid_view, - semanticLabel: L.of(context)!.semantics_layout_option_grid, - color: mode == 2 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + child: Semantics( + selected: mode == 2, + label: L.of(context)!.semantics_layout_option_grid, + child: Icon( + Icons.grid_view, + color: mode == 2 ? Theme.of(context).canvasColor : Theme.of(context).primaryColor, + ), ), ), ),