From ddd51597d09b35af63b29ecab33519ac78bf23c3 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 (#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/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 0f088470a45fe..c1b2dfcc4b422 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -636,7 +636,17 @@ - (void)keyboardWillChangeFrame:(NSNotification*)notification { } - (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]; }