From 6f3d28f29195d47a5fc53e0ce6305cb01eb833f0 Mon Sep 17 00:00:00 2001 From: Gareth Taft Date: Wed, 30 Jan 2019 11:55:00 +0000 Subject: [PATCH 1/4] Auto detect if there is a bottomLayoutGuide in the controller hierarchy k --- lib/ObservingInputAccessoryView.m | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/ObservingInputAccessoryView.m b/lib/ObservingInputAccessoryView.m index e472679..c13bbaa 100644 --- a/lib/ObservingInputAccessoryView.m +++ b/lib/ObservingInputAccessoryView.m @@ -7,6 +7,7 @@ // #import "ObservingInputAccessoryView.h" +#import @implementation ObservingInputAccessoryViewManager @@ -89,7 +90,13 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N _previousKeyboardHeight = _keyboardHeight; _keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height); - + + CGFloat bottomLayout = [self getBottomLayoutGuide]; + + if (bottomLayout) { + _keyboardHeight -= bottomLayout; + } + [_delegate observingInputAccessoryViewDidChangeFrame:self]; } } @@ -166,4 +173,28 @@ - (void)_keyboardWillChangeFrameNotification:(NSNotification*)notification [self invalidateIntrinsicContentSize]; } +- (UIViewController *)reactViewController:(UIView *)view +{ + id responder = [view nextResponder]; + while (responder) { + if ([responder isKindOfClass:[UIViewController class]]) { + if (((UIViewController*)responder).bottomLayoutGuide.length > 0) { + return responder; + } + } + responder = [responder nextResponder]; + } + return nil; +} + +- (CGFloat)getBottomLayoutGuide +{ + UIViewController *controller = [self reactViewController:self]; + if (controller) { + return controller.bottomLayoutGuide.length; + } + + return 0; +} + @end From faf42947f2a70a0faaef1de11e6a72d0d8abe23e Mon Sep 17 00:00:00 2001 From: Aiden Montgomery Date: Tue, 5 Mar 2019 13:19:43 +0000 Subject: [PATCH 2/4] Adjusting height for inside UITabBar --- lib/KeyboardTrackingViewManager.m | 14 ++++++++++++- lib/ObservingInputAccessoryView.m | 33 +------------------------------ 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/lib/KeyboardTrackingViewManager.m b/lib/KeyboardTrackingViewManager.m index 800bd35..f2747cf 100644 --- a/lib/KeyboardTrackingViewManager.m +++ b/lib/KeyboardTrackingViewManager.m @@ -501,12 +501,24 @@ - (void) rctContentDidAppearNotification:(NSNotification*)notification }); } +-(CGFloat)getTabBarHeight { + UITabBarController *tabBarController = (UITabBarController *)[[[UIApplication sharedApplication] delegate] window].rootViewController; + CGFloat tabbarHeight = 0.0f; + + if (!tabBarController.tabBar.isHidden) { + tabbarHeight = tabBarController.tabBar.bounds.size.height; + } + + return tabbarHeight; +} + #pragma mark - ObservingInputAccessoryViewDelegate methods -(void)updateTransformAndInsets { CGFloat bottomSafeArea = [self getBottomSafeArea]; - CGFloat accessoryTranslation = MIN(-bottomSafeArea, -_observingInputAccessoryView.keyboardHeight); + CGFloat tabBarHeight = [self getTabBarHeight]; + CGFloat accessoryTranslation = MIN(-bottomSafeArea, -(_observingInputAccessoryView.keyboardHeight - tabBarHeight)); if (_observingInputAccessoryView.keyboardHeight <= bottomSafeArea) { _bottomViewHeight = kBottomViewHeight; diff --git a/lib/ObservingInputAccessoryView.m b/lib/ObservingInputAccessoryView.m index c13bbaa..0025a45 100644 --- a/lib/ObservingInputAccessoryView.m +++ b/lib/ObservingInputAccessoryView.m @@ -7,7 +7,6 @@ // #import "ObservingInputAccessoryView.h" -#import @implementation ObservingInputAccessoryViewManager @@ -89,13 +88,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N CGFloat boundsH = self.superview.bounds.size.height; _previousKeyboardHeight = _keyboardHeight; - _keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height); - - CGFloat bottomLayout = [self getBottomLayoutGuide]; - - if (bottomLayout) { - _keyboardHeight -= bottomLayout; - } + _keyboardHeight = MAX(0, self.window.bounds.size.height - (centerY - boundsH / 2) - self.intrinsicContentSize.height); [_delegate observingInputAccessoryViewDidChangeFrame:self]; } @@ -173,28 +166,4 @@ - (void)_keyboardWillChangeFrameNotification:(NSNotification*)notification [self invalidateIntrinsicContentSize]; } -- (UIViewController *)reactViewController:(UIView *)view -{ - id responder = [view nextResponder]; - while (responder) { - if ([responder isKindOfClass:[UIViewController class]]) { - if (((UIViewController*)responder).bottomLayoutGuide.length > 0) { - return responder; - } - } - responder = [responder nextResponder]; - } - return nil; -} - -- (CGFloat)getBottomLayoutGuide -{ - UIViewController *controller = [self reactViewController:self]; - if (controller) { - return controller.bottomLayoutGuide.length; - } - - return 0; -} - @end From 50f8a2952963e25b0f2bb3af488c45eaeaf99e02 Mon Sep 17 00:00:00 2001 From: Aiden Montgomery Date: Fri, 30 Aug 2019 09:49:24 +0100 Subject: [PATCH 3/4] Added a test podspec --- KeyboardTrackingView.podspec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 KeyboardTrackingView.podspec diff --git a/KeyboardTrackingView.podspec b/KeyboardTrackingView.podspec new file mode 100644 index 0000000..f876c13 --- /dev/null +++ b/KeyboardTrackingView.podspec @@ -0,0 +1,19 @@ +require 'json' +package = JSON.parse(File.read('./package.json')) + +Pod::Spec.new do |s| + s.name = 'KeyboardTrackingView' + s.dependency "React" + + s.version = package["version"] + s.license = package["license"] + s.summary = package["description"] + s.authors = package["author"] + s.homepage = package["homepage"] + + s.platform = :ios, "9.0" + s.requires_arc = true + + s.source = { :git => s.homepage, :tag => s.version } + s.source_files = "ios/**/*.{h,m}" +end From 9496edb9be88216d916c3f8ce64b1295a09f9b86 Mon Sep 17 00:00:00 2001 From: Aiden Montgomery Date: Fri, 30 Aug 2019 15:08:09 +0100 Subject: [PATCH 4/4] Updated podspec --- KeyboardTrackingView.podspec | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/KeyboardTrackingView.podspec b/KeyboardTrackingView.podspec index f876c13..5df290f 100644 --- a/KeyboardTrackingView.podspec +++ b/KeyboardTrackingView.podspec @@ -15,5 +15,5 @@ Pod::Spec.new do |s| s.requires_arc = true s.source = { :git => s.homepage, :tag => s.version } - s.source_files = "ios/**/*.{h,m}" + s.source_files = "lib/**/*.{h,m}" end diff --git a/package.json b/package.json index 13d2c3b..2179f55 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/wix/react-native-keyboard-tracking-view.git" }, - "version": "5.5.0", + "version": "5.5.1", "description": "React Native UI component which tracks the keyboard", "nativePackage": true, "bugs": {