-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiate between Window padding and margins in dart:ui #12895
Comments
If I understand correctly, the change you propose will break BC of a lot of widgets (internal and external). In my mind there are 3 possible use cases for this API:
With you current API proposal it would be tricky to reach goal 2 because I expect the bottom padding to become 0 when the keyboard is shown (otherwise it wouldn't be anymore On the other hand if you decide to keep the padding always to the same value when the keyboard is open, the Dev would need to perform some math in order to reach goal 3 (because (s)he would have to sum the padding of the window only when the keyboard is not shown) . E.g. see this SO question: https://stackoverflow.com/questions/45399178/extend-ios-11-safe-area-to-include-the-keyboard. I think that a better approach for this API would be to provide a way to reach goals 1, 2 and 3 without requiring additional efforts. Maybe something like This way you will be BC in a way that will require Dev intervention (in most of the cases they will just have to replace I hope I was clear enough. |
@sroddy thanks for the feedback!
Just to clear up what might be a misunderstanding: the intent here is not to blindly apply the iOS safe areas as additional padding within the margin, it's to do the appropriate rect intersections in the engine such that the correct margin and padding are exposed to the framework and developers without any additional work necessary from widget authors. Today, the only known use-case for
And a similarly terrible rendition with the keyboard closed:
This fixes an inconsistency in the framework today. Bottom padding is treated differently from all other padding. Specifically, in Scaffold, bottom padding is used to reduce the scaffold body height by the height of the keyboard; i.e., effectively positions the bottom of the body at the top edge of the keyboard to allow the user to scroll the entire view without it being under the keyboard. Top padding, on the other hand, is treatable as a drawable area (e.g., under the status bar) under which you want additional padding so that widgets the user may need to interact with aren't blocked by system chrome. As part of this change, Scaffold will be updated to use That said, @Hixie and I were just discussing a case the current design doesn't account for. I'll add it in a followup comment momentarily, since this one is now pretty huge :) |
The case this design doesn't cover is a Imagine such a scaffold where the body is a Under the proposed design, the placeholder will have a height equal to the view height minus top padding (status bar) minus bottom padding (home indicator). The problem is that when the keyboard is closed, bottom padding == safe Area height. When the keyboard is open, the proposed design specifies that The goal with using a The end result is likely that I'll adapt the current prototype implementation to use two sets of view-relative insets and add an additional framework widget (or adapt safearea) to handle both types. Thanks again for prompting this discussion and for your feedback and input! |
@cbracken Exactly! The The thing I was proposing for the API is to expose two "computed" values but in a way that imho would be more pragmatic for the developer:
I would personally advise against using terms like |
Yep. Given the discussion, we won't use |
Work is now complete in the engine and framework.
Engine work for iOS is complete. For Android it may be useful to consider the desired behaviour when the system Navigation Bar (back/home/app switcher) is translucent and make similar adaptations. Similarly, the Essential phone allows for a translucent status bar (though I believe it requires whitelisting with Essential). |
This is now also complete for Android. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
There are two different sets of view insets that applications may want
to track in order to avoid unwanted interaction with system UI:
view: e.g., when the keyboard opens, it occludes the bottom of the
screen and the view should be adjusted such that the bottom, for the
purposes of scrolling is just above the keyboard.
application should draw. e.g., the Home indicator on the iPhone X
typically appears near the bottom of the screen, overlaid over app
content. Content should be rendered within this 'safe area' but apps
should avoid requiring user interaction there. For example, list
views may want to include some small amount of additional padding to
ensure the last list item can scroll above this area.
Flutter does not currently distinguish between these two cases. For example, padding is used to:
We should track these insets separately:
margin
: a set of view insets that describe areas which apps should consider occluded by system UI (e.g. keyboard).padding
: a set of insets (relative to the inner edge of the margin) that describe areas that the app should consider visible/drawable, but within which apps should avoid requiring user interaction, since it may be hijacked by the OS, such as near the iPhone X home indicator.The text was updated successfully, but these errors were encountered: