From 1f58a9609880d949bcc84bd061a9d68c1d24a2df Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 31 Oct 2017 17:17:38 -0700 Subject: [PATCH] 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. --- .../ios/framework/Source/FlutterViewController.mm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 0f088470a4..c1b2dfcc4b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -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]; }