iOS - expose C++ FabricUIManager to the bridge via a wrapper class
Reviewed By: shergin Differential Revision: D7093253 fbshipit-source-id: 7317144ad2cb5b8903227c779798e1576f8de2c2
This commit is contained in:
parent
52acbbdd62
commit
28c694f25a
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* 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/RCTBridge.h>
|
||||
#import <React/RCTInvalidating.h>
|
||||
#import <React/RCTShadowView.h>
|
||||
|
||||
@class RCTShadowView;
|
||||
|
||||
/**
|
||||
* The RCTFabricUIManager is the module responsible for updating the view hierarchy.
|
||||
*/
|
||||
@interface RCTFabricUIManager : NSObject <RCTInvalidating>
|
||||
|
||||
- (RCTShadowView *)createNode:(nonnull NSNumber *)reactTag
|
||||
viewName:(NSString *)viewName
|
||||
rootTag:(nonnull NSNumber *)rootTag
|
||||
props:(NSDictionary *)props
|
||||
instanceHandle:(void *)instanceHandle;
|
||||
|
||||
- (RCTShadowView *)cloneNode:(RCTShadowView *)node;
|
||||
- (RCTShadowView *)cloneNodeWithNewChildren:(RCTShadowView *)node;
|
||||
- (RCTShadowView *)cloneNodeWithNewProps:(RCTShadowView *)node
|
||||
newProps:(NSDictionary *)props;
|
||||
- (RCTShadowView *)cloneNodeWithNewChildrenAndProps:(RCTShadowView *)node
|
||||
newProps:(NSDictionary *)props;
|
||||
- (void)appendChild:(RCTShadowView *)parentNode
|
||||
childNode:(RCTShadowView *)childNode;
|
||||
|
||||
- (NSMutableArray<RCTShadowView *> *)createChildSet:(nonnull NSNumber *)rootTag;
|
||||
- (void)appendChildToSet:(NSMutableArray<RCTShadowView *> *)childSet
|
||||
childNode:(RCTShadowView *)childNode;
|
||||
- (void)completeRoot:(nonnull NSNumber *)rootTag
|
||||
childSet:(NSArray<RCTShadowView *> *)childSet;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTFabricUIManager)
|
||||
|
||||
@property (nonatomic, readonly) RCTFabricUIManager *fabricUIManager;
|
||||
|
||||
@end
|
|
@ -1,86 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTFabricUIManager.h"
|
||||
|
||||
// This file contains experimental placeholders, nothing is finalized.
|
||||
@implementation RCTFabricUIManager
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
}
|
||||
|
||||
- (RCTShadowView *)createNode:(nonnull NSNumber *)reactTag
|
||||
viewName:(NSString *)viewName
|
||||
rootTag:(nonnull NSNumber *)rootTag
|
||||
props:(NSDictionary *)props
|
||||
instanceHandle:(void *)instanceHandle
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (RCTShadowView *)cloneNode:(RCTShadowView *)node
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
- (RCTShadowView *)cloneNodeWithNewChildren:(RCTShadowView *)node
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (RCTShadowView *)cloneNodeWithNewProps:(RCTShadowView *)node
|
||||
newProps:(NSDictionary *)props
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
- (RCTShadowView *)cloneNodeWithNewChildrenAndProps:(RCTShadowView *)node
|
||||
newProps:(NSDictionary *)props
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
- (void)appendChild:(RCTShadowView *)parentNode
|
||||
childNode:(RCTShadowView *)childNode
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (NSMutableArray<RCTShadowView *> *)createChildSet:(nonnull NSNumber *)rootTag
|
||||
{
|
||||
return [NSMutableArray array];
|
||||
}
|
||||
|
||||
- (void)appendChildToSet:(NSMutableArray<RCTShadowView *> *)childSet
|
||||
childNode:(RCTShadowView *)childNode
|
||||
{
|
||||
if (!childNode) {
|
||||
// TODO: until this class is fully implemented, we may get nil from JS.
|
||||
return;
|
||||
}
|
||||
|
||||
[childSet addObject:childNode];
|
||||
}
|
||||
|
||||
- (void)completeRoot:(nonnull NSNumber *)rootTag
|
||||
childSet:(NSArray<RCTShadowView *> *)childSet
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTFabricUIManager)
|
||||
|
||||
- (RCTFabricUIManager *)fabricUIManager
|
||||
{
|
||||
return [self jsBoundExtraModuleForClass:[RCTFabricUIManager class]];
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* 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 <memory>
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTInvalidating.h>
|
||||
#import <React/RCTShadowView.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class FabricUIManager;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
/**
|
||||
* An ObjC++ wrapper around the C++ FabricUIManager instance, so that the RCTCxxBridge can access it as needed.
|
||||
*/
|
||||
@interface RCTFabricUIManagerWrapper : NSObject <RCTInvalidating>
|
||||
|
||||
- (instancetype)initWithManager:(std::shared_ptr<FabricUIManager>)manager;
|
||||
- (std::shared_ptr<FabricUIManager>)manager;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTFabricUIManagerWrapper)
|
||||
|
||||
/**
|
||||
* To access via the bridge:
|
||||
*
|
||||
* std::shared_ptr<FabricUIManager> fabricUIManager = [_bridge fabricUIManager];
|
||||
*/
|
||||
- (std::shared_ptr<FabricUIManager>)fabricUIManager;
|
||||
|
||||
@end
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTFabricUIManagerWrapper.h"
|
||||
|
||||
#include <fabric/FabricUIManager.h>
|
||||
|
||||
// This file contains experimental placeholders, nothing is finalized.
|
||||
@implementation RCTFabricUIManagerWrapper
|
||||
{
|
||||
std::shared_ptr<FabricUIManager> _manager;
|
||||
}
|
||||
|
||||
- (instancetype)initWithManager:(std::shared_ptr<FabricUIManager>)manager
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_manager = manager;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<FabricUIManager>)manager
|
||||
{
|
||||
return _manager;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTFabricUIManagerWrapper)
|
||||
|
||||
- (std::shared_ptr<FabricUIManager>)fabricUIManager
|
||||
{
|
||||
RCTFabricUIManagerWrapper *wrapper = [self jsBoundExtraModuleForClass:[RCTFabricUIManagerWrapper class]];
|
||||
if (wrapper) {
|
||||
return [wrapper manager];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue