iOS: add oldBottomMargin, oldHeight & bottomMargin

This commit is contained in:
王劲鹏 2021-03-30 11:31:17 +08:00 committed by osborn
parent f16b8b8125
commit 10c60814d1

View File

@ -46,11 +46,14 @@ - (void)subscribe:(NSString *)callbackId withPromise:(DoricPromise *)promise {
CGRect beginFrame = [[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; CGRect beginFrame = [[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGRect endFrame = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
BOOL isOpen = endFrame.origin.y < beginFrame.origin.y; CGFloat oldBottomMargin = [[UIScreen mainScreen] bounds].size.height - beginFrame.origin.y - beginFrame.size.height;
int heightDiff = isOpen ? beginFrame.origin.y - endFrame.origin.y : 0; CGFloat bottomMargin = [[UIScreen mainScreen] bounds].size.height - endFrame.origin.y - endFrame.size.height;
NSDictionary *dict = @{ 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]; DoricPromise *currentPromise = [[DoricPromise alloc] initWithContext:self.doricContext callbackId:callbackId];