diff --git a/node_modules/react-native-ui-lib/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js b/node_modules/react-native-ui-lib/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js index cfe1d35..7ce5105 100644 --- a/node_modules/react-native-ui-lib/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js +++ b/node_modules/react-native-ui-lib/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js @@ -123,7 +123,13 @@ class KeyboardAccessoryView extends Component { * Whether or not to handle SafeArea * default: true */ - useSafeArea: PropTypes.bool + useSafeArea: PropTypes.bool, + + /** + * iOS only. + * Scroll view to track + */ + scrollViewNativeID: PropTypes.string }; static iosScrollBehaviors = IOS_SCROLL_BEHAVIORS; @@ -256,7 +262,8 @@ class KeyboardAccessoryView extends Component { kbComponent, onItemSelected, onRequestShowKeyboard, - useSafeArea + useSafeArea, + scrollViewNativeID } = this.props; return ( @@ -271,6 +278,7 @@ class KeyboardAccessoryView extends Component { addBottomView={addBottomView} bottomViewColor={this.props.bottomViewColor} allowHitsOutsideBounds={allowHitsOutsideBounds} + scrollViewNativeID={scrollViewNativeID} > {renderContent && renderContent()} ) #import #else -#import "RCTEventEmitter.h" +#import #endif @interface RCTCustomInputControllerTemp : RCTEventEmitter diff --git a/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h b/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h index 4344724..2786051 100644 --- a/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +++ b/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h @@ -10,7 +10,7 @@ #if __has_include() #import #else -#import "RCTRootView.h" +#import #endif @interface RCTCustomKeyboardViewControllerTemp : UIInputViewController diff --git a/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m b/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m index 8f8446e..728bedd 100644 --- a/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +++ b/node_modules/react-native-ui-lib/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m @@ -43,7 +43,6 @@ @interface KeyboardTrackingViewTemp : UIView @property (nonatomic, strong) UIScrollView *scrollViewToManage; @property (nonatomic) BOOL scrollIsInverted; @property (nonatomic) BOOL revealKeyboardInteractive; -@property (nonatomic) BOOL isDraggingScrollView; @property (nonatomic) BOOL manageScrollView; @property (nonatomic) BOOL requiresSameParentToManageScrollView; @property (nonatomic) NSUInteger deferedInitializeAccessoryViewsCount; @@ -54,6 +53,7 @@ @interface KeyboardTrackingViewTemp : UIView @property (nonatomic) BOOL useSafeArea; @property (nonatomic) BOOL scrollToFocusedInput; @property (nonatomic) BOOL allowHitsOutsideBounds; +@property (nonatomic) NSString* scrollViewNativeID; @end @@ -84,6 +84,7 @@ -(instancetype)init self.addBottomView = NO; self.bottomViewColor = nil; self.scrollToFocusedInput = NO; + self.scrollIsInverted = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rctContentDidAppearNotification:) name:RCTContentDidAppearNotification object:nil]; } @@ -170,7 +171,6 @@ -(void)layoutSubviews - (void)initializeAccessoryViewsAndHandleInsets { NSArray* allSubviews = [self getBreadthFirstSubviewsForView:[self getRootView]]; - NSMutableArray* rctScrollViewsArray = [NSMutableArray array]; for (UIView* subview in allSubviews) { @@ -179,24 +179,13 @@ - (void)initializeAccessoryViewsAndHandleInsets { if(_scrollViewToManage == nil) { - if(_requiresSameParentToManageScrollView && [subview isKindOfClass:[RCTScrollView class]] && subview.superview == self.superview) + if([subview isKindOfClass:[RCTScrollView class]]) { - _scrollViewToManage = ((RCTScrollView*)subview).scrollView; + RCTScrollView *scrollView = (RCTScrollView*)subview; + if (subview.nativeID && [subview.nativeID isEqualToString:self.scrollViewNativeID]) { + _scrollViewToManage = scrollView.scrollView; + } } - else if(!_requiresSameParentToManageScrollView && [subview isKindOfClass:[UIScrollView class]]) - { - _scrollViewToManage = (UIScrollView*)subview; - } - - if(_scrollViewToManage != nil) - { - _scrollIsInverted = CGAffineTransformEqualToTransform(_scrollViewToManage.superview.transform, CGAffineTransformMakeScale(1, -1)); - } - } - - if([subview isKindOfClass:[RCTScrollView class]]) - { - [rctScrollViewsArray addObject:(RCTScrollView*)subview]; } } @@ -246,15 +235,15 @@ - (void)initializeAccessoryViewsAndHandleInsets } } - for (RCTScrollView *scrollView in rctScrollViewsArray) - { - if(scrollView.scrollView == _scrollViewToManage) - { - [scrollView removeScrollListener:self]; - [scrollView addScrollListener:self]; - break; - } - } +// for (RCTScrollView *scrollView in [_rctScrollViewsArray allValues]) +// { +// if(scrollView.scrollView == _scrollViewToManage) +// { +// [scrollView removeScrollListener:self]; +// [scrollView addScrollListener:self]; +// break; +// } +// } #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3 if (@available(iOS 11.0, *)) { @@ -412,9 +401,6 @@ - (void)_updateScrollViewInsets CGFloat bottomSafeArea = [self getBottomSafeArea]; CGFloat bottomInset = MAX(self.bounds.size.height, _ObservingInputAccessoryViewTemp.keyboardHeight + _ObservingInputAccessoryViewTemp.height); - CGFloat originalBottomInset = self.scrollIsInverted ? insets.top : insets.bottom; - CGPoint originalOffset = self.scrollViewToManage.contentOffset; - bottomInset += (_ObservingInputAccessoryViewTemp.keyboardHeight == 0 ? bottomSafeArea : 0); if(self.scrollIsInverted) { @@ -426,20 +412,11 @@ - (void)_updateScrollViewInsets } self.scrollViewToManage.contentInset = insets; - if(self.scrollBehavior == KeyboardTrackingScrollBehaviorScrollToBottomInvertedOnly && _scrollIsInverted) + BOOL firstTime = _ObservingInputAccessoryViewTemp.keyboardHeight == 0 && _ObservingInputAccessoryViewTemp.keyboardState == KeyboardStateHidden; + BOOL willOpen = _ObservingInputAccessoryViewTemp.keyboardHeight != 0 && _ObservingInputAccessoryViewTemp.keyboardState == KeyboardStateHidden; + if(firstTime || willOpen) { - BOOL fisrtTime = _ObservingInputAccessoryViewTemp.keyboardHeight == 0 && _ObservingInputAccessoryViewTemp.keyboardState == KeyboardStateHidden; - BOOL willOpen = _ObservingInputAccessoryViewTemp.keyboardHeight != 0 && _ObservingInputAccessoryViewTemp.keyboardState == KeyboardStateHidden; - BOOL isOpen = _ObservingInputAccessoryViewTemp.keyboardHeight != 0 && _ObservingInputAccessoryViewTemp.keyboardState == KeyboardStateShown; - if(fisrtTime || willOpen || (isOpen && !self.isDraggingScrollView)) - { - [self.scrollViewToManage setContentOffset:CGPointMake(self.scrollViewToManage.contentOffset.x, -self.scrollViewToManage.contentInset.top) animated:!fisrtTime]; - } - } - else if(self.scrollBehavior == KeyboardTrackingScrollBehaviorFixedOffset && !self.isDraggingScrollView) - { - CGFloat insetsDiff = (bottomInset - originalBottomInset) * (self.scrollIsInverted ? -1 : 1); - self.scrollViewToManage.contentOffset = CGPointMake(originalOffset.x, originalOffset.y + insetsDiff); + [self.scrollViewToManage setContentOffset:CGPointMake(self.scrollViewToManage.contentOffset.x, -self.scrollViewToManage.contentInset.top) animated:!firstTime]; } insets = self.scrollViewToManage.contentInset; @@ -468,7 +445,6 @@ -(void)addBottomViewIfNecessary if (self.addBottomView && _bottomView == nil) { _bottomView = [UIView new]; - // _bottomView.backgroundColor = [UIColor whiteColor]; if (self.bottomViewColor) { _bottomView.backgroundColor = [self colorFromHexString:self.bottomViewColor]; @@ -607,21 +583,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView } } -- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView -{ - self.isDraggingScrollView = YES; -} - -- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset -{ - self.isDraggingScrollView = NO; -} - -- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate -{ - self.isDraggingScrollView = NO; -} - - (CGFloat)getKeyboardHeight { return _ObservingInputAccessoryViewTemp ? _ObservingInputAccessoryViewTemp.keyboardHeight : 0; @@ -664,6 +625,7 @@ @implementation KeyboardTrackingViewTempManager RCT_REMAP_VIEW_PROPERTY(useSafeArea, useSafeArea, BOOL) RCT_REMAP_VIEW_PROPERTY(scrollToFocusedInput, scrollToFocusedInput, BOOL) RCT_REMAP_VIEW_PROPERTY(allowHitsOutsideBounds, allowHitsOutsideBounds, BOOL) +RCT_EXPORT_VIEW_PROPERTY(scrollViewNativeID, NSString) + (BOOL)requiresMainQueueSetup {