Skip to content

Commit

Permalink
Use safe area padding on hide keyboard on iOS (flutter#4304)
Browse files Browse the repository at this point in the history
On hide keyboard, reset the bottom padding to the safe area inset on
devices running iOS 11 or higher.
  • Loading branch information
cbracken authored Nov 1, 2017
1 parent 19e690e commit ddd5159
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit ddd5159

Please sign in to comment.