Ensure cupertino time picker positions hours and minutes correctly for RTL (#63405)
This commit is contained in:
@@ -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() {
|
|||||||
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user