Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Libraries/NativeAnimation/Nodes/RCTColorAnimatedNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTAnimatedNode.h>

@interface RCTColorAnimatedNode : RCTAnimatedNode

@property (nonatomic, assign) int32_t color;

@end
30 changes: 30 additions & 0 deletions Libraries/NativeAnimation/Nodes/RCTColorAnimatedNode.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTColorAnimatedNode.h>
#import <React/RCTValueAnimatedNode.h>

@implementation RCTColorAnimatedNode

- (void)performUpdate
{
[super performUpdate];

RCTValueAnimatedNode *rNode = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:self.config[@"r"]];
RCTValueAnimatedNode *gNode = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:self.config[@"g"]];
RCTValueAnimatedNode *bNode = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:self.config[@"b"]];
RCTValueAnimatedNode *aNode = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:self.config[@"a"]];

_color = ((int)round(aNode.value * 255) & 0xff) << 24 |
((int)round(rNode.value) & 0xff) << 16 |
((int)round(gNode.value) & 0xff) << 8 |
((int)round(bNode.value) & 0xff);

// TODO (T111179606): Support platform colors for color animations
}

@end
17 changes: 11 additions & 6 deletions Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTStyleAnimatedNode.h>
#import <React/RCTUIManager.h>
#import <React/RCTValueAnimatedNode.h>
#import <React/RCTColorAnimatedNode.h>

@implementation RCTPropsAnimatedNode
{
Expand Down Expand Up @@ -118,17 +119,21 @@ - (void)performUpdate
for (NSNumber *parentTag in self.parentNodes.keyEnumerator) {
RCTAnimatedNode *parentNode = [self.parentNodes objectForKey:parentTag];
if ([parentNode isKindOfClass:[RCTStyleAnimatedNode class]]) {
[self->_propsDictionary addEntriesFromDictionary:[(RCTStyleAnimatedNode *)parentNode propsDictionary]];

RCTStyleAnimatedNode *styleAnimatedNode = (RCTStyleAnimatedNode *)parentNode;
[_propsDictionary addEntriesFromDictionary:styleAnimatedNode.propsDictionary];
} else if ([parentNode isKindOfClass:[RCTValueAnimatedNode class]]) {
RCTValueAnimatedNode *valueAnimatedNode = (RCTValueAnimatedNode *)parentNode;
NSString *property = [self propertyNameForParentTag:parentTag];
id animatedObject = [(RCTValueAnimatedNode *)parentNode animatedObject];
id animatedObject = valueAnimatedNode.animatedObject;
if (animatedObject) {
self->_propsDictionary[property] = animatedObject;
_propsDictionary[property] = animatedObject;
} else {
CGFloat value = [(RCTValueAnimatedNode *)parentNode value];
self->_propsDictionary[property] = @(value);
_propsDictionary[property] = @(valueAnimatedNode.value);
}
} else if ([parentNode isKindOfClass:[RCTColorAnimatedNode class]]) {
RCTColorAnimatedNode *colorAnimatedNode = (RCTColorAnimatedNode *)parentNode;
NSString *property = [self propertyNameForParentTag:parentTag];
_propsDictionary[property] = @(colorAnimatedNode.color);
}
}

Expand Down
12 changes: 8 additions & 4 deletions Libraries/NativeAnimation/Nodes/RCTStyleAnimatedNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <React/RCTAnimationUtils.h>
#import <React/RCTValueAnimatedNode.h>
#import <React/RCTTransformAnimatedNode.h>
#import <React/RCTColorAnimatedNode.h>

@implementation RCTStyleAnimatedNode
{
Expand Down Expand Up @@ -38,11 +39,14 @@ - (void)performUpdate
RCTAnimatedNode *node = [self.parentNodes objectForKey:nodeTag];
if (node) {
if ([node isKindOfClass:[RCTValueAnimatedNode class]]) {
RCTValueAnimatedNode *parentNode = (RCTValueAnimatedNode *)node;
[self->_propsDictionary setObject:@(parentNode.value) forKey:property];
RCTValueAnimatedNode *valueAnimatedNode = (RCTValueAnimatedNode *)node;
_propsDictionary[property] = @(valueAnimatedNode.value);
} else if ([node isKindOfClass:[RCTTransformAnimatedNode class]]) {
RCTTransformAnimatedNode *parentNode = (RCTTransformAnimatedNode *)node;
[self->_propsDictionary addEntriesFromDictionary:parentNode.propsDictionary];
RCTTransformAnimatedNode *transformAnimatedNode = (RCTTransformAnimatedNode *)node;
[_propsDictionary addEntriesFromDictionary:transformAnimatedNode.propsDictionary];
} else if ([node isKindOfClass:[RCTColorAnimatedNode class]]) {
RCTColorAnimatedNode *colorAnimatedNode = (RCTColorAnimatedNode *)node;
_propsDictionary[property] = @(colorAnimatedNode.color);
}
}
}];
Expand Down
2 changes: 2 additions & 0 deletions Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTAdditionAnimatedNode.h>
#import <React/RCTAnimatedNode.h>
#import <React/RCTAnimationDriver.h>
#import <React/RCTColorAnimatedNode.h>
#import <React/RCTDiffClampAnimatedNode.h>
#import <React/RCTDivisionAnimatedNode.h>
#import <React/RCTEventAnimation.h>
Expand Down Expand Up @@ -86,6 +87,7 @@ - (void)createAnimatedNode:(NSNumber *)tag
dispatch_once(&mapToken, ^{
map = @{@"style" : [RCTStyleAnimatedNode class],
@"value" : [RCTValueAnimatedNode class],
@"color" : [RCTColorAnimatedNode class],
@"props" : [RCTPropsAnimatedNode class],
@"interpolation" : [RCTInterpolationAnimatedNode class],
@"addition" : [RCTAdditionAnimatedNode class],
Expand Down
2 changes: 1 addition & 1 deletion Libraries/NativeAnimation/React-RCTAnimation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#214)
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
s.source = source
s.source_files = "{Drivers/*,Nodes/*,*}.{m,mm}"
s.source_files = "**/*.{h,m,mm}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTAnimation"
s.pod_target_xcconfig = {
Expand Down
6 changes: 6 additions & 0 deletions React/Fabric/Mounting/RCTMountingManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import <React/RCTFollyConvert.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>
#import <react/config/ReactNativeConfig.h>
#import <react/renderer/components/root/RootShadowNode.h>
#import <react/renderer/core/LayoutableShadowNode.h>
#import <react/renderer/core/RawProps.h>
Expand Down Expand Up @@ -318,6 +319,11 @@ - (void)synchronouslyUpdateViewOnUIThread:(ReactTag)reactTag
if (props[@"opacity"] && componentView.layer.opacity != (float)newViewProps.opacity) {
componentView.layer.opacity = newViewProps.opacity;
}

auto reactNativeConfig = _contextContainer->at<std::shared_ptr<ReactNativeConfig const>>("ReactNativeConfig");
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:finalize_updates_on_synchronous_update_view_ios")) {
[componentView finalizeUpdates:RNComponentViewUpdateMaskProps];
}
}

- (void)synchronouslyDispatchCommandOnUIThread:(ReactTag)reactTag
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/react/renderer/graphics/platform/ios/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#pragma once

#include <butter/optional.h>
#include <cmath>
#include <optional>

Expand Down