Fabric: Default support of `displayType` and `layoutDirection` layout metrics

Summary:
@public
Quite trivial.

Reviewed By: mdvacca

Differential Revision: D8528922

fbshipit-source-id: 1e21f988317eecc7aa659fd9b51600b9e2b7d69f
This commit is contained in:
Valentin Shergin 2018-06-22 11:53:50 -07:00 committed by Facebook Github Bot
parent 803c14bd98
commit 36c052ad96
3 changed files with 27 additions and 16 deletions

View File

@ -10,6 +10,8 @@
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import "RCTConversions.h" #import "RCTConversions.h"
using namespace facebook::react;
@implementation UIView (ComponentViewProtocol) @implementation UIView (ComponentViewProtocol)
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
@ -25,31 +27,40 @@
[childComponentView removeFromSuperview]; [childComponentView removeFromSuperview];
} }
- (void)updateProps:(facebook::react::SharedProps)props - (void)updateProps:(SharedProps)props
oldProps:(facebook::react::SharedProps)oldProps oldProps:(SharedProps)oldProps
{ {
// Default implementation does nothing. // Default implementation does nothing.
} }
- (void)updateEventEmitter:(facebook::react::SharedEventEmitter)eventEmitter - (void)updateEventEmitter:(SharedEventEmitter)eventEmitter
{ {
// Default implementation does nothing. // Default implementation does nothing.
} }
- (void)updateLocalData:(facebook::react::SharedLocalData)localData - (void)updateLocalData:(SharedLocalData)localData
oldLocalData:(facebook::react::SharedLocalData)oldLocalData oldLocalData:(SharedLocalData)oldLocalData
{ {
// Default implementation does nothing. // Default implementation does nothing.
} }
- (void)updateLayoutMetrics:(facebook::react::LayoutMetrics)layoutMetrics - (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics
oldLayoutMetrics:(facebook::react::LayoutMetrics)oldLayoutMetrics oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics
{ {
if (layoutMetrics.frame != oldLayoutMetrics.frame) { if (layoutMetrics.frame != oldLayoutMetrics.frame) {
self.frame = RCTCGRectFromRect(layoutMetrics.frame); self.frame = RCTCGRectFromRect(layoutMetrics.frame);
} }
// TODO: Apply another layout metrics here. if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) {
self.semanticContentAttribute =
layoutMetrics.layoutDirection == LayoutDirection::RightToLeft ?
UISemanticContentAttributeForceRightToLeft :
UISemanticContentAttributeForceLeftToRight;
}
if (layoutMetrics.displayType != oldLayoutMetrics.displayType) {
self.hidden = layoutMetrics.displayType == DisplayType::None;
}
} }
- (void)prepareForRecycle - (void)prepareForRecycle

View File

@ -26,18 +26,18 @@ namespace react {
Sealable::Sealable(): sealed_(false) {} Sealable::Sealable(): sealed_(false) {}
Sealable::Sealable(const Sealable& other): sealed_(false) {}; Sealable::Sealable(const Sealable &other): sealed_(false) {};
Sealable::Sealable(Sealable&& other) noexcept: sealed_(false) {}; Sealable::Sealable(Sealable &&other) noexcept: sealed_(false) {};
Sealable::~Sealable() noexcept {}; Sealable::~Sealable() noexcept {};
Sealable& Sealable::operator= (const Sealable& other) { Sealable &Sealable::operator=(const Sealable &other) {
ensureUnsealed(); ensureUnsealed();
return *this; return *this;
} }
Sealable& Sealable::operator= (Sealable&& other) noexcept { Sealable &Sealable::operator=(Sealable &&other) noexcept {
ensureUnsealed(); ensureUnsealed();
return *this; return *this;
}; };

View File

@ -43,11 +43,11 @@ namespace react {
class Sealable { class Sealable {
public: public:
Sealable(); Sealable();
Sealable(const Sealable& other); Sealable(const Sealable &other);
Sealable(Sealable&& other) noexcept; Sealable(Sealable &&other) noexcept;
~Sealable() noexcept; ~Sealable() noexcept;
Sealable& operator=(const Sealable& other); Sealable &operator=(const Sealable &other);
Sealable& operator=(Sealable&& other) noexcept; Sealable &operator=(Sealable &&other) noexcept;
/* /*
* Seals the object. This operation is irreversible; * Seals the object. This operation is irreversible;