Skip to content

Commit 662c14f

Browse files
committed
Revert "UI-LIB scrollview fix for new arch"
This reverts commit 083661c.
1 parent 2b54010 commit 662c14f

File tree

1 file changed

+32
-45
lines changed

1 file changed

+32
-45
lines changed

lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
#import "UIResponder+FirstResponderTemp.h"
1212

1313
#import <WebKit/WebKit.h>
14-
14+
#import <React/RCTScrollView.h>
1515
#import <React/RCTBridge.h>
1616
#import <React/RCTUIManager.h>
1717
#import <React/UIView+React.h>
1818
#import <React/RCTUIManagerUtils.h>
19-
#import <React/RCTSurfaceHostingView.h>
2019

2120
#import <objc/runtime.h>
2221

@@ -71,7 +70,7 @@ -(instancetype)init
7170

7271
if (self)
7372
{
74-
[self addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:NULL];
73+
[self addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:NULL];
7574
_inputViewsMap = [NSMapTable weakToWeakObjectsMapTable];
7675
_deferedInitializeAccessoryViewsCount = 0;
7776

@@ -94,21 +93,20 @@ -(instancetype)init
9493
return self;
9594
}
9695

97-
-(UIView*)getRootView
96+
-(RCTRootView*)getRootView
9897
{
9998
UIView *view = self;
10099
while (view.superview != nil)
101100
{
102101
view = view.superview;
103-
if ([view isKindOfClass:[RCTSurfaceHostingView class]]) {
102+
if ([view isKindOfClass:[RCTRootView class]])
104103
break;
105-
}
106104
}
107105

108-
if ([view isKindOfClass:[RCTSurfaceHostingView class]]) {
109-
return view;
106+
if ([view isKindOfClass:[RCTRootView class]])
107+
{
108+
return (RCTRootView*)view;
110109
}
111-
112110
return nil;
113111
}
114112

@@ -171,50 +169,37 @@ -(void)layoutSubviews
171169
[self updateBottomViewFrame];
172170
}
173171

174-
- (UIScrollView*)extractUIScrollView:(UIView*)view
175-
{
176-
for (UIView* subview in view.subviews) {
177-
if ([subview isKindOfClass:[UIScrollView class]]) {
178-
return (UIScrollView*)subview;
179-
}
180-
}
181-
182-
return nil;
183-
}
184-
185172
- (void)initializeAccessoryViewsAndHandleInsets
186173
{
187174
NSArray<UIView*>* allSubviews = [self getBreadthFirstSubviewsForView:[self getRootView]];
175+
NSMutableArray<RCTScrollView*>* rctScrollViewsArray = [NSMutableArray array];
188176

189177
for (UIView* subview in allSubviews)
190178
{
191179
if(_manageScrollView)
192180
{
193181
if(_scrollViewToManage == nil)
194182
{
195-
if ([NSStringFromClass([subview class]) isEqualToString:@"RCTScrollViewComponentView"]) {
196-
UIScrollView *scrollView = [self extractUIScrollView:subview];
197-
198-
if ([scrollView isKindOfClass:[UIScrollView class]])
199-
{
200-
if(_requiresSameParentToManageScrollView && subview.superview == self.superview)
201-
{
202-
_scrollViewToManage = scrollView;
203-
}
204-
else if(!_requiresSameParentToManageScrollView)
205-
{
206-
_scrollViewToManage = scrollView;
207-
}
208-
209-
if(_scrollViewToManage != nil)
210-
{
211-
_scrollIsInverted = CGAffineTransformEqualToTransform(_scrollViewToManage.superview.transform, CGAffineTransformMakeScale(1, -1));
212-
}
213-
}
183+
if(_requiresSameParentToManageScrollView && [subview isKindOfClass:[RCTScrollView class]] && subview.superview == self.superview)
184+
{
185+
_scrollViewToManage = ((RCTScrollView*)subview).scrollView;
186+
}
187+
else if(!_requiresSameParentToManageScrollView && [subview isKindOfClass:[UIScrollView class]])
188+
{
189+
_scrollViewToManage = (UIScrollView*)subview;
214190
}
191+
192+
if(_scrollViewToManage != nil)
193+
{
194+
_scrollIsInverted = CGAffineTransformEqualToTransform(_scrollViewToManage.superview.transform, CGAffineTransformMakeScale(1, -1));
195+
}
196+
}
197+
198+
if([subview isKindOfClass:[RCTScrollView class]])
199+
{
200+
[rctScrollViewsArray addObject:(RCTScrollView*)subview];
215201
}
216202
}
217-
218203

219204
if ([subview isKindOfClass:NSClassFromString(@"RCTTextField")])
220205
{
@@ -262,11 +247,13 @@ - (void)initializeAccessoryViewsAndHandleInsets
262247
}
263248
}
264249

265-
if(_scrollViewToManage != nil)
250+
for (RCTScrollView *scrollView in rctScrollViewsArray)
266251
{
267-
if(_scrollViewToManage.delegate == nil)
252+
if(scrollView.scrollView == _scrollViewToManage)
268253
{
269-
_scrollViewToManage.delegate = self;
254+
[scrollView removeScrollListener:self];
255+
[scrollView addScrollListener:self];
256+
break;
270257
}
271258
}
272259

@@ -351,12 +338,12 @@ -(void)didMoveToWindow
351338

352339
-(void)dealloc
353340
{
354-
[self removeObserver:self forKeyPath:@"frame"];
341+
[self removeObserver:self forKeyPath:@"bounds"];
355342
}
356343

357344
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
358345
{
359-
_ObservingInputAccessoryViewTemp.height = self.frame.size.height;
346+
_ObservingInputAccessoryViewTemp.height = self.bounds.size.height;
360347
}
361348

362349
- (void)ObservingInputAccessoryViewTempKeyboardWillDisappear:(ObservingInputAccessoryViewTemp *)ObservingInputAccessoryViewTemp

0 commit comments

Comments
 (0)