Use safe area padding on hide keyboard on iOS (flutter/engine#4304)

On hide keyboard, reset the bottom padding to the safe area inset on
devices running iOS 11 or higher.
This commit is contained in:
Chris Bracken
2017-10-31 17:17:38 -07:00
committed by GitHub
parent 0ac48e7bd8
commit 1f58a96098

View File

@@ -636,7 +636,17 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to
}
- (void)keyboardWillBeHidden:(NSNotification*)notification {
_viewportMetrics.physical_padding_bottom = 0;
// TODO(cbracken) once clang toolchain compiler-rt has been updated, replace with
// if (@available(iOS 11, *)) {
if (_platformSupportsSafeAreaInsets) {
CGFloat scale = [UIScreen mainScreen].scale;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
_viewportMetrics.physical_padding_bottom = self.view.safeAreaInsets.bottom * scale;
#pragma clang diagnostic pop
} else {
_viewportMetrics.physical_padding_bottom = 0;
}
[self updateViewportMetrics];
}