mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebd04dff7d |
@@ -433,6 +433,7 @@ let reactFabricComponents = RNTarget(
|
||||
"components/view/platform/android",
|
||||
"components/view/platform/windows",
|
||||
"components/view/platform/macos",
|
||||
"components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm",
|
||||
"components/textinput/platform/android",
|
||||
"components/text/platform/android",
|
||||
"components/textinput/platform/macos",
|
||||
@@ -445,7 +446,7 @@ let reactFabricComponents = RNTarget(
|
||||
"conponents/rncore", // this was the old folder where RN Core Components were generated. If you ran codegen in the past, you might have some files in it that might make the build fail.
|
||||
],
|
||||
dependencies: [.reactNativeDependencies, .reactCore, .reactJsiExecutor, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .yoga, .reactRendererDebug, .reactGraphics, .reactFabric, .reactTurboModuleBridging],
|
||||
sources: ["components/inputaccessory", "components/modal", "components/safeareaview", "components/text", "components/text/platform/cxx", "components/textinput", "components/textinput/platform/ios/", "components/unimplementedview", "components/virtualview", "components/virtualviewexperimental", "textlayoutmanager", "textlayoutmanager/platform/ios"]
|
||||
sources: ["components/inputaccessory", "components/modal", "components/safeareaview", "components/text", "components/text/platform/cxx", "components/textinput", "components/textinput/platform/ios/", "components/unimplementedview", "components/virtualview", "components/virtualviewexperimental", "textlayoutmanager", "textlayoutmanager/platform/ios", "components/switch/iosswitch"]
|
||||
)
|
||||
|
||||
/// React-FabricImage.podspec
|
||||
|
||||
@@ -53,6 +53,7 @@ RCT_EXTERN CGFloat RCTScreenScale(void);
|
||||
RCT_EXTERN CGFloat RCTFontSizeMultiplier(void);
|
||||
RCT_EXTERN CGSize RCTScreenSize(void);
|
||||
RCT_EXTERN CGSize RCTViewportSize(void);
|
||||
RCT_EXTERN CGSize RCTSwitchSize(void);
|
||||
|
||||
// Round float coordinates to nearest whole screen pixel (not point)
|
||||
RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value);
|
||||
|
||||
@@ -410,6 +410,16 @@ CGSize RCTViewportSize(void)
|
||||
return window ? window.bounds.size : RCTScreenSize();
|
||||
}
|
||||
|
||||
CGSize RCTSwitchSize(void)
|
||||
{
|
||||
static CGSize rctSwitchSize;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
rctSwitchSize = [UISwitch new].intrinsicContentSize;
|
||||
});
|
||||
return rctSwitchSize;
|
||||
}
|
||||
|
||||
CGFloat RCTRoundPixelValue(CGFloat value)
|
||||
{
|
||||
CGFloat scale = RCTScreenScale();
|
||||
|
||||
+1
-1
@@ -9,10 +9,10 @@
|
||||
|
||||
#import <React/RCTConversions.h>
|
||||
|
||||
#import <react/renderer/components/FBReactNativeSpec/ComponentDescriptors.h>
|
||||
#import <react/renderer/components/FBReactNativeSpec/EventEmitters.h>
|
||||
#import <react/renderer/components/FBReactNativeSpec/Props.h>
|
||||
#import <react/renderer/components/FBReactNativeSpec/RCTComponentViewHelpers.h>
|
||||
#import <react/renderer/components/switch/AppleSwitchComponentDescriptor.h>
|
||||
|
||||
#import "RCTFabricComponentsPlugins.h"
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ Pod::Spec.new do |s|
|
||||
"react/renderer/components/scrollview/platform/cxx",
|
||||
"react/renderer/components/text/platform/cxx",
|
||||
"react/renderer/components/textinput/platform/ios",
|
||||
"react/renderer/components/switch/iosswitch",
|
||||
]);
|
||||
|
||||
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
|
||||
|
||||
@@ -127,6 +127,14 @@ Pod::Spec.new do |s|
|
||||
sss.header_dir = "react/renderer/components/iostextinput"
|
||||
end
|
||||
|
||||
ss.subspec "switch" do |sss|
|
||||
sss.source_files = podspec_sources(
|
||||
["react/renderer/components/switch/iosswitch/**/*.{m,mm,cpp,h}"],
|
||||
["react/renderer/components/switch/iosswitch/**/*.h"])
|
||||
sss.exclude_files = "react/renderer/components/switch/iosswitch/**/MacOS*.{m,mm,cpp,h}"
|
||||
sss.header_dir = "react/renderer/components/switch/"
|
||||
end
|
||||
|
||||
ss.subspec "textinput" do |sss|
|
||||
sss.source_files = podspec_sources("react/renderer/components/textinput/*.{m,mm,cpp,h}", "react/renderer/components/textinput/**/*.h")
|
||||
sss.header_dir = "react/renderer/components/textinput"
|
||||
|
||||
+30
@@ -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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AppleSwitchShadowNode.h"
|
||||
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/*
|
||||
* Descriptor for <Switch> component.
|
||||
*/
|
||||
class SwitchComponentDescriptor final
|
||||
: public ConcreteComponentDescriptor<SwitchShadowNode> {
|
||||
public:
|
||||
SwitchComponentDescriptor(const ComponentDescriptorParameters& parameters)
|
||||
: ConcreteComponentDescriptor(parameters) {}
|
||||
|
||||
void adopt(ShadowNode& shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/components/FBReactNativeSpec/EventEmitters.h>
|
||||
#include <react/renderer/components/FBReactNativeSpec/Props.h>
|
||||
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
extern const char AppleSwitchComponentName[];
|
||||
|
||||
/*
|
||||
* `ShadowNode` for <IOSSwitch> component.
|
||||
*/
|
||||
class SwitchShadowNode final : public ConcreteViewShadowNode<
|
||||
AppleSwitchComponentName,
|
||||
SwitchProps,
|
||||
SwitchEventEmitter> {
|
||||
public:
|
||||
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
||||
|
||||
static ShadowNodeTraits BaseTraits() {
|
||||
auto traits = ConcreteViewShadowNode::BaseTraits();
|
||||
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
|
||||
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
|
||||
return traits;
|
||||
}
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size measureContent(
|
||||
const LayoutContext& layoutContext,
|
||||
const LayoutConstraints& layoutConstraints) const override;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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/RCTUtils.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "AppleSwitchShadowNode.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
extern const char AppleSwitchComponentName[] = "Switch";
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size SwitchShadowNode::measureContent(
|
||||
const LayoutContext & /*layoutContext*/,
|
||||
const LayoutConstraints & /*layoutConstraints*/) const
|
||||
{
|
||||
CGSize uiSwitchSize = RCTSwitchSize();
|
||||
return {.width = uiSwitchSize.width, .height = uiSwitchSize.height};
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 <AppKit/AppKit.h>
|
||||
#include "AppleSwitchShadowNode.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
extern const char AppleSwitchComponentName[] = "Switch";
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size SwitchShadowNode::measureContent(
|
||||
const LayoutContext & /*layoutContext*/,
|
||||
const LayoutConstraints & /*layoutConstraints*/) const
|
||||
{
|
||||
static CGSize nsSwitchSize = CGSizeZero;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
nsSwitchSize = [NSSwitch new].intrinsicContentSize;
|
||||
});
|
||||
});
|
||||
|
||||
return {.width = nsSwitchSize.width, .height = nsSwitchSize.height};
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
+1
@@ -366,6 +366,7 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
|
||||
RCTScreenSize();
|
||||
RCTScreenScale();
|
||||
RCTSwitchSize();
|
||||
|
||||
std::lock_guard<std::mutex> lock(*mutex);
|
||||
*isReady = true;
|
||||
|
||||
Reference in New Issue
Block a user