yeet
This commit is contained in:
25
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h
generated
vendored
Normal file
25
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTViewComponentView.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTLegacyViewManagerInteropComponentView : RCTViewComponentView
|
||||
|
||||
/**
|
||||
Returns true for components that are supported by LegacyViewManagerInterop layer, false otherwise.
|
||||
*/
|
||||
+ (BOOL)isSupported:(NSString *)componentName;
|
||||
|
||||
+ (void)supportLegacyViewManagerWithName:(NSString *)componentName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
148
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm
generated
vendored
Normal file
148
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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 "RCTLegacyViewManagerInteropComponentView.h"
|
||||
|
||||
#import <React/UIView+React.h>
|
||||
#import <react/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h>
|
||||
#import <react/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h>
|
||||
#import <react/utils/ManagedObjectWrapper.h>
|
||||
#import "RCTLegacyViewManagerInteropCoordinatorAdapter.h"
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
@implementation RCTLegacyViewManagerInteropComponentView {
|
||||
NSMutableDictionary<NSNumber *, UIView *> *_viewsToBeMounted;
|
||||
NSMutableArray<UIView *> *_viewsToBeUnmounted;
|
||||
RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter;
|
||||
LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
static const auto defaultProps = std::make_shared<const LegacyViewManagerInteropViewProps>();
|
||||
_props = defaultProps;
|
||||
_viewsToBeMounted = [NSMutableDictionary new];
|
||||
_viewsToBeUnmounted = [NSMutableArray new];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSMutableSet<NSString *> *)supportedViewManagers
|
||||
{
|
||||
static NSMutableSet<NSString *> *supported =
|
||||
[NSMutableSet setWithObjects:@"Picker", @"DatePicker", @"ProgressView", @"SegmentedControl", @"MaskedView", nil];
|
||||
return supported;
|
||||
}
|
||||
|
||||
+ (BOOL)isSupported:(NSString *)componentName
|
||||
{
|
||||
return [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
|
||||
}
|
||||
|
||||
+ (void)supportLegacyViewManagerWithName:(NSString *)componentName
|
||||
{
|
||||
[[RCTLegacyViewManagerInteropComponentView supportedViewManagers] addObject:componentName];
|
||||
}
|
||||
|
||||
- (RCTLegacyViewManagerInteropCoordinator *)coordinator
|
||||
{
|
||||
if (_state != nullptr) {
|
||||
const auto &state = _state->getData();
|
||||
return unwrapManagedObject(state.coordinator);
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
|
||||
{
|
||||
const auto &state = _state->getData();
|
||||
RCTLegacyViewManagerInteropCoordinator *coordinator = unwrapManagedObject(state.coordinator);
|
||||
return coordinator.componentViewName;
|
||||
}
|
||||
|
||||
#pragma mark - RCTComponentViewProtocol
|
||||
|
||||
- (void)prepareForRecycle
|
||||
{
|
||||
_adapter = nil;
|
||||
[_viewsToBeMounted removeAllObjects];
|
||||
[_viewsToBeUnmounted removeAllObjects];
|
||||
_state.reset();
|
||||
[super prepareForRecycle];
|
||||
}
|
||||
|
||||
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
||||
{
|
||||
[_viewsToBeMounted setObject:childComponentView forKey:[NSNumber numberWithInteger:index]];
|
||||
}
|
||||
|
||||
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
||||
{
|
||||
[_viewsToBeUnmounted addObject:childComponentView];
|
||||
}
|
||||
|
||||
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
||||
{
|
||||
return concreteComponentDescriptorProvider<LegacyViewManagerInteropComponentDescriptor>();
|
||||
}
|
||||
|
||||
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
|
||||
{
|
||||
_state = std::static_pointer_cast<LegacyViewManagerInteropShadowNode::ConcreteState const>(state);
|
||||
}
|
||||
|
||||
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
|
||||
{
|
||||
[super finalizeUpdates:updateMask];
|
||||
|
||||
if (!_adapter) {
|
||||
_adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:self.coordinator
|
||||
reactTag:self.tag];
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
_adapter.eventInterceptor = ^(std::string eventName, folly::dynamic event) {
|
||||
if (weakSelf) {
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
auto eventEmitter =
|
||||
std::static_pointer_cast<LegacyViewManagerInteropViewEventEmitter const>(strongSelf->_eventEmitter);
|
||||
eventEmitter->dispatchEvent(eventName, event);
|
||||
}
|
||||
};
|
||||
self.contentView = _adapter.paperView;
|
||||
}
|
||||
|
||||
for (NSNumber *key in _viewsToBeMounted) {
|
||||
[_adapter.paperView insertReactSubview:_viewsToBeMounted[key] atIndex:key.integerValue];
|
||||
}
|
||||
|
||||
[_viewsToBeMounted removeAllObjects];
|
||||
|
||||
for (UIView *view in _viewsToBeUnmounted) {
|
||||
[_adapter.paperView removeReactSubview:view];
|
||||
}
|
||||
|
||||
[_viewsToBeUnmounted removeAllObjects];
|
||||
|
||||
[_adapter.paperView didUpdateReactSubviews];
|
||||
|
||||
if (updateMask & RNComponentViewUpdateMaskProps) {
|
||||
const auto &newProps = *std::static_pointer_cast<const LegacyViewManagerInteropViewProps>(_props);
|
||||
[_adapter setProps:newProps.otherProps];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Native Commands
|
||||
|
||||
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
||||
{
|
||||
[_adapter handleCommand:(NSString *)commandName args:(NSArray *)args];
|
||||
}
|
||||
|
||||
@end
|
27
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h
generated
vendored
Normal file
27
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 <Foundation/Foundation.h>
|
||||
#import <react/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTLegacyViewManagerInteropCoordinatorAdapter : NSObject
|
||||
|
||||
- (instancetype)initWithCoordinator:(RCTLegacyViewManagerInteropCoordinator *)coordinator reactTag:(NSInteger)tag;
|
||||
|
||||
@property (strong, nonatomic) UIView *paperView;
|
||||
|
||||
@property (nonatomic, copy, nullable) void (^eventInterceptor)(std::string eventName, folly::dynamic event);
|
||||
|
||||
- (void)setProps:(folly::dynamic const &)props;
|
||||
|
||||
- (void)handleCommand:(NSString *)commandName args:(NSArray *)args;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
58
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm
generated
vendored
Normal file
58
node_modules/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 "RCTLegacyViewManagerInteropCoordinatorAdapter.h"
|
||||
#import <React/UIView+React.h>
|
||||
|
||||
@implementation RCTLegacyViewManagerInteropCoordinatorAdapter {
|
||||
RCTLegacyViewManagerInteropCoordinator *_coordinator;
|
||||
NSInteger _tag;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoordinator:(RCTLegacyViewManagerInteropCoordinator *)coordinator reactTag:(NSInteger)tag
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_coordinator = coordinator;
|
||||
_tag = tag;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_paperView removeFromSuperview];
|
||||
[_coordinator removeObserveForTag:_tag];
|
||||
}
|
||||
|
||||
- (UIView *)paperView
|
||||
{
|
||||
if (!_paperView) {
|
||||
_paperView = _coordinator.paperView;
|
||||
_paperView.reactTag = [NSNumber numberWithInteger:_tag];
|
||||
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
[_coordinator addObserveForTag:_tag
|
||||
usingBlock:^(std::string eventName, folly::dynamic event) {
|
||||
if (weakSelf.eventInterceptor) {
|
||||
weakSelf.eventInterceptor(eventName, event);
|
||||
}
|
||||
}];
|
||||
}
|
||||
return _paperView;
|
||||
}
|
||||
|
||||
- (void)setProps:(const folly::dynamic &)props
|
||||
{
|
||||
[_coordinator setProps:props forView:self.paperView];
|
||||
}
|
||||
|
||||
- (void)handleCommand:(NSString *)commandName args:(NSArray *)args
|
||||
{
|
||||
[_coordinator handleCommand:commandName args:args reactTag:_tag];
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user