-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] [iPad] fix avoid bottom inset in split view mode #35535
[iOS] [iPad] fix avoid bottom inset in split view mode #35535
Conversation
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 (don't just cc him here, he won't see it! He's on Discord!). 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. |
Looks like the bug wasn't what I thought in flutter/flutter#109845 (comment). @LongCatIsLooong @justinmc Are you the right people to review this? @RichardFevrier, tests need to be added in order for this PR to land. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to review it! I'm no expert on the iOS embedder but this seems reasonable to me. +1 that this needs tests.
I don't know why we used keyboardWillBeHidden in the first place instead of keyboardWillChangeFrame. Seems like this should all still work though, but me or someone else should probably try this out locally and confirm that nothing seems broken.
@@ -1190,12 +1185,19 @@ - (void)updateViewportPadding { | |||
|
|||
#pragma mark - Keyboard events | |||
|
|||
// using keyboardWillChangeFrame instead of keyboardWill(Show/Hide) because of split/floating | |||
// keyboard on iPad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capital letter at the beginning and period at the end. Also maybe link to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that this week 👍
|
||
// Ignore keyboard notifications related to other apps. | ||
// Ignore keyboard notifications related to other apps if not dismissing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you show the keyboard in the other app, then tap the Flutter app's text field?
I haven't tried it, just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works normally,
- the keyboard appear on the other app and the other app is resized
- the textfield in the flutter app becomes the first responder so the flutter app is resized at that moment.
I can make a video if necessary
[[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | ||
[self startKeyBoardAnimation:duration]; | ||
} | ||
// Get the animation duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Period at the end (I know you didn't write this comment, but it's a good chance to fix it! 😁).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that this week 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also make sure this change doesn't regress flutter/flutter#99951
@@ -1190,12 +1185,19 @@ - (void)updateViewportPadding { | |||
|
|||
#pragma mark - Keyboard events | |||
|
|||
// using keyboardWillChangeFrame instead of keyboardWill(Show/Hide) because of split/floating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "keybaordWill(show/hide), but we don't have a "keyboardWillShow", maybe just "keyboardWillBeHidden"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyboardWillShow/keyboardWillHide are part of the UIKit framework; so keyboardWillBeHidden is not appropriated here and my comment is still relevant 🙂
BTW I tried to answer to you in my opened issue last week but I could not without closing the issue.
(nothing related but I loved the document you wrote related to blurs... so interesting to read !)
|
||
// Ignore keyboard notifications related to other apps. | ||
// Ignore keyboard notifications related to other apps if not dismissing. | ||
bool isDismissing = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
bool isShowing = CGRectIntersection(keyboardFrame, screenRect);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll fix that this week 👍
id isLocal = info[UIKeyboardIsLocalUserInfoKey]; | ||
if (isLocal && ![isLocal boolValue]) { | ||
if (!isDismissing && isLocal && ![isLocal boolValue]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested If the keyboard is brought be by the other app, does the Flutter app's bottom inset adjust? This logic here seems to prevent Flutter app's bottom inset to be adjusted to the correct value in that case. Which is what I was saying in: flutter/flutter#109845 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I wrote to @justinmc, if the keyboard is brought by an other app:
- the keyboard appear on the other app and the other app is resized
- (if you tap in the textfield on the flutter app) the textfield in the flutter app becomes the first responder so the flutter app is resized at that moment.
This is the correct behavior since natives apps have that one.
// Get the animation duration | ||
NSTimeInterval duration = | ||
[[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | ||
|
||
// Considering the iPad's split keyboard, Flutter needs to check if the keyboard frame is present | ||
// in the screen to see if the keyboard is visible. | ||
if (CGRectIntersectsRect(keyboardFrame, screenRect)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be changed to if (isShowing) {
if you take my suggestion above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that this week 👍
Worse than that @justinmc, it calls twice the animation via Also something that I wanted to say the week before without closing the issue is:
I can try that @cyanglaz on my iPad but is there not a Unit test to check it automatically? And last point, I am okay to make a Unit Test to avoid regressions on that point, but is it possible to write Unit test for split view apps with your framework? Thanks. |
Maybe just delete the code below can fix this? // Delete this code in keyboardWillBeHidden
id isLocal = info[UIKeyboardIsLocalUserInfoKey];
if (isLocal && ![isLocal boolValue]) {
return;
} |
Updated: So this look seems better, and we just need to make sure that the |
@RichardFevrier were you able to figure out how to write the split view mode integration tests? Also it looks like @luckysmg had some suggestions. |
We do have unit-tests cover it but not integration test. It would be nice to at least do a manual test to make sure it is not regressed. If it is, then we will need to add better tests for flutter/flutter#99951 I think we can land this PR when 1. Unit-tests (or even better integration tests) are added, 2. When we did a manual test that flutter/flutter#99951 is not regressed. |
It seems like this is still WIP. Adding the labels. If OTOH no progress is being made, perhaps we can close this? |
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. |
@RichardFevrier Thank you for your contribution. This PR has been superseded by #37719 cc @vashworth. If you're still seeing issues related to split view mode please file new issues and we'll take a look! |
Fix flutter/flutter#109845
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.