Add displayMode parameter into startSurface and setSurfaceProps methods
Summary: This diff extends startSurface and setSurfaceProps methods with the new parameter called displayMode changelog: [internal] internal Reviewed By: yungsters Differential Revision: D27669847 fbshipit-source-id: c2ddb690ca897e46e00f07b491b91bb2bc8e847d
This commit is contained in:
Родитель
2793bba278
Коммит
bdb9a1e094
|
@ -76,7 +76,10 @@ void SurfaceHandler::start() const noexcept {
|
|||
link_.shadowTree = shadowTree.get();
|
||||
|
||||
link_.uiManager->startSurface(
|
||||
std::move(shadowTree), parameters.moduleName, parameters.props);
|
||||
std::move(shadowTree),
|
||||
parameters.moduleName,
|
||||
parameters.props,
|
||||
parameters_.displayMode);
|
||||
|
||||
link_.status = Status::Running;
|
||||
|
||||
|
@ -121,7 +124,10 @@ void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept {
|
|||
}
|
||||
|
||||
link_.uiManager->setSurfaceProps(
|
||||
parameters_.surfaceId, parameters_.moduleName, parameters_.props);
|
||||
parameters_.surfaceId,
|
||||
parameters_.moduleName,
|
||||
parameters_.props,
|
||||
parameters_.displayMode);
|
||||
|
||||
applyDisplayMode(displayMode);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,8 @@ void UIManager::setIsJSResponder(
|
|||
void UIManager::startSurface(
|
||||
ShadowTree::Unique &&shadowTree,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const {
|
||||
folly::dynamic const &props,
|
||||
DisplayMode displayMode) const {
|
||||
SystraceSection s("UIManager::startSurface");
|
||||
|
||||
auto surfaceId = shadowTree->getSurfaceId();
|
||||
|
@ -160,14 +161,16 @@ void UIManager::startSurface(
|
|||
return;
|
||||
}
|
||||
|
||||
uiManagerBinding->startSurface(runtime, surfaceId, moduleName, props);
|
||||
uiManagerBinding->startSurface(
|
||||
runtime, surfaceId, moduleName, props, displayMode);
|
||||
});
|
||||
}
|
||||
|
||||
void UIManager::setSurfaceProps(
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const {
|
||||
folly::dynamic const &props,
|
||||
DisplayMode displayMode) const {
|
||||
SystraceSection s("UIManager::setSurfaceProps");
|
||||
|
||||
runtimeExecutor_([=](jsi::Runtime &runtime) {
|
||||
|
@ -176,7 +179,8 @@ void UIManager::setSurfaceProps(
|
|||
return;
|
||||
}
|
||||
|
||||
uiManagerBinding->setSurfaceProps(runtime, surfaceId, moduleName, props);
|
||||
uiManagerBinding->setSurfaceProps(
|
||||
runtime, surfaceId, moduleName, props, displayMode);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -87,12 +87,14 @@ class UIManager final : public ShadowTreeDelegate {
|
|||
void startSurface(
|
||||
ShadowTree::Unique &&shadowTree,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
folly::dynamic const &props,
|
||||
DisplayMode displayMode) const;
|
||||
|
||||
void setSurfaceProps(
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
folly::dynamic const &props,
|
||||
DisplayMode displayMode) const;
|
||||
|
||||
ShadowTree::Unique stopSurface(SurfaceId surfaceId) const;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/core/LayoutableShadowNode.h>
|
||||
#include <react/renderer/debug/SystraceSection.h>
|
||||
#include <react/renderer/uimanager/primitives.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
|
@ -143,7 +144,8 @@ void UIManagerBinding::startSurface(
|
|||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &initalProps) const {
|
||||
folly::dynamic const &initalProps,
|
||||
DisplayMode displayMode) const {
|
||||
folly::dynamic parameters = folly::dynamic::object();
|
||||
parameters["rootTag"] = surfaceId;
|
||||
parameters["initialProps"] = initalProps;
|
||||
|
@ -158,14 +160,16 @@ void UIManagerBinding::startSurface(
|
|||
method.call(
|
||||
runtime,
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
jsi::valueFromDynamic(runtime, parameters),
|
||||
jsi::Value(runtime, displayModeToInt(displayMode))});
|
||||
} else {
|
||||
callMethodOfModule(
|
||||
runtime,
|
||||
"AppRegistry",
|
||||
"runApplication",
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
jsi::valueFromDynamic(runtime, parameters),
|
||||
jsi::Value(runtime, displayModeToInt(displayMode))});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +177,8 @@ void UIManagerBinding::setSurfaceProps(
|
|||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &initalProps) const {
|
||||
folly::dynamic const &initalProps,
|
||||
DisplayMode displayMode) const {
|
||||
folly::dynamic parameters = folly::dynamic::object();
|
||||
parameters["rootTag"] = surfaceId;
|
||||
parameters["initialProps"] = initalProps;
|
||||
|
@ -188,14 +193,16 @@ void UIManagerBinding::setSurfaceProps(
|
|||
method.call(
|
||||
runtime,
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
jsi::valueFromDynamic(runtime, parameters),
|
||||
jsi::Value(runtime, displayModeToInt(displayMode))});
|
||||
} else {
|
||||
callMethodOfModule(
|
||||
runtime,
|
||||
"AppRegistry",
|
||||
"setSurfaceProps",
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
jsi::valueFromDynamic(runtime, parameters),
|
||||
jsi::Value(runtime, displayModeToInt(displayMode))});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ class UIManagerBinding : public jsi::HostObject {
|
|||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &initalProps) const;
|
||||
folly::dynamic const &initalProps,
|
||||
DisplayMode displayMode) const;
|
||||
|
||||
/*
|
||||
* Updates the React Native Surface identified with surfaceId and moduleName
|
||||
|
@ -64,7 +65,8 @@ class UIManagerBinding : public jsi::HostObject {
|
|||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
folly::dynamic const &props,
|
||||
DisplayMode displayMode) const;
|
||||
|
||||
/*
|
||||
* Stops React Native Surface with given id.
|
||||
|
|
|
@ -124,6 +124,17 @@ inline static SurfaceId surfaceIdFromValue(
|
|||
return (SurfaceId)value.getNumber();
|
||||
}
|
||||
|
||||
inline static int displayModeToInt(DisplayMode const value) {
|
||||
switch (value) {
|
||||
case DisplayMode::Visible:
|
||||
return 1;
|
||||
case DisplayMode::Suspended:
|
||||
return 2;
|
||||
case DisplayMode::Hidden:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
inline static std::string stringFromValue(
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &value) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче