From cfc2cf4c3a80c4e27b0d3d529df179f06458c3a0 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 6 Dec 2017 15:06:12 -0800 Subject: [PATCH] Set window.viewInsets.bottom to keyboard height on iOS (flutter/engine#4420) This allows for us to start migrating framework classes (notably Scaffold) to use window.viewInsets.bottom to get the keyboard height. Once framework updates have landed, we will land an engine patch to expose the iOS bottom safe area inset as padding. This change is already landed for Android. Related issue: flutter/flutter#12098 --- .../ios/framework/Source/FlutterViewController.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 1f19abaf8e..ea84cb43f2 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 @@ -656,17 +656,19 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to NSDictionary* info = [notification userInfo]; CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]); CGFloat scale = [UIScreen mainScreen].scale; - // TODO(cbracken): Once framework has been updated to use view insets, keyboard should change - // insets rather than padding. - // _viewportMetrics.physical_view_inset_bottom = bottom * scale; + _viewportMetrics.physical_view_inset_bottom = bottom * scale; + + // TODO(cbracken): Once framework has been updated to use view insets for keyboard padding, + // eliminate this line. _viewportMetrics.physical_padding_bottom = bottom * scale; [self updateViewportMetrics]; } - (void)keyboardWillBeHidden:(NSNotification*)notification { - // TODO(cbracken): Once framework has been updated to use view insets, keyboard should change - // insets rather than padding. - // _viewportMetrics.physical_view_inset_bottom = 0; + _viewportMetrics.physical_view_inset_bottom = 0; + + // TODO(cbracken): Once framework has been updated to use view insets for keyboard padding, + // eliminate this line. _viewportMetrics.physical_padding_bottom = 0; [self updateViewportMetrics]; }