Date picker layout exceptions#31514
Date picker layout exceptions#31514darrenaustin merged 8 commits intoflutter:masterfrom darrenaustin:date_picker_layout
Conversation
…t removed hard coded sizes to allow the grid view to scroll instead of overflowing.
HansMuller
left a comment
There was a problem hiding this comment.
This looks good, just some minor feedback.
It would be helpful if the issue's description included a few before/after screenshots that illustrated the layout changes.
| child: GridView.custom( | ||
| gridDelegate: _kDayPickerGridDelegate, | ||
| childrenDelegate: SliverChildListDelegate(labels, addRepaintBoundaries: false), | ||
| padding: EdgeInsets.zero, |
There was a problem hiding this comment.
If we set this to zero don't we risk having the bottom of the grid end up behind the display's notch?
There was a problem hiding this comment.
I don't think so, as this GridView is embedded in a PageView.builder which puts the dialog header above it. If this padding isn't set to zero, by default there is an unneeded gap at the top of the grid, which will make it more likely that it will need to scroll on smaller screens.
| @override | ||
| Widget build(BuildContext context) { | ||
| return SizedBox( | ||
| width: _kMonthPickerPortraitWidth, |
There was a problem hiding this comment.
Looking at this through the github review microsope ... it seems odd to configure the height of the MonthPicker with _kMaxDayPickerHeight. If that's intentional, maybe a comment that explains why.
There was a problem hiding this comment.
Yeah, this is a bit weird. The MonthPicker just wraps the DayPicker with horizontal navigation to switch months. I added a comment that hopefully makes this easier to follow.
|
|
||
| void _screenConfigTests() { | ||
|
|
||
| const Size kPixel1Portrait = Size(1070, 1770); |
There was a problem hiding this comment.
A comment about these sizes, like what they're based on, why we chose them, would be helpful.
There was a problem hiding this comment.
Just pushed a fix that renamed them and commented them with hopefully better descriptions.
| } | ||
|
|
||
| void _screenConfigTests() { | ||
|
|
There was a problem hiding this comment.
Please insert a comment (probably several) like this here:
// Regression test for https://github.com/flutter/flutter/issues/21383
Or, if it makes more sense, in the specific testWidgets tests.
| } | ||
|
|
||
| testWidgets('display on Pixel1 - portrait', (WidgetTester tester) async { | ||
| await _showPicker(tester, kPixel1Portrait); |
There was a problem hiding this comment.
These tests are verifying that we don't assert. Just to make that clear it would be good to append:
expect(tester.takeException(), isNull);
There was a problem hiding this comment.
Nice suggestion. I have added this to all the tests.
| await tester.tap(find.text('ANNULER')); | ||
| }); | ||
|
|
||
| group('screen configurations', () { |
There was a problem hiding this comment.
What these tests have in common seems to be that we're varying locale?
There was a problem hiding this comment.
I renamed this group to "locale fonts don't overflow layout". Couldn't think of a better description. Let me know if you have one :).
|
|
||
| const Size kPixel1Portrait = Size(1070, 1770); | ||
| const Size kPixel1Landscape = Size(1770, 1070); | ||
| Future<void> _showPicker(WidgetTester tester, Locale locale, Size size) async { |
|
|
||
| group('screen configurations', () { | ||
|
|
||
| const Size kPixel1Portrait = Size(1070, 1770); |
There was a problem hiding this comment.
As before, maybe there's something to say about the sizes
- Renamed the sizes used for testing and documented them with comments. - Added more comments around the tests to better describe them and reference the bugs they test for.
…scape picker always try to take up 2/3 of the space and give the other 3rd to the header.
Description
This PR addresses several layout issues with the Material Date Picker when displaying on smaller sized devices or with an increased text scale factor. It removes several hard coded sizes that were causing the layouts to overflow. This change will lead to some awkward layouts with scrolling the month grid vertically, but it should no longer throw overflow exceptions. We will address smaller layouts more fully in a future update.
Example of layout fixes
Before/After on a Pixel with Large Text scale selected:
Before/After on a Pixel with a Chinese locale:
Before/After on a small display (320x521) with Large Text scale selected:
Related Issues
Fixes: #21383, #20171, #19744, #17745
Tests
I added the following tests:
A group of device configuration tests that will try to bring up the date picker in various sized screens, orientations and text scale factors.
A group of device configuration tests to the flutter_localizations tests to bring up the date picker in various locales that were having issues with layout.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?