-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Fix:Keyboard inset is not correct when presenting a native ViewController on FlutterViewController #29862
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1200,9 +1200,10 @@ - (void)startKeyBoardAnimation:(NSTimeInterval)duration { | |||||||||||||
| } | ||||||||||||||
| completion:^(BOOL finished) { | ||||||||||||||
| if (self.displayLink == currentDisplayLink) { | ||||||||||||||
| // Indicates the displaylink captured by this block is the original one,which also | ||||||||||||||
| // indicates the animation has not been interrupted from its beginning. Moreover,indicates | ||||||||||||||
| // the animation is over and there is no more animation about to exectute. | ||||||||||||||
|
Comment on lines
+1203
to
+1205
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| [self invalidateDisplayLink]; | ||||||||||||||
| } | ||||||||||||||
| if (finished) { | ||||||||||||||
|
Comment on lines
-1204
to
-1205
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this looks like a good change to me. This will be tricky to write a test for.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will definitely be tricky to test. I don't love the partial mocks we use for this now since we're not really testing the behavior, but that the code is being executed in the right order engine/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm Lines 187 to 190 in 2962099
This doesn't really test that the change is fixed, but you could add an expectation/verification that the engine
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test passed on this diff and fails on }];
+
+ XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"];
+ OCMStub([mockEngine updateViewportMetrics:flutter::ViewportMetrics()])
+ .ignoringNonObjectArgs()
+ .andDo(^(NSInvocation* invocation) {
+ [expectation fulfill];
+ });
id viewControllerMock = OCMPartialMock(viewController);
[viewControllerMock keyboardWillChangeFrame:notification];
OCMVerify([viewControllerMock startKeyBoardAnimation:0.25]);
+ [self waitForExpectationsWithTimeout:5.0 handler:nil];
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took the liberty of pushing this test to your fork since this bug fix is blocking an internal release. Hope you don't mind. 🙂 |
||||||||||||||
| [self removeKeyboardAnimationView]; | ||||||||||||||
| [self ensureViewportMetricsIsCorrect]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,9 +173,17 @@ - (void)testkeyboardWillChangeFrameWillStartKeyboardAnimation { | |
| @"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25], | ||
| @"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal] | ||
| }]; | ||
|
|
||
| XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gaaclarke would you mind reviewing this test change? I just added it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
| OCMStub([mockEngine updateViewportMetrics:flutter::ViewportMetrics()]) | ||
| .ignoringNonObjectArgs() | ||
| .andDo(^(NSInvocation* invocation) { | ||
| [expectation fulfill]; | ||
| }); | ||
| id viewControllerMock = OCMPartialMock(viewController); | ||
| [viewControllerMock keyboardWillChangeFrame:notification]; | ||
| OCMVerify([viewControllerMock startKeyBoardAnimation:0.25]); | ||
| [self waitForExpectationsWithTimeout:5.0 handler:nil]; | ||
| } | ||
|
|
||
| - (void)testEnsureViewportMetricsWillInvokeAndDisplayLinkWillInvalidateInViewDidDisappear { | ||
|
|
||
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.
finishedmay be false here because thekeyboardAnimationViewwith the animation was removed from the superView before the animation was completed? Not sure though.