From 49bcda52a2c39ba1468ef094583039e346b5c6c1 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 31 May 2018 10:45:07 -0700 Subject: [PATCH] remove ExcludeSemantics from bottom app bar demo (#18033) --- .../demo/material/bottom_app_bar_demo.dart | 69 +++++++++++-------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart index e2c9d1c168e..36fd59357b8 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart @@ -97,19 +97,19 @@ class _BottomAppBarDemoState extends State { // App bar color - static const List kBabColors = const [ - null, - const Color(0xFFFFC100), - const Color(0xFF91FAFF), - const Color(0xFF00D1FF), - const Color(0xFF00BCFF), - const Color(0xFF009BEE), + static const List<_NamedColor> kBabColors = const <_NamedColor>[ + const _NamedColor(null, 'Clear'), + const _NamedColor(const Color(0xFFFFC100), 'Orange'), + const _NamedColor(const Color(0xFF91FAFF), 'Light Blue'), + const _NamedColor(const Color(0xFF00D1FF), 'Cyan'), + const _NamedColor(const Color(0xFF00BCFF), 'Cerulean'), + const _NamedColor(const Color(0xFF009BEE), 'Blue'), ]; _ChoiceValue _fabShape = kCircularFab; _ChoiceValue _showNotch = kShowNotchTrue; _ChoiceValue _fabLocation = kFabEndDocked; - Color _babColor = kBabColors.first; + Color _babColor = kBabColors.first.color; void _onShowNotchChanged(_ChoiceValue value) { setState(() { @@ -250,37 +250,46 @@ class _RadioItem extends StatelessWidget { } } +class _NamedColor { + const _NamedColor(this.color, this.name); + + final Color color; + final String name; +} + class _ColorsItem extends StatelessWidget { const _ColorsItem(this.colors, this.selectedColor, this.onChanged); - final List colors; + final List<_NamedColor> colors; final Color selectedColor; final ValueChanged onChanged; @override Widget build(BuildContext context) { - return new ExcludeSemantics( - child: new Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: colors.map((Color color) { - return new RawMaterialButton( - onPressed: () { - onChanged(color); - }, - constraints: const BoxConstraints.tightFor( - width: 32.0, - height: 32.0, + return new Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: colors.map((_NamedColor namedColor) { + return new RawMaterialButton( + onPressed: () { + onChanged(namedColor.color); + }, + constraints: const BoxConstraints.tightFor( + width: 32.0, + height: 32.0, + ), + fillColor: namedColor.color, + shape: new CircleBorder( + side: new BorderSide( + color: namedColor.color == selectedColor ? Colors.black : const Color(0xFFD5D7DA), + width: 2.0, ), - fillColor: color, - shape: new CircleBorder( - side: new BorderSide( - color: color == selectedColor ? Colors.black : const Color(0xFFD5D7DA), - width: 2.0, - ), - ), - ); - }).toList(), - ), + ), + child: new Semantics( + value: namedColor.name, + selected: namedColor.color == selectedColor, + ), + ); + }).toList(), ); } }