Skip to content

Foldable support & TwoPane Widget#77156

Closed
andreidiaconu wants to merge 19 commits intoflutter:masterfrom
andreidiaconu:foldable_support
Closed

Foldable support & TwoPane Widget#77156
andreidiaconu wants to merge 19 commits intoflutter:masterfrom
andreidiaconu:foldable_support

Conversation

@andreidiaconu
Copy link
Contributor

  • Adds support for foldable devices and display cutouts, in the form of Display Features exposed by MediaQuery.
  • Adds TwoPane, a widget which helps with layouts on dual-screen devices and scaling a two pane design on larger screens.
  • Adds HingeAvoidingModalWrapper, a widget can be used at the root of a Popup route in order to make the contents avoid the hinge area. It determines the safe areas of the display and uses one of them to render its child.
  • Makes dialogs aware of the hinge, so they don't overlap.

This is based on the Engine support for Display Features: flutter/engine#24756

A display feature is an area of the display that is obstructed by a hardware feature. For now, this works only on Android. There are three types of display features:

  • Hinge - a physical separator between the two displays of the device.
    display-feature-hinge
  • Fold - You can view the fold like a hinge that has zero width. It tells us where the flexible display has a crease.
    display-feature-fold
  • Cutout - A cutout sits at the edge of the display and usually houses camera systems.
    display-feature-cutout

Here is a preview of what this PR enables, on a dual-screen emulator:

hinge-aware-dialog-right

Issues that will be closed by this PR:

Work in progress:

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Mar 3, 2021
@google-cla google-cla bot added the cla: yes label Mar 3, 2021
@goderbauer goderbauer self-requested a review March 4, 2021 16:58
@goderbauer
Copy link
Member

Thanks for the PR. Unfortunately, this PR is in many aspects not following our style guide (see also https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo). Most of the issues are also pointed out by the analyzer (flutter analyze --flutter-repo). There's also commented out code in the PR making it unclear whether this is just a draft or if it's actually ready for review. Can you please clean this up to make it easier to actually review this? Thanks!

@andreidiaconu
Copy link
Contributor Author

@goderbauer Yes. Will ping you when this is higher quality and also has tests.

@goderbauer
Copy link
Member

OK, marking this as draft for now.

@goderbauer goderbauer marked this pull request as draft March 16, 2021 19:26
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@goderbauer
Copy link
Member

Some overall feedback from scanning through the code: It would be good to keep this a little more generic. The Dialogs and Pop-ups for example need to avoid all kinds of display obstructions and the API shouldn't assume that these obstructions divide the rendering space into two "screens" (not all obstructions will do). So, having a screen argument doesn't seem ideal. As an idea, maybe we could have an anchorPoint argument instead that specifies if the dialog cannot be rendered at its natural point (e.g. due to obstructions) it is pulled towards that point to stay clear of those obstructions. The point the user touched on screen to trigger the dialog could be used as a natural anchor point for most use cases, presumably. If no anchor point is provided, we'd use a heuristic to avoid obstructions (e.g. prefer higher over lower, prefer the leading edge over the trailing edge, etc).

Also, the TwoPane seems pretty specific to certain phone hardware and its also pretty independent of the framework. That widget may be best distributed as part of an external package.

@andreidiaconu
Copy link
Contributor Author

andreidiaconu commented Mar 17, 2021 via email

@andreidiaconu
Copy link
Contributor Author

@goderbauer The code is now in line with the style guide and gives no messages during analyze. Made the dialogs use anchorPoint and fallback on Directionality. I'm turning my attention to tests. Since we want all checks to pass before we consider this Ready for review, this means that flutter/engine#24756 needs to be merged first - I will update you when we make progress on that.

For now I just wanted to let you know that your concerns were addressed, in case you want to give this another look and provide any other feedback.

…port

# Conflicts:
#	packages/flutter/lib/src/material/bottom_sheet.dart
#	packages/flutter/lib/src/material/date_picker.dart
#	packages/flutter/lib/src/material/popup_menu.dart
#	packages/flutter/lib/src/widgets/routes.dart
@andreidiaconu
Copy link
Contributor Author

@goderbauer I would like to offer an update on this PR:

  • The Engine PR that this depends on is now out of WIP status. It was marked as WIP while we waited for its main dependency, androidx.window, to be promoted to beta.
  • This PR now has tests for all the components it touches and the documentation is better.

The current status for this PR is that we are waiting for the Engine PR to be merged, but the code is ready for review, in case we want to speed things along in the meantime. I will gladly address any feedback I get, as I already did up to this point.

@blasten
Copy link

blasten commented Aug 26, 2021

PTAL @goderbauer

…port

# Conflicts:
#	packages/flutter/test/material/bottom_sheet_test.dart
@goderbauer
Copy link
Member

I believe this PR would be easier to review, land, and (if necessary) revert if it were split up into multiple PRs, one per feature listed in the bullet list in the PR's description.

@andreidiaconu
Copy link
Contributor Author

Ok, I will split this into multiple PRs.

@12people
Copy link

@andreidiaconu Any updates on this?

@andreidiaconu
Copy link
Contributor Author

@andreidiaconu Any updates on this?

Yes, the Engine changes are now able to make progress #89511 and once those are merged, focus moves to this. Also, I am breaking ths PR into smaller, more focused ones this week.

…port

# Conflicts:
#	packages/flutter/lib/src/material/time_picker.dart
#	packages/flutter/test/material/bottom_sheet_test.dart
@andreidiaconu
Copy link
Contributor Author

andreidiaconu commented Nov 2, 2021

Here are the PRs that were split from this:

Edit: And they can be reviewed in that order. The first one would be #92906 since all the other depend on it.

Everything still depends on getting the Engine support merged:

@blasten @goderbauer I am closing this PR as it is now replaced by 4 other smaller PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants