Update view padding on iOS keyboard frame change (flutter/engine#3681)

This commit is contained in:
Chris Bracken
2017-05-10 16:35:58 -07:00
committed by GitHub
parent 27fcb31df5
commit 4103fe7a40

View File

@@ -190,7 +190,7 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
object:nil];
[center addObserver:self
selector:@selector(keyboardWasShown:)
selector:@selector(keyboardFrameDidChange:)
name:UIKeyboardDidShowNotification
object:nil];
@@ -199,6 +199,11 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
name:UIKeyboardWillHideNotification
object:nil];
[center addObserver:self
selector:@selector(keyboardFrameDidChange:)
name:UIKeyboardDidChangeFrameNotification
object:nil];
[center addObserver:self
selector:@selector(onLocaleUpdated:)
name:NSCurrentLocaleDidChangeNotification
@@ -394,10 +399,10 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(UITouc
#pragma mark - Keyboard events
- (void)keyboardWasShown:(NSNotification*)notification {
- (void)keyboardFrameDidChange:(NSNotification*)notification {
NSDictionary* info = [notification userInfo];
CGFloat bottom =
CGRectGetHeight([[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]);
CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]);
CGFloat scale = [UIScreen mainScreen].scale;
_viewportMetrics.physical_padding_bottom = bottom * scale;
[self updateViewportMetrics];