Skip to content

Commit 87d89c9

Browse files
committed
Auto detect if there is a bottomLayoutGuide in the controller hierarchy
k
1 parent 34c5544 commit 87d89c9

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

lib/ObservingInputAccessoryView.m

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

99
#import "ObservingInputAccessoryView.h"
10+
#import <React/RCTView.h>
1011

1112
@implementation ObservingInputAccessoryViewManager
1213

@@ -89,7 +90,13 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
8990

9091
_previousKeyboardHeight = _keyboardHeight;
9192
_keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height);
92-
93+
94+
CGFloat bottomLayout = [self getBottomLayoutGuide];
95+
96+
if (bottomLayout) {
97+
_keyboardHeight -= bottomLayout;
98+
}
99+
93100
[_delegate observingInputAccessoryViewDidChangeFrame:self];
94101
}
95102
}
@@ -166,4 +173,28 @@ - (void)_keyboardWillChangeFrameNotification:(NSNotification*)notification
166173
[self invalidateIntrinsicContentSize];
167174
}
168175

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+
169200
@end

0 commit comments

Comments
 (0)