Rocket.Chat.ReactNative/patches/react-native-keyboard-track...

130 lines
5.6 KiB
Diff

diff --git a/node_modules/react-native-keyboard-tracking-view/lib/KeyboardTrackingViewManager.m b/node_modules/react-native-keyboard-tracking-view/lib/KeyboardTrackingViewManager.m
index 800bd35..edb3030 100644
--- a/node_modules/react-native-keyboard-tracking-view/lib/KeyboardTrackingViewManager.m
+++ b/node_modules/react-native-keyboard-tracking-view/lib/KeyboardTrackingViewManager.m
@@ -49,6 +49,7 @@ @interface KeyboardTrackingView : UIView
@property (nonatomic) CGFloat originalHeight;
@property (nonatomic) KeyboardTrackingScrollBehavior scrollBehavior;
@property (nonatomic) BOOL addBottomView;
+@property (nonatomic) NSString* bottomViewColor;
@property (nonatomic) BOOL scrollToFocusedInput;
@property (nonatomic) BOOL allowHitsOutsideBounds;
@@ -79,6 +80,7 @@ -(instancetype)init
_bottomViewHeight = kBottomViewHeight;
self.addBottomView = NO;
+ self.bottomViewColor = nil;
self.scrollToFocusedInput = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rctContentDidAppearNotification:) name:RCTContentDidAppearNotification object:nil];
@@ -170,6 +172,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
for (UIView* subview in allSubviews)
{
+ NSString* className = NSStringFromClass([subview class]);
if(_manageScrollView)
{
if(_scrollViewToManage == nil)
@@ -195,7 +198,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
}
}
- if ([subview isKindOfClass:NSClassFromString(@"RCTTextField")])
+ if ([className isEqualToString:@"RCTTextField"])
{
UITextField *textField = nil;
Ivar backedTextInputIvar = class_getInstanceVariable([subview class], "_backedTextInput");
@@ -209,15 +212,15 @@ - (void)initializeAccessoryViewsAndHandleInsets
}
[self setupTextField:textField];
}
- else if ([subview isKindOfClass:NSClassFromString(@"RCTUITextField")] && [subview isKindOfClass:[UITextField class]])
+ else if ([className isEqualToString:@"RCTUITextField"])
{
[self setupTextField:(UITextField*)subview];
}
- else if ([subview isKindOfClass:NSClassFromString(@"RCTMultilineTextInputView")])
+ else if ([className isEqualToString:@"RCTMultilineTextInputView"])
{
[self setupTextView:[subview valueForKey:@"_backedTextInputView"]];
}
- else if ([subview isKindOfClass:NSClassFromString(@"RCTTextView")])
+ else if ([className isEqualToString:@"RCTTextView"])
{
UITextView *textView = nil;
Ivar backedTextInputIvar = class_getInstanceVariable([subview class], "_backedTextInput");
@@ -231,7 +234,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
}
[self setupTextView:textView];
}
- else if ([subview isKindOfClass:NSClassFromString(@"RCTUITextView")] && [subview isKindOfClass:[UITextView class]])
+ else if ([className isEqualToString:@"RCTUITextView"])
{
[self setupTextView:(UITextView*)subview];
}
@@ -442,12 +445,28 @@ -(void)setAddBottomView:(BOOL)addBottomView
[self addBottomViewIfNecessary];
}
+-(UIColor *)colorFromHexString:(NSString *)hexString
+{
+ unsigned rgbValue = 0;
+ NSScanner *scanner = [NSScanner scannerWithString:hexString];
+ [scanner setScanLocation:1]; // bypass '#' character
+ [scanner scanHexInt:&rgbValue];
+ return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
+}
+
-(void)addBottomViewIfNecessary
{
if (self.addBottomView && _bottomView == nil)
{
_bottomView = [UIView new];
- _bottomView.backgroundColor = [UIColor whiteColor];
+ if (self.bottomViewColor)
+ {
+ _bottomView.backgroundColor = [self colorFromHexString:self.bottomViewColor];
+ }
+ else
+ {
+ _bottomView.backgroundColor = [UIColor whiteColor];
+ }
[self addSubview:_bottomView];
[self updateBottomViewFrame];
}
@@ -631,6 +650,7 @@ @implementation KeyboardTrackingViewManager
RCT_REMAP_VIEW_PROPERTY(manageScrollView, manageScrollView, BOOL)
RCT_REMAP_VIEW_PROPERTY(requiresSameParentToManageScrollView, requiresSameParentToManageScrollView, BOOL)
RCT_REMAP_VIEW_PROPERTY(addBottomView, addBottomView, BOOL)
+RCT_REMAP_VIEW_PROPERTY(bottomViewColor, bottomViewColor, NSString)
RCT_REMAP_VIEW_PROPERTY(scrollToFocusedInput, scrollToFocusedInput, BOOL)
RCT_REMAP_VIEW_PROPERTY(allowHitsOutsideBounds, allowHitsOutsideBounds, BOOL)
diff --git a/node_modules/react-native-keyboard-tracking-view/react-native-keyboard-tracking-view.podspec b/node_modules/react-native-keyboard-tracking-view/react-native-keyboard-tracking-view.podspec
new file mode 100644
index 0000000..a6dbe01
--- /dev/null
+++ b/node_modules/react-native-keyboard-tracking-view/react-native-keyboard-tracking-view.podspec
@@ -0,0 +1,19 @@
+require 'json'
+
+package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
+
+Pod::Spec.new do |s|
+ s.name = package['name']
+ s.version = package['version']
+ s.summary = package['description']
+ s.license = package['license']
+
+ s.authors = package['author']
+ s.homepage = package['homepage']
+ s.platform = :ios, "9.0"
+
+ s.source = { :git => "https://github.com/wix/react-native-keyboard-tracking-view.git", :tag => "v#{s.version}" }
+ s.source_files = "lib/**/*.{h,m}"
+
+ s.dependency 'React'
+end
\ No newline at end of file