From 792c98751f96afb36692060f8042e43142175450 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Mon, 10 Jul 2017 17:37:21 -0700 Subject: [PATCH] a11y fix for list_demo.dart (#11142) * a11y fix for list_demo.dart * fix semantics of persistant bottom sheet --- .../lib/demo/material/list_demo.dart | 168 ++++++++++-------- 1 file changed, 92 insertions(+), 76 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/material/list_demo.dart b/examples/flutter_gallery/lib/demo/material/list_demo.dart index dff92d768e..f14b6906f0 100644 --- a/examples/flutter_gallery/lib/demo/material/list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/list_demo.dart @@ -58,83 +58,97 @@ class _ListDemoState extends State { shrinkWrap: true, primary: false, children: [ - new ListTile( - dense: true, - title: const Text('One-line'), - trailing: new Radio<_MaterialListType>( - value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, - groupValue: _itemType, - onChanged: changeItemType, - ) - ), - new ListTile( - dense: true, - title: const Text('Two-line'), - trailing: new Radio<_MaterialListType>( - value: _MaterialListType.twoLine, - groupValue: _itemType, - onChanged: changeItemType, - ) - ), - new ListTile( - dense: true, - title: const Text('Three-line'), - trailing: new Radio<_MaterialListType>( - value: _MaterialListType.threeLine, - groupValue: _itemType, - onChanged: changeItemType, + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('One-line'), + trailing: new Radio<_MaterialListType>( + value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, + groupValue: _itemType, + onChanged: changeItemType, + ) ), ), - new ListTile( - dense: true, - title: const Text('Show avatar'), - trailing: new Checkbox( - value: _showAvatars, - onChanged: (bool value) { - setState(() { - _showAvatars = value; - }); - _bottomSheet?.setState(() { }); - }, + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Two-line'), + trailing: new Radio<_MaterialListType>( + value: _MaterialListType.twoLine, + groupValue: _itemType, + onChanged: changeItemType, + ) ), ), - new ListTile( - dense: true, - title: const Text('Show icon'), - trailing: new Checkbox( - value: _showIcons, - onChanged: (bool value) { - setState(() { - _showIcons = value; - }); - _bottomSheet?.setState(() { }); - }, + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Three-line'), + trailing: new Radio<_MaterialListType>( + value: _MaterialListType.threeLine, + groupValue: _itemType, + onChanged: changeItemType, + ), ), ), - new ListTile( - dense: true, - title: const Text('Show dividers'), - trailing: new Checkbox( - value: _showDividers, - onChanged: (bool value) { - setState(() { - _showDividers = value; - }); - _bottomSheet?.setState(() { }); - }, + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Show avatar'), + trailing: new Checkbox( + value: _showAvatars, + onChanged: (bool value) { + setState(() { + _showAvatars = value; + }); + _bottomSheet?.setState(() { }); + }, + ), ), ), - new ListTile( - dense: true, - title: const Text('Dense layout'), - trailing: new Checkbox( - value: _dense, - onChanged: (bool value) { - setState(() { - _dense = value; - }); - _bottomSheet?.setState(() { }); - }, + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Show icon'), + trailing: new Checkbox( + value: _showIcons, + onChanged: (bool value) { + setState(() { + _showIcons = value; + }); + _bottomSheet?.setState(() { }); + }, + ), + ), + ), + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Show dividers'), + trailing: new Checkbox( + value: _showDividers, + onChanged: (bool value) { + setState(() { + _showDividers = value; + }); + _bottomSheet?.setState(() { }); + }, + ), + ), + ), + new MergeSemantics( + child: new ListTile( + dense: true, + title: const Text('Dense layout'), + trailing: new Checkbox( + value: _dense, + onChanged: (bool value) { + setState(() { + _dense = value; + }); + _bottomSheet?.setState(() { }); + }, + ), ), ), ], @@ -164,13 +178,15 @@ class _ListDemoState extends State { "Even more additional list item information appears on line three.", ); } - return new ListTile( - isThreeLine: _itemType == _MaterialListType.threeLine, - dense: _dense, - leading: _showAvatars ? new CircleAvatar(child: new Text(item)) : null, - title: new Text('This item represents $item.'), - subtitle: secondary, - trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null, + return new MergeSemantics( + child: new ListTile( + isThreeLine: _itemType == _MaterialListType.threeLine, + dense: _dense, + leading: _showAvatars ? new ExcludeSemantics(child: new CircleAvatar(child: new Text(item))) : null, + title: new Text('This item represents $item.'), + subtitle: secondary, + trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null, + ), ); }