Unverified Commit fafeb6c6 authored by Rami's avatar Rami Committed by GitHub

Ensure cupertino time picker positions hours and minutes correctly for RTL (#63405)

parent e8c94210
...@@ -948,10 +948,11 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> { ...@@ -948,10 +948,11 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
_getEstimatedColumnWidth(_PickerColumnType.hour), _getEstimatedColumnWidth(_PickerColumnType.hour),
_getEstimatedColumnWidth(_PickerColumnType.minute), _getEstimatedColumnWidth(_PickerColumnType.minute),
]; ];
final List<_ColumnBuilder> pickerBuilders = <_ColumnBuilder>[
_buildHourPicker, // Swap the hours and minutes if RTL to ensure they are in the correct position.
_buildMinutePicker, final List<_ColumnBuilder> pickerBuilders = Directionality.of(context) == TextDirection.rtl
]; ? <_ColumnBuilder>[_buildMinutePicker, _buildHourPicker]
: <_ColumnBuilder>[_buildHourPicker, _buildMinutePicker];
// Adds am/pm column if the picker is not using 24h format. // Adds am/pm column if the picker is not using 24h format.
if (!widget.use24hFormat) { if (!widget.use24hFormat) {
......
...@@ -1215,6 +1215,31 @@ void main() { ...@@ -1215,6 +1215,31 @@ void main() {
matchesGoldenFile('date_picker_test.datetime.drag.png'), matchesGoldenFile('date_picker_test.datetime.drag.png'),
); );
}); });
testWidgets('DatePicker displays hours and minutes correctly in RTL', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Directionality(
textDirection: TextDirection.rtl,
child: Center(
child: SizedBox(
width: 500,
height: 400,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: DateTime(2019, 1, 1, 4),
onDateTimeChanged: (_) {},
),
),
),
),
),
);
final double hourLeft = tester.getTopLeft(find.text('4')).dx;
final double minuteLeft = tester.getTopLeft(find.text('00')).dx;
expect(hourLeft, lessThan(minuteLeft));
});
}); });
testWidgets('TimerPicker golden tests', (WidgetTester tester) async { testWidgets('TimerPicker golden tests', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment