forked from firka/flutter
Assorted a11y fixes (#14395)
This commit is contained in:
committed by
GitHub
parent
882be89e4c
commit
b54b576c1a
@@ -19,23 +19,27 @@ class SectionCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: <Color>[
|
||||
section.leftColor,
|
||||
section.rightColor,
|
||||
],
|
||||
return new Semantics(
|
||||
label: section.title,
|
||||
button: true,
|
||||
child: new DecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: <Color>[
|
||||
section.leftColor,
|
||||
section.rightColor,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: new Image.asset(
|
||||
section.backgroundAsset,
|
||||
package: section.backgroundAssetPackage,
|
||||
color: const Color.fromRGBO(255, 255, 255, 0.075),
|
||||
colorBlendMode: BlendMode.modulate,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: new Image.asset(
|
||||
section.backgroundAsset,
|
||||
package: section.backgroundAssetPackage,
|
||||
color: const Color.fromRGBO(255, 255, 255, 0.075),
|
||||
colorBlendMode: BlendMode.modulate,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ class ExitButton extends StatelessWidget {
|
||||
child: const Tooltip(
|
||||
message: 'Back',
|
||||
child: const Text('Exit'),
|
||||
excludeFromSemantics: true,
|
||||
),
|
||||
onPressed: () {
|
||||
// The demo is on the root navigator.
|
||||
|
||||
@@ -218,14 +218,20 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: const Icon(Icons.thumb_up),
|
||||
icon: const Icon(
|
||||
Icons.thumb_up,
|
||||
semanticLabel: 'Thumbs up',
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() => iconButtonToggle = !iconButtonToggle);
|
||||
},
|
||||
color: iconButtonToggle ? Theme.of(context).primaryColor : null,
|
||||
),
|
||||
const IconButton(
|
||||
icon: const Icon(Icons.thumb_up),
|
||||
icon: const Icon(
|
||||
Icons.thumb_up,
|
||||
semanticLabel: 'Thumbs up',
|
||||
),
|
||||
onPressed: null,
|
||||
)
|
||||
]
|
||||
|
||||
@@ -108,21 +108,24 @@ class _IconsDemoCard extends StatelessWidget {
|
||||
return new Card(
|
||||
child: new DefaultTextStyle(
|
||||
style: textStyle,
|
||||
child: new Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
children: <TableRow> [
|
||||
new TableRow(
|
||||
children: <Widget> [
|
||||
_centeredText('Size'),
|
||||
_centeredText('Enabled'),
|
||||
_centeredText('Disabled'),
|
||||
]
|
||||
),
|
||||
_buildIconRow(18.0),
|
||||
_buildIconRow(24.0),
|
||||
_buildIconRow(36.0),
|
||||
_buildIconRow(48.0),
|
||||
],
|
||||
child: new Semantics(
|
||||
explicitChildNodes: true,
|
||||
child: new Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
children: <TableRow> [
|
||||
new TableRow(
|
||||
children: <Widget> [
|
||||
_centeredText('Size'),
|
||||
_centeredText('Enabled'),
|
||||
_centeredText('Disabled'),
|
||||
]
|
||||
),
|
||||
_buildIconRow(18.0),
|
||||
_buildIconRow(24.0),
|
||||
_buildIconRow(36.0),
|
||||
_buildIconRow(48.0),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -76,7 +76,10 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: _showMessage,
|
||||
backgroundColor: Colors.redAccent,
|
||||
child: const Icon(Icons.add)
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
semanticLabel: 'Add',
|
||||
),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RaisedButton(
|
||||
|
||||
@@ -154,7 +154,10 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
leading: new IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
icon: const Icon(
|
||||
Icons.clear,
|
||||
semanticLabel: 'Close',
|
||||
),
|
||||
onPressed: () { Navigator.pop(context); }
|
||||
),
|
||||
title: const Text('Example code')
|
||||
|
||||
@@ -52,51 +52,54 @@ class _GalleryDrawerHeaderState extends State<GalleryDrawerHeader> {
|
||||
Widget build(BuildContext context) {
|
||||
final double systemTopPadding = MediaQuery.of(context).padding.top;
|
||||
|
||||
return new DrawerHeader(
|
||||
decoration: new FlutterLogoDecoration(
|
||||
margin: new EdgeInsets.fromLTRB(12.0, 12.0 + systemTopPadding, 12.0, 12.0),
|
||||
style: _logoHasName ? _logoHorizontal ? FlutterLogoStyle.horizontal
|
||||
: FlutterLogoStyle.stacked
|
||||
: FlutterLogoStyle.markOnly,
|
||||
lightColor: _logoColor.shade400,
|
||||
darkColor: _logoColor.shade900,
|
||||
textColor: widget.light ? const Color(0xFF616161) : const Color(0xFF9E9E9E),
|
||||
return new Semantics(
|
||||
label: 'Flutter',
|
||||
child: new DrawerHeader(
|
||||
decoration: new FlutterLogoDecoration(
|
||||
margin: new EdgeInsets.fromLTRB(12.0, 12.0 + systemTopPadding, 12.0, 12.0),
|
||||
style: _logoHasName ? _logoHorizontal ? FlutterLogoStyle.horizontal
|
||||
: FlutterLogoStyle.stacked
|
||||
: FlutterLogoStyle.markOnly,
|
||||
lightColor: _logoColor.shade400,
|
||||
darkColor: _logoColor.shade900,
|
||||
textColor: widget.light ? const Color(0xFF616161) : const Color(0xFF9E9E9E),
|
||||
),
|
||||
duration: const Duration(milliseconds: 750),
|
||||
child: new GestureDetector(
|
||||
onLongPress: () {
|
||||
setState(() {
|
||||
_logoHorizontal = !_logoHorizontal;
|
||||
if (!_logoHasName)
|
||||
_logoHasName = true;
|
||||
});
|
||||
},
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_logoHasName = !_logoHasName;
|
||||
});
|
||||
},
|
||||
onDoubleTap: () {
|
||||
setState(() {
|
||||
final List<MaterialColor> options = <MaterialColor>[];
|
||||
if (_logoColor != Colors.blue)
|
||||
options.addAll(<MaterialColor>[Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue]);
|
||||
if (_logoColor != Colors.amber)
|
||||
options.addAll(<MaterialColor>[Colors.amber, Colors.amber, Colors.amber]);
|
||||
if (_logoColor != Colors.red)
|
||||
options.addAll(<MaterialColor>[Colors.red, Colors.red, Colors.red]);
|
||||
if (_logoColor != Colors.indigo)
|
||||
options.addAll(<MaterialColor>[Colors.indigo, Colors.indigo, Colors.indigo]);
|
||||
if (_logoColor != Colors.pink)
|
||||
options.addAll(<MaterialColor>[Colors.pink]);
|
||||
if (_logoColor != Colors.purple)
|
||||
options.addAll(<MaterialColor>[Colors.purple]);
|
||||
if (_logoColor != Colors.cyan)
|
||||
options.addAll(<MaterialColor>[Colors.cyan]);
|
||||
_logoColor = options[new math.Random().nextInt(options.length)];
|
||||
});
|
||||
}
|
||||
),
|
||||
),
|
||||
duration: const Duration(milliseconds: 750),
|
||||
child: new GestureDetector(
|
||||
onLongPress: () {
|
||||
setState(() {
|
||||
_logoHorizontal = !_logoHorizontal;
|
||||
if (!_logoHasName)
|
||||
_logoHasName = true;
|
||||
});
|
||||
},
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_logoHasName = !_logoHasName;
|
||||
});
|
||||
},
|
||||
onDoubleTap: () {
|
||||
setState(() {
|
||||
final List<MaterialColor> options = <MaterialColor>[];
|
||||
if (_logoColor != Colors.blue)
|
||||
options.addAll(<MaterialColor>[Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue, Colors.blue]);
|
||||
if (_logoColor != Colors.amber)
|
||||
options.addAll(<MaterialColor>[Colors.amber, Colors.amber, Colors.amber]);
|
||||
if (_logoColor != Colors.red)
|
||||
options.addAll(<MaterialColor>[Colors.red, Colors.red, Colors.red]);
|
||||
if (_logoColor != Colors.indigo)
|
||||
options.addAll(<MaterialColor>[Colors.indigo, Colors.indigo, Colors.indigo]);
|
||||
if (_logoColor != Colors.pink)
|
||||
options.addAll(<MaterialColor>[Colors.pink]);
|
||||
if (_logoColor != Colors.purple)
|
||||
options.addAll(<MaterialColor>[Colors.purple]);
|
||||
if (_logoColor != Colors.cyan)
|
||||
options.addAll(<MaterialColor>[Colors.cyan]);
|
||||
_logoColor = options[new math.Random().nextInt(options.length)];
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user