Make time picker accessible (#13152)
* make time picker accessible * use new CustomPaint a11y API * flutter_localizations tests; use bigger distance delta * fix am/pm control; selected values * fix translations; remove @mustCallSuper in describeSemanticsConfiguration * exclude AM/PM announcement from iOS as on iOS the label is read back automatically
This commit is contained in:
@@ -140,57 +140,58 @@ void main() {
|
||||
],
|
||||
child: new MediaQuery(
|
||||
data: new MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat),
|
||||
child: new Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: new Navigator(
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
return new MaterialPageRoute<dynamic>(builder: (BuildContext context) {
|
||||
showTimePicker(context: context, initialTime: const TimeOfDay(hour: 7, minute: 0));
|
||||
return new Container();
|
||||
});
|
||||
},
|
||||
child: new Material(
|
||||
child: new Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: new Navigator(
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
return new MaterialPageRoute<dynamic>(builder: (BuildContext context) {
|
||||
return new FlatButton(
|
||||
onPressed: () {
|
||||
showTimePicker(context: context, initialTime: const TimeOfDay(hour: 7, minute: 0));
|
||||
},
|
||||
child: const Text('X'),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
// Pump once, because the dialog shows up asynchronously.
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('respects MediaQueryData.alwaysUse24HourFormat == false', (WidgetTester tester) async {
|
||||
await mediaQueryBoilerplate(tester, false);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_Dial'),
|
||||
matching: find.byType(CustomPaint),
|
||||
));
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
final List<TextPainter> primaryOuterLabels = dialPainter.primaryOuterLabels;
|
||||
expect(primaryOuterLabels.map((TextPainter tp) => tp.text.text), labels12To11);
|
||||
final List<dynamic> primaryOuterLabels = dialPainter.primaryOuterLabels;
|
||||
expect(primaryOuterLabels.map<String>((dynamic tp) => tp.painter.text.text), labels12To11);
|
||||
expect(dialPainter.primaryInnerLabels, null);
|
||||
|
||||
final List<TextPainter> secondaryOuterLabels = dialPainter.secondaryOuterLabels;
|
||||
expect(secondaryOuterLabels.map((TextPainter tp) => tp.text.text), labels12To11);
|
||||
final List<dynamic> secondaryOuterLabels = dialPainter.secondaryOuterLabels;
|
||||
expect(secondaryOuterLabels.map<String>((dynamic tp) => tp.painter.text.text), labels12To11);
|
||||
expect(dialPainter.secondaryInnerLabels, null);
|
||||
});
|
||||
|
||||
testWidgets('respects MediaQueryData.alwaysUse24HourFormat == true', (WidgetTester tester) async {
|
||||
await mediaQueryBoilerplate(tester, true);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_Dial'),
|
||||
matching: find.byType(CustomPaint),
|
||||
));
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
final List<TextPainter> primaryOuterLabels = dialPainter.primaryOuterLabels;
|
||||
expect(primaryOuterLabels.map((TextPainter tp) => tp.text.text), labels00To23);
|
||||
final List<TextPainter> primaryInnerLabels = dialPainter.primaryInnerLabels;
|
||||
expect(primaryInnerLabels.map((TextPainter tp) => tp.text.text), labels12To11TwoDigit);
|
||||
final List<dynamic> primaryOuterLabels = dialPainter.primaryOuterLabels;
|
||||
expect(primaryOuterLabels.map<String>((dynamic tp) => tp.painter.text.text), labels00To23);
|
||||
final List<dynamic> primaryInnerLabels = dialPainter.primaryInnerLabels;
|
||||
expect(primaryInnerLabels.map<String>((dynamic tp) => tp.painter.text.text), labels12To11TwoDigit);
|
||||
|
||||
final List<TextPainter> secondaryOuterLabels = dialPainter.secondaryOuterLabels;
|
||||
expect(secondaryOuterLabels.map((TextPainter tp) => tp.text.text), labels00To23);
|
||||
final List<TextPainter> secondaryInnerLabels = dialPainter.secondaryInnerLabels;
|
||||
expect(secondaryInnerLabels.map((TextPainter tp) => tp.text.text), labels12To11TwoDigit);
|
||||
final List<dynamic> secondaryOuterLabels = dialPainter.secondaryOuterLabels;
|
||||
expect(secondaryOuterLabels.map<String>((dynamic tp) => tp.painter.text.text), labels00To23);
|
||||
final List<dynamic> secondaryInnerLabels = dialPainter.secondaryInnerLabels;
|
||||
expect(secondaryInnerLabels.map<String>((dynamic tp) => tp.painter.text.text), labels12To11TwoDigit);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user