verdnatura-chat/patches/react-native-keyboard-track...

191 lines
8.1 KiB
Diff
Raw Normal View History

2019-12-04 16:39:53 +00:00
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..8fcd559 100644
2019-12-04 16:39:53 +00:00
--- 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];
}
@@ -266,6 +269,13 @@ - (void)initializeAccessoryViewsAndHandleInsets
[self addBottomViewIfNecessary];
}
+- (void)resetTracking
+{
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ [self deferedInitializeAccessoryViewsAndHandleInsets];
+ });
+}
+
- (void)setupTextView:(UITextView*)textView
{
if (textView != nil)
@@ -442,12 +452,28 @@ -(void)setAddBottomView:(BOOL)addBottomView
2019-12-04 16:39:53 +00:00
[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 +657,7 @@ @implementation KeyboardTrackingViewManager
2019-12-04 16:39:53 +00:00
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)
@@ -687,6 +714,21 @@ - (UIView *)view
}];
}
+RCT_EXPORT_METHOD(resetTracking:(nonnull NSNumber *)reactTag)
+{
+ [self.bridge.uiManager addUIBlock:
+ ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, KeyboardTrackingView *> *viewRegistry) {
+
+ KeyboardTrackingView *view = viewRegistry[reactTag];
+ if (!view || ![view isKindOfClass:[KeyboardTrackingView class]]) {
+ RCTLogError(@"Error: cannot find KeyboardTrackingView with tag #%@", reactTag);
+ return;
+ }
+
+ [view resetTracking];
+ }];
+}
+
#pragma mark - helper methods
-(void)rejectPromise:(RCTPromiseRejectBlock)reject withErrorMessage:(NSString*)errorMessage errorCode:(NSInteger)errorCode
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
diff --git a/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.android.js b/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.android.js
index af15edf..1e1bd35 100644
--- a/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.android.js
+++ b/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.android.js
@@ -14,4 +14,5 @@ export default class KeyboardTrackingView extends PureComponent {
return {trackingViewHeight: 0, keyboardHeight: 0, contentTopInset: 0};
}
scrollToStart() {}
+ resetTracking() {}
}
diff --git a/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.ios.js b/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.ios.js
index 5e2c207..43bc252 100644
--- a/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.ios.js
+++ b/node_modules/react-native-keyboard-tracking-view/src/KeyboardTrackingView.ios.js
@@ -30,4 +30,10 @@ export default class KeyboardTrackingView extends PureComponent {
KeyboardTrackingViewManager.scrollToStart(ReactNative.findNodeHandle(this.ref));
}
}
+
+ resetTracking() {
+ if (this.ref && KeyboardTrackingViewManager && KeyboardTrackingViewManager.resetTracking) {
+ KeyboardTrackingViewManager.resetTracking(ReactNative.findNodeHandle(this.ref));
+ }
+ }
}