Skip to content

Commit 6ba0d83

Browse files
Adjusting height for inside UITabBar
1 parent 87d89c9 commit 6ba0d83

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

lib/KeyboardTrackingViewManager.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,24 @@ - (void) rctContentDidAppearNotification:(NSNotification*)notification
501501
});
502502
}
503503

504+
-(CGFloat)getTabBarHeight {
505+
UITabBarController *tabBarController = (UITabBarController *)[[[UIApplication sharedApplication] delegate] window].rootViewController;
506+
CGFloat tabbarHeight = 0.0f;
507+
508+
if (!tabBarController.tabBar.isHidden) {
509+
tabbarHeight = tabBarController.tabBar.bounds.size.height;
510+
}
511+
512+
return tabbarHeight;
513+
}
514+
504515
#pragma mark - ObservingInputAccessoryViewDelegate methods
505516

506517
-(void)updateTransformAndInsets
507518
{
508519
CGFloat bottomSafeArea = [self getBottomSafeArea];
509-
CGFloat accessoryTranslation = MIN(-bottomSafeArea, -_observingInputAccessoryView.keyboardHeight);
520+
CGFloat tabBarHeight = [self getTabBarHeight];
521+
CGFloat accessoryTranslation = MIN(-bottomSafeArea, -(_observingInputAccessoryView.keyboardHeight - tabBarHeight));
510522

511523
if (_observingInputAccessoryView.keyboardHeight <= bottomSafeArea) {
512524
_bottomViewHeight = kBottomViewHeight;

lib/ObservingInputAccessoryView.m

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import "ObservingInputAccessoryView.h"
10-
#import <React/RCTView.h>
1110

1211
@implementation ObservingInputAccessoryViewManager
1312

@@ -89,13 +88,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
8988
CGFloat boundsH = self.superview.bounds.size.height;
9089

9190
_previousKeyboardHeight = _keyboardHeight;
92-
_keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height);
93-
94-
CGFloat bottomLayout = [self getBottomLayoutGuide];
95-
96-
if (bottomLayout) {
97-
_keyboardHeight -= bottomLayout;
98-
}
91+
_keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height);
9992

10093
[_delegate observingInputAccessoryViewDidChangeFrame:self];
10194
}
@@ -173,28 +166,4 @@ - (void)_keyboardWillChangeFrameNotification:(NSNotification*)notification
173166
[self invalidateIntrinsicContentSize];
174167
}
175168

176-
- (UIViewController *)reactViewController:(UIView *)view
177-
{
178-
id responder = [view nextResponder];
179-
while (responder) {
180-
if ([responder isKindOfClass:[UIViewController class]]) {
181-
if (((UIViewController*)responder).bottomLayoutGuide.length > 0) {
182-
return responder;
183-
}
184-
}
185-
responder = [responder nextResponder];
186-
}
187-
return nil;
188-
}
189-
190-
- (CGFloat)getBottomLayoutGuide
191-
{
192-
UIViewController *controller = [self reactViewController:self];
193-
if (controller) {
194-
return controller.bottomLayoutGuide.length;
195-
}
196-
197-
return 0;
198-
}
199-
200169
@end

0 commit comments

Comments
 (0)