Add missing space between DayPeriodControl and time control in time picker (#162230)
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> Fixes #162229 | Before | After | |--------|--------| |   |   | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
29a2f674ca
commit
bd055cf960
@ -267,10 +267,12 @@ class _TimePickerHeader extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
textDirection:
|
||||||
|
timeOfDayFormat == TimeOfDayFormat.a_space_h_colon_mm
|
||||||
|
? TextDirection.rtl
|
||||||
|
: TextDirection.ltr,
|
||||||
|
spacing: 12,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (hourDialType == _HourDialType.twelveHour &&
|
|
||||||
timeOfDayFormat == TimeOfDayFormat.a_space_h_colon_mm)
|
|
||||||
const _DayPeriodControl(),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
// Hour/minutes should not change positions in RTL locales.
|
// Hour/minutes should not change positions in RTL locales.
|
||||||
@ -282,11 +284,7 @@ class _TimePickerHeader extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (hourDialType == _HourDialType.twelveHour &&
|
if (hourDialType == _HourDialType.twelveHour) const _DayPeriodControl(),
|
||||||
timeOfDayFormat != TimeOfDayFormat.a_space_h_colon_mm) ...<Widget>[
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
const _DayPeriodControl(),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -303,29 +301,24 @@ class _TimePickerHeader extends StatelessWidget {
|
|||||||
_TimePickerModel.defaultThemeOf(context).helpTextStyle,
|
_TimePickerModel.defaultThemeOf(context).helpTextStyle,
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
|
verticalDirection:
|
||||||
|
timeOfDayFormat == TimeOfDayFormat.a_space_h_colon_mm
|
||||||
|
? VerticalDirection.up
|
||||||
|
: VerticalDirection.down,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 12,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (hourDialType == _HourDialType.twelveHour &&
|
Row(
|
||||||
timeOfDayFormat == TimeOfDayFormat.a_space_h_colon_mm)
|
// Hour/minutes should not change positions in RTL locales.
|
||||||
const _DayPeriodControl(),
|
textDirection: TextDirection.ltr,
|
||||||
Padding(
|
children: <Widget>[
|
||||||
padding: EdgeInsets.only(
|
const Expanded(child: _HourControl()),
|
||||||
bottom: hourDialType == _HourDialType.twelveHour ? 12 : 0,
|
_TimeSelectorSeparator(timeOfDayFormat: timeOfDayFormat),
|
||||||
),
|
const Expanded(child: _MinuteControl()),
|
||||||
child: Row(
|
],
|
||||||
// Hour/minutes should not change positions in RTL locales.
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
children: <Widget>[
|
|
||||||
const Expanded(child: _HourControl()),
|
|
||||||
_TimeSelectorSeparator(timeOfDayFormat: timeOfDayFormat),
|
|
||||||
const Expanded(child: _MinuteControl()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (hourDialType == _HourDialType.twelveHour &&
|
if (hourDialType == _HourDialType.twelveHour) const _DayPeriodControl(),
|
||||||
timeOfDayFormat != TimeOfDayFormat.a_space_h_colon_mm)
|
|
||||||
const _DayPeriodControl(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -10,6 +10,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import '../widgets/feedback_tester.dart';
|
import '../widgets/feedback_tester.dart';
|
||||||
@ -2162,6 +2163,56 @@ void main() {
|
|||||||
|
|
||||||
expect(tester.getSize(findBorderPainter().first), const Size(96.0, 70.0));
|
expect(tester.getSize(findBorderPainter().first), const Size(96.0, 70.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/162229.
|
||||||
|
testWidgets(
|
||||||
|
'Time picker spacing between time control and day period control for locales using "a h:mm" pattern',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
|
||||||
|
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||||
|
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||||
|
);
|
||||||
|
final Finder timeControlFinder =
|
||||||
|
find.ancestor(of: find.text('7'), matching: find.byType(Row)).first;
|
||||||
|
|
||||||
|
// Render in portrait mode.
|
||||||
|
tester.view.physicalSize = const Size(800, 800.5);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
await mediaQueryBoilerplate(
|
||||||
|
tester,
|
||||||
|
materialType: MaterialType.material3,
|
||||||
|
locale: const Locale('ko', 'KR'),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
tester.getBottomLeft(timeControlFinder).dx -
|
||||||
|
tester.getBottomRight(dayPeriodControlFinder).dx,
|
||||||
|
12,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Dismiss the dialog.
|
||||||
|
final MaterialLocalizations materialLocalizations = MaterialLocalizations.of(
|
||||||
|
tester.element(find.byType(TextButton).first),
|
||||||
|
);
|
||||||
|
await tester.tap(find.text(materialLocalizations.okButtonLabel));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Render in landscape mode.
|
||||||
|
tester.view.physicalSize = const Size(800.5, 800);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
await mediaQueryBoilerplate(
|
||||||
|
tester,
|
||||||
|
materialType: MaterialType.material3,
|
||||||
|
locale: const Locale('ko', 'KR'),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(timeControlFinder).dy - tester.getBottomLeft(dayPeriodControlFinder).dy,
|
||||||
|
12,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Finder findDialPaint = find.descendant(
|
final Finder findDialPaint = find.descendant(
|
||||||
@ -2204,15 +2255,16 @@ Future<void> mediaQueryBoilerplate(
|
|||||||
bool tapButton = true,
|
bool tapButton = true,
|
||||||
required MaterialType materialType,
|
required MaterialType materialType,
|
||||||
Orientation? orientation,
|
Orientation? orientation,
|
||||||
|
Locale locale = const Locale('en', 'US'),
|
||||||
}) async {
|
}) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
data: ThemeData(useMaterial3: materialType == MaterialType.material3),
|
data: ThemeData(useMaterial3: materialType == MaterialType.material3),
|
||||||
child: Localizations(
|
child: Localizations(
|
||||||
locale: const Locale('en', 'US'),
|
locale: locale,
|
||||||
delegates: const <LocalizationsDelegate<dynamic>>[
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
DefaultMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
DefaultWidgetsLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
],
|
],
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: MediaQueryData(
|
data: MediaQueryData(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user