From 10c60814d1dbc9c7515927f3e9b7941d5ab26d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 30 Mar 2021 11:31:17 +0800 Subject: [PATCH] iOS: add oldBottomMargin, oldHeight & bottomMargin --- doric-iOS/Pod/Classes/Plugin/DoricKeyboardPlugin.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doric-iOS/Pod/Classes/Plugin/DoricKeyboardPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricKeyboardPlugin.m index 03153949..dc032097 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricKeyboardPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricKeyboardPlugin.m @@ -45,12 +45,15 @@ - (void)subscribe:(NSString *)callbackId withPromise:(DoricPromise *)promise { CGRect beginFrame = [[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; CGRect endFrame = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; - - BOOL isOpen = endFrame.origin.y < beginFrame.origin.y; - int heightDiff = isOpen ? beginFrame.origin.y - endFrame.origin.y : 0; + + CGFloat oldBottomMargin = [[UIScreen mainScreen] bounds].size.height - beginFrame.origin.y - beginFrame.size.height; + CGFloat bottomMargin = [[UIScreen mainScreen] bounds].size.height - endFrame.origin.y - endFrame.size.height; NSDictionary *dict = @{ - @"height": @(heightDiff), + @"oldBottomMargin": @(oldBottomMargin), + @"oldHeight": @(beginFrame.size.height), + @"bottomMargin": @(bottomMargin), + @"height": @(endFrame.size.height), }; DoricPromise *currentPromise = [[DoricPromise alloc] initWithContext:self.doricContext callbackId:callbackId];