-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ios): add Fabric support (#657)
* Initial changes * test fabric in CI * Sending picker size to shadow node * Fix E2E config * Update Xcode in CI * Adding more comments * cleanup Co-authored-by: Alfonso Curbelo <[email protected]>
- Loading branch information
1 parent
9e35e45
commit 8df590b
Showing
23 changed files
with
573 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ DerivedData | |
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
IDEWorkspaceChecks.plist | ||
|
||
#Detox | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
cpp/react/renderer/components/RNDateTimePicker/ComponentDescriptors.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* and copied to the cpp directory to override the adopt function and set the size of the shadow node based | ||
* on the state. | ||
* @generated by codegen project: GenerateComponentDescriptorH.js | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "ShadowNodes.h" | ||
#include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class RNDateTimePickerComponentDescriptor final : public ConcreteComponentDescriptor<RNDateTimePickerShadowNode> { | ||
public: | ||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor; | ||
|
||
void adopt(ShadowNode::Unshared const &shadowNode) const override { | ||
react_native_assert(std::dynamic_pointer_cast<RNDateTimePickerShadowNode>(shadowNode)); | ||
auto pickerShadowNode = std::static_pointer_cast<RNDateTimePickerShadowNode>(shadowNode); | ||
|
||
react_native_assert( | ||
std::dynamic_pointer_cast<YogaLayoutableShadowNode>(pickerShadowNode)); | ||
auto layoutableShadowNode = | ||
std::static_pointer_cast<YogaLayoutableShadowNode>(pickerShadowNode); | ||
|
||
auto state = std::static_pointer_cast<const RNDateTimePickerShadowNode::ConcreteState>(shadowNode->getState()); | ||
auto stateData = state->getData(); | ||
|
||
if(stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { | ||
layoutableShadowNode->setSize(Size{stateData.frameSize.width, stateData.frameSize.height}); | ||
} | ||
|
||
ConcreteComponentDescriptor::adopt(shadowNode); | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
12 changes: 12 additions & 0 deletions
12
cpp/react/renderer/components/RNDateTimePicker/RNDateTimePickerState.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Custom state to store frameSize that the component descriptor will use to modify the | ||
* shadow node layout. | ||
*/ | ||
|
||
#include "RNDateTimePickerState.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
} // namespace react | ||
} // namespace facebook |
23 changes: 23 additions & 0 deletions
23
cpp/react/renderer/components/RNDateTimePicker/RNDateTimePickerState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Custom state to store frameSize that the component descriptor will use to modify the | ||
* shadow node layout. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/graphics/Geometry.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class RNDateTimePickerState final { | ||
public: | ||
using Shared = std::shared_ptr<const RNDateTimePickerState>; | ||
RNDateTimePickerState(){}; | ||
RNDateTimePickerState(Size frameSize_) : frameSize(frameSize_){}; | ||
|
||
Size frameSize{}; | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
17 changes: 17 additions & 0 deletions
17
cpp/react/renderer/components/RNDateTimePicker/ShadowNodes.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen) | ||
* and copied to the cpp directory to add custom state and set shadow node trait as a LeafYogaNode. | ||
* | ||
* @generated by codegen project: GenerateShadowNodeCpp.js | ||
*/ | ||
|
||
#include "ShadowNodes.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
extern const char RNDateTimePickerComponentName[] = "RNDateTimePicker"; | ||
|
||
} // namespace react | ||
} // namespace facebook |
39 changes: 39 additions & 0 deletions
39
cpp/react/renderer/components/RNDateTimePicker/ShadowNodes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen) | ||
* and copied to the cpp directory to add custom state and set shadow node trait as a LeafYogaNode. | ||
* | ||
* @generated by codegen project: GenerateShadowNodeH.js | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "RNDateTimePickerState.h" | ||
#include <react/renderer/components/RNDateTimePicker/EventEmitters.h> | ||
#include <react/renderer/components/RNDateTimePicker/Props.h> | ||
#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
#include <jsi/jsi.h> | ||
#include <react/renderer/core/LayoutContext.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
JSI_EXPORT extern const char RNDateTimePickerComponentName[]; | ||
|
||
/* | ||
* `ShadowNode` for <RNDateTimePicker> component. | ||
*/ | ||
class JSI_EXPORT RNDateTimePickerShadowNode final : public ConcreteViewShadowNode<RNDateTimePickerComponentName, RNDateTimePickerProps, RNDateTimePickerEventEmitter, RNDateTimePickerState> { | ||
|
||
public: | ||
using ConcreteViewShadowNode::ConcreteViewShadowNode; | ||
|
||
static ShadowNodeTraits BaseTraits() { | ||
auto traits = ConcreteViewShadowNode::BaseTraits(); | ||
traits.set(ShadowNodeTraits::Trait::LeafYogaNode); | ||
return traits; | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SegmentedControl from '@react-native-segmented-control/segmented-control'; | ||
import JSSegmentedControl from '@react-native-segmented-control/segmented-control/js/SegmentedControl.js'; | ||
|
||
const isFabricEnabled = global.nativeFabricUIManager !== null; | ||
|
||
// Forcing the JS implementation for Fabric as the native module is not compatible with Fabric yet. | ||
export default isFabricEnabled ? JSSegmentedControl : SegmentedControl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
example/ios/date-time-picker-example.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* RNDateTimePickerComponentView is only be available when fabric is enabled. | ||
*/ | ||
|
||
#import <React/RCTViewComponentView.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RNDateTimePickerComponentView : RCTViewComponentView | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.