@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515- (void )flashScrollIndicators ;
1616- (void )scrollTo : (double )x y : (double )y animated : (BOOL )animated ;
1717- (void )scrollToEnd : (BOOL )animated ;
18+ - (void )zoomToRect : (CGRect)rect animated : (BOOL )animated ;
1819@end
1920
2021RCT_EXTERN inline void
@@ -90,6 +91,43 @@ RCTScrollViewHandleCommand(id<RCTScrollViewProtocol> componentView, NSString con
9091 [componentView scrollToEnd: animated];
9192 return ;
9293 }
94+
95+ if ([commandName isEqualToString: @" zoomToRect" ]) {
96+ #if RCT_DEBUG
97+ if ([args count ] != 2 ) {
98+ RCTLogError (
99+ @" %@ command %@ received %d arguments, expected %d ." , @" ScrollView" , commandName, (int )[args count ], 2 );
100+ return ;
101+ }
102+ #endif
103+
104+ NSObject *arg0 = args[0 ];
105+
106+ #if RCT_DEBUG
107+ if (!RCTValidateTypeOfViewCommandArgument (
108+ arg0, [NSDictionary class ], @" dictionary" , @" ScrollView" , commandName, @" 1st" )) {
109+ return ;
110+ }
111+ #endif
112+
113+ NSDictionary *rectDict = (NSDictionary *)arg0;
114+ NSNumber *x = rectDict[@" x" ];
115+ NSNumber *y = rectDict[@" y" ];
116+ NSNumber *width = rectDict[@" width" ];
117+ NSNumber *height = rectDict[@" height" ];
118+ CGRect rect = CGRectMake (x.doubleValue , y.doubleValue , width.doubleValue , height.doubleValue );
119+
120+ NSObject *arg1 = args[1 ];
121+ #if RCT_DEBUG
122+ if (!RCTValidateTypeOfViewCommandArgument (arg1, [NSNumber class ], @" boolean" , @" ScrollView" , commandName, @" 2nd" )) {
123+ return ;
124+ }
125+ #endif
126+
127+ BOOL animated = [(NSNumber *)arg1 boolValue ];
128+ [componentView zoomToRect: rect animated: animated];
129+ return ;
130+ }
93131}
94132
95133NS_ASSUME_NONNULL_END
0 commit comments