Adjusts the Hindi TimeOfDayFormat to display in a LTR orientation in localizations. (#157998)

Fixes https://github.com/flutter/flutter/issues/156565
This update corrects the `TimeOfDayFormat` mapping for the Hindi language. Previously, the format was incorrectly set to `a_space_h_colon_mm` - (a h:mm), but it should be `h_colon_mm_space_a` - (h:mm a) since Hindi is a LTR language.
This commit is contained in:
Mairramer 2024-11-13 21:10:14 -03:00 committed by GitHub
parent 5f0f18d739
commit dec763979c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 2 deletions

View File

@ -18612,7 +18612,7 @@ class MaterialLocalizationHi extends GlobalMaterialLocalizations {
String get tabLabelRaw => r'$tabCount का टैब $tabIndex';
@override
TimeOfDayFormat get timeOfDayFormatRaw => TimeOfDayFormat.a_space_h_colon_mm;
TimeOfDayFormat get timeOfDayFormatRaw => TimeOfDayFormat.h_colon_mm_space_a;
@override
String get timePickerDialHelpText => 'समय चुनें';

View File

@ -1,6 +1,6 @@
{
"scriptCategory": "dense",
"timeOfDayFormat": "ah:mm",
"timeOfDayFormat": "h:mm a",
"openAppDrawerTooltip": "नेविगेशन मेन्यू खोलें",
"backButtonTooltip": "वापस जाएं",
"closeButtonTooltip": "बंद करें",

View File

@ -603,6 +603,38 @@ void main() {
labels00To22TwoDigit,
);
});
// Regression test for https://github.com/flutter/flutter/issues/156565
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Portrait', (WidgetTester tester) async {
const Locale locale = Locale('hi', 'HI');
final Offset centerPortrait = await startPicker(tester, (TimeOfDay? time) {}, locale: locale, useMaterial3: false, orientation: Orientation.portrait);
final Finder amButtonPortrait = find.text('AM');
final Finder pmButtonPortrait = find.text('PM') ;
final Offset amButtonPositionPortrait = tester.getCenter(amButtonPortrait);
final Offset pmButtonPositionPortrait = tester.getCenter(pmButtonPortrait);
expect(amButtonPositionPortrait.dx, greaterThan(centerPortrait.dx));
expect(pmButtonPositionPortrait.dx, greaterThan(centerPortrait.dx));
});
// Regression test for https://github.com/flutter/flutter/issues/156565
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Landscape', (WidgetTester tester) async {
const Locale locale = Locale('hi', 'HI');
final Offset centerLandscape = await startPicker(tester, (TimeOfDay? time) {}, locale: locale, useMaterial3: false, orientation: Orientation.landscape);
final Finder amButtonLandscape = find.text('AM');
final Finder pmButtonLandscape = find.text('PM');
final Offset amButtonPositionLandscape = tester.getCenter(amButtonLandscape);
final Offset pmButtonPositionLandscape = tester.getCenter(pmButtonLandscape);
expect(amButtonPositionLandscape.dy, greaterThan(centerLandscape.dy));
expect(pmButtonPositionLandscape.dy, greaterThan(centerLandscape.dy));
});
}
class _TimePickerLauncher extends StatelessWidget {
@ -611,12 +643,14 @@ class _TimePickerLauncher extends StatelessWidget {
required this.locale,
this.entryMode = TimePickerEntryMode.dial,
this.useMaterial3,
this.orientation,
});
final ValueChanged<TimeOfDay?>? onChanged;
final Locale locale;
final TimePickerEntryMode entryMode;
final bool? useMaterial3;
final Orientation? orientation;
@override
Widget build(BuildContext context) {
@ -635,6 +669,7 @@ class _TimePickerLauncher extends StatelessWidget {
onChanged?.call(await showTimePicker(
context: context,
initialEntryMode: entryMode,
orientation: orientation,
initialTime: const TimeOfDay(hour: 7, minute: 0),
));
},
@ -652,12 +687,14 @@ Future<Offset> startPicker(
ValueChanged<TimeOfDay?> onChanged, {
Locale locale = const Locale('en', 'US'),
bool? useMaterial3,
Orientation? orientation,
}) async {
await tester.pumpWidget(
_TimePickerLauncher(
onChanged: onChanged,
locale: locale,
useMaterial3: useMaterial3,
orientation: orientation,
),
);
await tester.tap(find.text('X'));