|
28 | 28 | #import <react/utils/FollyConvert.h> |
29 | 29 |
|
30 | 30 | #import <react/featureflags/ReactNativeFeatureFlags.h> |
| 31 | +#import <react/renderer/animationbackend/AnimatedProps.h> |
31 | 32 | #import <react/renderer/componentregistry/ComponentDescriptorFactory.h> |
32 | 33 | #import <react/renderer/components/text/BaseTextProps.h> |
| 34 | +#import <react/renderer/components/view/BaseViewProps.h> |
33 | 35 | #import <react/renderer/runtimescheduler/RuntimeScheduler.h> |
34 | 36 | #import <react/renderer/scheduler/SchedulerToolbox.h> |
35 | 37 | #import <react/utils/ContextContainer.h> |
@@ -416,6 +418,44 @@ - (void)schedulerDidSetIsJSResponder:(BOOL)isJSResponder |
416 | 418 | [_mountingManager setIsJSResponder:isJSResponder blockNativeResponder:blockNativeResponder forShadowView:shadowView]; |
417 | 419 | } |
418 | 420 |
|
| 421 | +- (void)schedulerDidSynchronouslyUpdateViewWithAnimatedPropsOnUIThread:(Tag)tag |
| 422 | + surfaceId:(SurfaceId)surfaceId |
| 423 | + animatedProps:(const AnimatedProps &)animatedProps |
| 424 | +{ |
| 425 | + RCTScheduler *scheduler = [self scheduler]; |
| 426 | + if (!scheduler) { |
| 427 | + return; |
| 428 | + } |
| 429 | + |
| 430 | + UIView<RCTComponentViewProtocol> *componentView = |
| 431 | + [_mountingManager.componentViewRegistry findComponentViewWithTag:tag]; |
| 432 | + if (componentView == nil) { |
| 433 | + return; |
| 434 | + } |
| 435 | + ComponentHandle handle = [[componentView class] componentDescriptorProvider].handle; |
| 436 | + auto *componentDescriptor = [scheduler findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN:handle]; |
| 437 | + if (!componentDescriptor) { |
| 438 | + return; |
| 439 | + } |
| 440 | + |
| 441 | + Props::Shared oldProps = [componentView props]; |
| 442 | + PropsParserContext propsParserContext{surfaceId, *[self contextContainer]}; |
| 443 | + |
| 444 | + Props::Shared newProps; |
| 445 | + if (animatedProps.rawProps) { |
| 446 | + newProps = componentDescriptor->cloneProps(propsParserContext, oldProps, RawProps(*animatedProps.rawProps)); |
| 447 | + } else { |
| 448 | + newProps = componentDescriptor->cloneProps(propsParserContext, oldProps, RawProps{}); |
| 449 | + } |
| 450 | + |
| 451 | + auto viewProps = std::const_pointer_cast<BaseViewProps>(std::static_pointer_cast<const BaseViewProps>(newProps)); |
| 452 | + for (auto &animatedProp : animatedProps.props) { |
| 453 | + cloneProp(*viewProps, *animatedProp); |
| 454 | + } |
| 455 | + |
| 456 | + [_mountingManager synchronouslyUpdateViewOnUIThread:tag withProps:newProps]; |
| 457 | +} |
| 458 | + |
419 | 459 | - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer |
420 | 460 | { |
421 | 461 | std::unique_lock lock(_observerListMutex); |
|
0 commit comments