Skip to content

Commit b510acf

Browse files
UI-LIB scrollview fix for new arch #3775 (#3776)
* UI-LIB scrollview fix for new arch #3775 * Update snapshot --------- Co-authored-by: M-i-k-e-l <[email protected]>
1 parent 662c14f commit b510acf

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m

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

1313
#import <WebKit/WebKit.h>
14-
#import <React/RCTScrollView.h>
14+
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>
1920

2021
#import <objc/runtime.h>
2122

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

7172
if (self)
7273
{
73-
[self addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:NULL];
74+
[self addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:NULL];
7475
_inputViewsMap = [NSMapTable weakToWeakObjectsMapTable];
7576
_deferedInitializeAccessoryViewsCount = 0;
7677

@@ -93,20 +94,21 @@ -(instancetype)init
9394
return self;
9495
}
9596

96-
-(RCTRootView*)getRootView
97+
-(UIView*)getRootView
9798
{
9899
UIView *view = self;
99100
while (view.superview != nil)
100101
{
101102
view = view.superview;
102-
if ([view isKindOfClass:[RCTRootView class]])
103+
if ([view isKindOfClass:[RCTSurfaceHostingView class]]) {
103104
break;
105+
}
104106
}
105107

106-
if ([view isKindOfClass:[RCTRootView class]])
107-
{
108-
return (RCTRootView*)view;
108+
if ([view isKindOfClass:[RCTSurfaceHostingView class]]) {
109+
return view;
109110
}
111+
110112
return nil;
111113
}
112114

@@ -169,37 +171,50 @@ -(void)layoutSubviews
169171
[self updateBottomViewFrame];
170172
}
171173

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+
172185
- (void)initializeAccessoryViewsAndHandleInsets
173186
{
174187
NSArray<UIView*>* allSubviews = [self getBreadthFirstSubviewsForView:[self getRootView]];
175-
NSMutableArray<RCTScrollView*>* rctScrollViewsArray = [NSMutableArray array];
176188

177189
for (UIView* subview in allSubviews)
178190
{
179191
if(_manageScrollView)
180192
{
181193
if(_scrollViewToManage == nil)
182194
{
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;
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(subview.superview.transform, CGAffineTransformMakeScale(1, -1));
212+
}
213+
}
190214
}
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];
201215
}
202216
}
217+
203218

204219
if ([subview isKindOfClass:NSClassFromString(@"RCTTextField")])
205220
{
@@ -247,13 +262,11 @@ - (void)initializeAccessoryViewsAndHandleInsets
247262
}
248263
}
249264

250-
for (RCTScrollView *scrollView in rctScrollViewsArray)
265+
if(_scrollViewToManage != nil)
251266
{
252-
if(scrollView.scrollView == _scrollViewToManage)
267+
if(_scrollViewToManage.delegate == nil)
253268
{
254-
[scrollView removeScrollListener:self];
255-
[scrollView addScrollListener:self];
256-
break;
269+
_scrollViewToManage.delegate = self;
257270
}
258271
}
259272

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

339352
-(void)dealloc
340353
{
341-
[self removeObserver:self forKeyPath:@"bounds"];
354+
[self removeObserver:self forKeyPath:@"frame"];
342355
}
343356

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

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"react-native-redash": "^12.0.3",
5757
"semver": "^5.5.0",
5858
"tinycolor2": "^1.4.2",
59-
"uilib-native": "5.0.0-snapshot.7216",
59+
"uilib-native": "5.0.0-snapshot.7240",
6060
"url-parse": "^1.2.0",
6161
"wix-react-native-text-size": "1.0.9"
6262
},

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10938,7 +10938,7 @@ __metadata:
1093810938
shell-utils: ^1.0.10
1093910939
tinycolor2: ^1.4.2
1094010940
typescript: 5.0.4
10941-
uilib-native: 5.0.0-snapshot.7216
10941+
uilib-native: 5.0.0-snapshot.7240
1094210942
url-parse: ^1.2.0
1094310943
wix-react-native-text-size: 1.0.9
1094410944
peerDependencies:
@@ -12570,16 +12570,16 @@ __metadata:
1257012570
languageName: node
1257112571
linkType: hard
1257212572

12573-
"uilib-native@npm:5.0.0-snapshot.7216":
12574-
version: 5.0.0-snapshot.7216
12575-
resolution: "uilib-native@npm:5.0.0-snapshot.7216"
12573+
"uilib-native@npm:5.0.0-snapshot.7240":
12574+
version: 5.0.0-snapshot.7240
12575+
resolution: "uilib-native@npm:5.0.0-snapshot.7240"
1257612576
dependencies:
1257712577
lodash: ^4.17.21
1257812578
prop-types: ^15.5.10
1257912579
peerDependencies:
1258012580
react: ">=17.0.1"
1258112581
react-native: ">=0.64.1"
12582-
checksum: 3ca207bae3865fc4275393135f5cd4a46c52678100d4308fe1008d0167d8d5ae8bd1cab558b364d7ad60e5c96cb38497cd10b0109e15376c623ef9849cfb3a32
12582+
checksum: e18a273800b231479aea3fac4a43c7f2c4a6f74c995f44e7b9ab5642b666d94060ff09a2c0f76cf6e871cbd8fc57baaee92a4879c28e20be3358fbb4fd02dc0f
1258312583
languageName: node
1258412584
linkType: hard
1258512585

0 commit comments

Comments
 (0)