Add DisplayFeatureSubScreen widget#92907
Conversation
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
|
@goderbauer I addressed all your comments, but I think the whole widget would benefit from another look from you, since a lot of code was refactored. |
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
|
@goderbauer I need help. Is there a correct way of knowing the global position on screen of a render object during its layout phase? Is there any other solution I should try / consider? Here is what I looked at and tried. This widget needs to accomplish these points:
Here are the things I tried:
My conclusion so far is that the flutter layout algorithm ( |
|
cc @HansMuller, I mentioned this in a meeting today |
goderbauer
left a comment
There was a problem hiding this comment.
@andreidiaconu I believe your analysis in the previous comment is spot on. Thanks for writing that up so concisely; it's very helpful. This appears to be a more complex problem than initially thought. I don't have a good idea yet for how to make this better, unfortunately. I am still thinking about it.
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
I assume the Thank you for taking the time to think about this. |
|
Can we model this closer to what
Applied here, the new widget could always assume the the obstructions are in its local coordinates. It would then calculate EdgeInsets ("padding") for its child widget that would avoid the obstructions and put the child on one of the subscreens. It would then also wrap the child with a new MediaQuery that basically only covers the subscreen (e.g. size is adjusted, all obstructions that are outside this subscreen are removed, coordinates for remaining obstructions are adjusted, and all other properties are adjusted to pretend that the subscreen is the only screen space available). A convenience method like WDYT? |
|
I agree with your comparison of the two widgets and the solution does make sense. We would, however end up with two widgets that are very similar, solve the same problem and would be used together almost always. The docs for SafeArea actually say: I have two questions:
|
|
|
Would making SafeArea depend on a Directionality ancestor be a better solution? |
|
@goderbauer I made |
Piinks
left a comment
There was a problem hiding this comment.
This looks great!! Thanks for reworking it, and for your patience waiting for review. Mostly nits below.
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
|
@Piinks Thank you for the review. If anything else seems off, please let me know. |
Piinks
left a comment
There was a problem hiding this comment.
LGTM! Thank you! Can you rebase (not merge) with master to resolve the failing customer test?
|
This will need a second review in order to submit, @goderbauer can you take a look? |
… a new MediaQuery to the child
829926c to
88ea530
Compare
@Piinks Rebased, checks seem to pass. |
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/widgets/display_feature_sub_screen.dart
Outdated
Show resolved
Hide resolved
|
@goderbauer Made all the suggested changes and also rewrote the way I cap the anchorPoint. Please have another look. Thanks. |
This PR adds the
DisplayFeatureSubScreenwidget which positions itschildsuch that it avoids overlapping anyDisplayFeaturethat splits the screen into sub-screens. In practical terms, it helps with displaying content on only one of the screens on dual-screen foldables.This widget is needed for making modal routes and dialogs avoid overlapping display features.
Here is an example of the widget placing a dialog on one of the screens, instead of the middle of the screen (where the example device has a display feature):
This is split from a larger PR for foldable support in order to make it easier to review (#77156).
Issues that will be fixed by this PR:
Depends on:
PRs that depend on this:
Pre-launch Checklist
///).