mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Ensure cupertino time picker positions hours and minutes correctly for RTL (#63405)
This commit is contained in:
parent
e8c942104b
commit
fafeb6c647
@ -948,10 +948,11 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
|
||||
_getEstimatedColumnWidth(_PickerColumnType.hour),
|
||||
_getEstimatedColumnWidth(_PickerColumnType.minute),
|
||||
];
|
||||
final List<_ColumnBuilder> pickerBuilders = <_ColumnBuilder>[
|
||||
_buildHourPicker,
|
||||
_buildMinutePicker,
|
||||
];
|
||||
|
||||
// Swap the hours and minutes if RTL to ensure they are in the correct position.
|
||||
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.
|
||||
if (!widget.use24hFormat) {
|
||||
|
||||
@ -1215,6 +1215,31 @@ void main() {
|
||||
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user