mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f312e5ba84
Summary: Original PR contents: This pull request updates the Podspecs and associated build scripts, and some source files so they build on OSS. RNTester now compiles with `fabric_enabled` again. The following changes have been made: * Various spots that were pointing to the old `ReactCommon/fabric` location have now been updated to `ReactCommon/react/renderer` * Files that were attempting to use internal FB header `FBRCTFabricComponentsPlugins.h` were changed to use `RCTFabricComponentsPlugins.h` * `RCTFabricComponentsPlugins` in OSS was updated to include the `Image` fabric component (thanks tsapeta) * Replaced old `generate-rncore.sh` build script with new `generate-rncore.js` script which does not require `flow-node` and uses the `react-native-codegen` API directly, so there is no longer any need for an interim `schema-rncore.json` file. * Updated Yoga podspec which wasn't fully synced with changes from the main Yoga repo * Updated Fabric podspec with additional needed subspecs Additions to PR by hramos: * Replaced use of generate-rncore scripts with the original generate-native-modules-specs.sh script, which is now generate-specs.sh and supports both codegen for Native Modules and Components now (TurboModules/Fabric). * Codegen now runs at build time as part of the Xcode build pipeline instead of as part of `pod install`. The build script is injected by the FBReactNativeSpec pod, as the pod is part of both Fabric and non-Fabric builds. ## Changelog [General] [Fixed] - RNTester compiles with `fabric_enabled` again Pull Request resolved: https://github.com/facebook/react-native/pull/29810 Test Plan: RNTester now compiles and runs in the simulator again when `fabric_enabled` is set to `true`. ``` cd xplat/js/react-native-github/packages/rn-tester USE_FABRIC=1 pod install open RNTesterPods.xcworkspace # Build and run ``` Reviewed By: fkgozali Differential Revision: D24058507 Pulled By: hramos fbshipit-source-id: 8b2ea3694e6cb9aa23f83f087e2995fd4320e2bb
100 lines
3.2 KiB
Plaintext
100 lines
3.2 KiB
Plaintext
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTActivityIndicatorViewComponentView.h"
|
|
|
|
#import <React/RCTConversions.h>
|
|
|
|
#import <react/renderer/components/rncore/ComponentDescriptors.h>
|
|
#import <react/renderer/components/rncore/EventEmitters.h>
|
|
#import <react/renderer/components/rncore/Props.h>
|
|
|
|
#import "RCTFabricComponentsPlugins.h"
|
|
|
|
using namespace facebook::react;
|
|
|
|
static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const ActivityIndicatorViewSize &size)
|
|
{
|
|
switch (size) {
|
|
case ActivityIndicatorViewSize::Small:
|
|
return UIActivityIndicatorViewStyleWhite;
|
|
case ActivityIndicatorViewSize::Large:
|
|
return UIActivityIndicatorViewStyleWhiteLarge;
|
|
}
|
|
}
|
|
|
|
@implementation RCTActivityIndicatorViewComponentView {
|
|
UIActivityIndicatorView *_activityIndicatorView;
|
|
}
|
|
|
|
#pragma mark - RCTComponentViewProtocol
|
|
|
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
{
|
|
return concreteComponentDescriptorProvider<ActivityIndicatorViewComponentDescriptor>();
|
|
}
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
if (self = [super initWithFrame:frame]) {
|
|
static const auto defaultProps = std::make_shared<const ActivityIndicatorViewProps>();
|
|
_props = defaultProps;
|
|
|
|
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
|
|
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
|
if (defaultProps->animating) {
|
|
[_activityIndicatorView startAnimating];
|
|
} else {
|
|
[_activityIndicatorView stopAnimating];
|
|
}
|
|
_activityIndicatorView.color = RCTUIColorFromSharedColor(defaultProps->color);
|
|
_activityIndicatorView.hidesWhenStopped = defaultProps->hidesWhenStopped;
|
|
_activityIndicatorView.activityIndicatorViewStyle = convertActivityIndicatorViewStyle(defaultProps->size);
|
|
|
|
[self addSubview:_activityIndicatorView];
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
{
|
|
const auto &oldViewProps = *std::static_pointer_cast<const ActivityIndicatorViewProps>(_props);
|
|
const auto &newViewProps = *std::static_pointer_cast<const ActivityIndicatorViewProps>(props);
|
|
|
|
if (oldViewProps.animating != newViewProps.animating) {
|
|
if (newViewProps.animating) {
|
|
[_activityIndicatorView startAnimating];
|
|
} else {
|
|
[_activityIndicatorView stopAnimating];
|
|
}
|
|
}
|
|
|
|
if (oldViewProps.color != newViewProps.color) {
|
|
_activityIndicatorView.color = RCTUIColorFromSharedColor(newViewProps.color);
|
|
}
|
|
|
|
// TODO: This prop should be deprecated.
|
|
if (oldViewProps.hidesWhenStopped != newViewProps.hidesWhenStopped) {
|
|
_activityIndicatorView.hidesWhenStopped = newViewProps.hidesWhenStopped;
|
|
}
|
|
|
|
if (oldViewProps.size != newViewProps.size) {
|
|
_activityIndicatorView.activityIndicatorViewStyle = convertActivityIndicatorViewStyle(newViewProps.size);
|
|
}
|
|
|
|
[super updateProps:props oldProps:oldProps];
|
|
}
|
|
|
|
@end
|
|
|
|
Class<RCTComponentViewProtocol> RCTActivityIndicatorViewCls(void)
|
|
{
|
|
return RCTActivityIndicatorViewComponentView.class;
|
|
}
|