[iOS] Fix:Keyboard inset is not correct when presenting and native ViewController on FlutterViewController (flutter/engine#29862)

This commit is contained in:
WenJingRui 2021-11-23 07:27:56 +08:00 committed by GitHub
parent 7ae65f835d
commit b4058bb068
2 changed files with 11 additions and 2 deletions

View File

@ -1200,9 +1200,10 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
}
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.
[self invalidateDisplayLink];
}
if (finished) {
[self removeKeyboardAnimationView];
[self ensureViewportMetricsIsCorrect];
}

View File

@ -173,9 +173,17 @@ typedef enum UIAccessibilityContrast : NSInteger {
@"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25],
@"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal]
}];
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];
}
- (void)testEnsureViewportMetricsWillInvokeAndDisplayLinkWillInvalidateInViewDidDisappear {