Fabric/Text: Connecting the dots

Summary: This change registers the Text module.

Reviewed By: mdvacca

Differential Revision: D7784509

fbshipit-source-id: 0de3e432b8f975927547ba990586f99655e8322d
This commit is contained in:
Valentin Shergin 2018-05-08 18:50:15 -07:00 коммит произвёл Facebook Github Bot
Родитель 81bdd36204
Коммит f3893aab3b
4 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -63,7 +63,6 @@ static NSLineBreakMode RCTNSLineBreakModeFromWritingDirection(EllipsizeMode elli
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:frame.origin];
}
- (NSTextStorage *)_textStorageAndLayoutManagerWithAttributesString:(NSAttributedString *)attributedString
paragraphAttributes:(ParagraphAttributes)paragraphAttributes
size:(CGSize)size

Просмотреть файл

@ -52,6 +52,7 @@ rn_xplat_cxx_library(
"xplat//third-party/glog:glog",
react_native_xplat_target("fabric/core:core"),
react_native_xplat_target("fabric/debug:debug"),
react_native_xplat_target("fabric/text:text"),
react_native_xplat_target("fabric/view:view"),
],
)

Просмотреть файл

@ -39,12 +39,33 @@ static const RawProps rawPropsFromDynamic(const folly::dynamic object) {
}
static const std::string componentNameByReactViewName(std::string viewName) {
// We need this function only for the transition period;
// eventually, all names will be unified.
std::string rctPrefix("RCT");
if (std::mismatch(rctPrefix.begin(), rctPrefix.end(), viewName.begin()).first == rctPrefix.end()) {
// If `viewName` has "RCT" prefix, remove it.
viewName.erase(0, 3);
}
// Fabric uses slightly new names for Text components because of differences
// in semantic.
if (viewName == "Text") {
return "Paragraph";
}
if (viewName == "VirtualText") {
return "Text";
}
// We need this temporarly for testing purposes until we have proper
// implementation of <ScrollView> component.
if (
viewName == "ScrollContentView" ||
viewName == "ScrollView"
) {
return "View";
}
return viewName;
}

Просмотреть файл

@ -5,6 +5,9 @@
#include <fabric/core/LayoutContext.h>
#include <fabric/uimanager/ComponentDescriptorRegistry.h>
#include <fabric/uimanager/FabricUIManager.h>
#include <fabric/text/ParagraphComponentDescriptor.h>
#include <fabric/text/TextComponentDescriptor.h>
#include <fabric/text/RawTextComponentDescriptor.h>
#include <fabric/view/ViewComponentDescriptor.h>
#include <fabric/view/ViewProps.h>
#include <fabric/view/ViewShadowNode.h>
@ -16,8 +19,11 @@ namespace react {
Scheduler::Scheduler() {
auto componentDescriptorRegistry = std::make_shared<ComponentDescriptorRegistry>();
SharedComponentDescriptor viewComponentDescriptor = std::make_shared<ViewComponentDescriptor>();
componentDescriptorRegistry->registerComponentDescriptor(viewComponentDescriptor);
componentDescriptorRegistry->registerComponentDescriptor(std::make_shared<ViewComponentDescriptor>());
componentDescriptorRegistry->registerComponentDescriptor(std::make_shared<ParagraphComponentDescriptor>());
componentDescriptorRegistry->registerComponentDescriptor(std::make_shared<TextComponentDescriptor>());
componentDescriptorRegistry->registerComponentDescriptor(std::make_shared<RawTextComponentDescriptor>());
uiManager_ = std::make_shared<FabricUIManager>(componentDescriptorRegistry);
uiManager_->setDelegate(this);