iOS: create C++ <-> ObjC++ connector for FabricUIManager to do UI operations

Reviewed By: shergin

Differential Revision: D7162911

fbshipit-source-id: 3e303020dafdccc51f52c3359a7054dc8a787978
This commit is contained in:
Kevin Gozali
2018-03-07 16:54:16 -08:00
committed by Facebook Github Bot
parent 23e0f868c9
commit 7bf3b20837
9 changed files with 163 additions and 14 deletions
+13 -3
View File
@@ -1,14 +1,23 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* 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.
*/
#include "FabricUIManager.h"
#include "IFabricPlatformUIOperationManager.h"
#include "ShadowNode.h"
namespace facebook {
namespace react {
FabricUIManager::FabricUIManager() {}
FabricUIManager::FabricUIManager(const std::shared_ptr<IFabricPlatformUIOperationManager> &platformUIOperationManager) :
platformUIOperationManager_(platformUIOperationManager) {};
ShadowNodeRef FabricUIManager::createNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle) {
platformUIOperationManager_->performUIOperation();
return std::make_shared<ShadowNode>(reactTag, viewName, rootTag, props, instanceHandle);
}
@@ -41,4 +50,5 @@ void FabricUIManager::appendChildToSet(const ShadowNodeSetRef &childSet, const S
void FabricUIManager::completeRoot(int rootTag, const ShadowNodeSetRef &childSet) {
}
}}
} // namespace react
} // namespace facebook
+13 -4
View File
@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* 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.
*/
#pragma once
@@ -10,6 +15,7 @@ namespace facebook {
namespace react {
class ShadowNode;
class IFabricPlatformUIOperationManager;
typedef std::shared_ptr<const ShadowNode> ShadowNodeRef;
typedef folly::fbvector<const ShadowNodeRef> ShadowNodeSet;
@@ -17,7 +23,7 @@ typedef std::shared_ptr<const ShadowNodeSet> ShadowNodeSetRef;
class FabricUIManager {
public:
FabricUIManager();
FabricUIManager(const std::shared_ptr<IFabricPlatformUIOperationManager> &platformUIOperationManager);
ShadowNodeRef createNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle);
ShadowNodeRef cloneNode(const ShadowNodeRef &node);
@@ -28,7 +34,10 @@ public:
ShadowNodeSetRef createChildSet(int rootTag);
void appendChildToSet(const ShadowNodeSetRef &childSet, const ShadowNodeRef &childNode);
void completeRoot(int rootTag, const ShadowNodeSetRef &childSet);
private:
std::shared_ptr<IFabricPlatformUIOperationManager> platformUIOperationManager_;
};
}}
} // namespace react
} // namespace facebook
@@ -0,0 +1,23 @@
/**
* 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.
*/
#pragma once
namespace facebook {
namespace react {
/**
* An interface for FabricUIManager to perform platform-specific UI operations, like updating native UIView's in iOS.
*/
class IFabricPlatformUIOperationManager {
public:
// TODO: add meaningful methods
virtual void performUIOperation() = 0;
};
} // namespace react
} // namespace facebook
+6 -1
View File
@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* 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.
*/
#include "ShadowNode.h"
+6 -1
View File
@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* 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.
*/
#pragma once