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
|
2020-05-08 16:37:49 +00:00
|
|
|
index 1333a10..4a698c5 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
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -50,6 +50,7 @@ @interface KeyboardTrackingView : UIView
|
2019-12-04 16:39:53 +00:00
|
|
|
@property (nonatomic) CGFloat originalHeight;
|
|
|
|
@property (nonatomic) KeyboardTrackingScrollBehavior scrollBehavior;
|
|
|
|
@property (nonatomic) BOOL addBottomView;
|
|
|
|
+@property (nonatomic) NSString* bottomViewColor;
|
|
|
|
@property (nonatomic) BOOL scrollToFocusedInput;
|
|
|
|
@property (nonatomic) BOOL allowHitsOutsideBounds;
|
|
|
|
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -80,6 +81,7 @@ -(instancetype)init
|
2019-12-04 16:39:53 +00:00
|
|
|
_bottomViewHeight = kBottomViewHeight;
|
|
|
|
|
|
|
|
self.addBottomView = NO;
|
|
|
|
+ self.bottomViewColor = nil;
|
|
|
|
self.scrollToFocusedInput = NO;
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rctContentDidAppearNotification:) name:RCTContentDidAppearNotification object:nil];
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -171,6 +173,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
|
2020-02-13 20:44:57 +00:00
|
|
|
|
|
|
|
for (UIView* subview in allSubviews)
|
|
|
|
{
|
|
|
|
+ NSString* className = NSStringFromClass([subview class]);
|
|
|
|
if(_manageScrollView)
|
|
|
|
{
|
|
|
|
if(_scrollViewToManage == nil)
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -196,7 +199,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
|
2020-02-13 20:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if ([subview isKindOfClass:NSClassFromString(@"RCTTextField")])
|
|
|
|
+ if ([className isEqualToString:@"RCTTextField"])
|
|
|
|
{
|
|
|
|
UITextField *textField = nil;
|
|
|
|
Ivar backedTextInputIvar = class_getInstanceVariable([subview class], "_backedTextInput");
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -210,15 +213,15 @@ - (void)initializeAccessoryViewsAndHandleInsets
|
2020-02-13 20:44:57 +00:00
|
|
|
}
|
|
|
|
[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");
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -232,7 +235,7 @@ - (void)initializeAccessoryViewsAndHandleInsets
|
2020-02-13 20:44:57 +00:00
|
|
|
}
|
|
|
|
[self setupTextView:textView];
|
|
|
|
}
|
|
|
|
- else if ([subview isKindOfClass:NSClassFromString(@"RCTUITextView")] && [subview isKindOfClass:[UITextView class]])
|
|
|
|
+ else if ([className isEqualToString:@"RCTUITextView"])
|
|
|
|
{
|
|
|
|
[self setupTextView:(UITextView*)subview];
|
|
|
|
}
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -267,6 +270,22 @@ - (void)initializeAccessoryViewsAndHandleInsets
|
2020-02-28 17:52:50 +00:00
|
|
|
[self addBottomViewIfNecessary];
|
|
|
|
}
|
|
|
|
|
|
|
|
+- (void)resetTracking
|
|
|
|
+{
|
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
+ [self deferedInitializeAccessoryViewsAndHandleInsets];
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
2019-12-04 16:39:53 +00:00
|
|
|
+-(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];
|
|
|
|
+}
|
|
|
|
+
|
2020-05-08 16:37:49 +00:00
|
|
|
- (void)setupTextView:(UITextView*)textView
|
2019-12-04 16:39:53 +00:00
|
|
|
{
|
2020-05-08 16:37:49 +00:00
|
|
|
if (textView != nil)
|
|
|
|
@@ -448,7 +467,14 @@ -(void)addBottomViewIfNecessary
|
2019-12-04 16:39:53 +00:00
|
|
|
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];
|
|
|
|
}
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -632,6 +658,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)
|
|
|
|
|
2020-05-08 16:37:49 +00:00
|
|
|
@@ -688,6 +715,21 @@ - (UIView *)view
|
2020-02-28 17:52:50 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
+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/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));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|