Files
react-native/ReactCommon/react/renderer/core/conversions.h
T
David Vacca 4076293aa1 Fix changes of View visibilities
Summary:
The purpose of this diff is to ensure that visibility changes are handled correctly when the value of "display" for a View changes from 'flex' to 'none'.

RNTester is nesting several Views with different kind of visibilities. When the user tap on an item there's a state update that changes the visibility styles for some of these views. Fabric does not reflect the right changes of visibility on the screen.

changelog: internal

Reviewed By: shergin

Differential Revision: D25841763

fbshipit-source-id: 769b97afb72939d346a4c6f2669ff938b35596bc
2021-01-10 19:46:40 -08:00

75 lines
1.7 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/core/LayoutPrimitives.h>
namespace facebook {
namespace react {
inline std::string toString(const LayoutDirection &layoutDirection) {
switch (layoutDirection) {
case LayoutDirection::Undefined:
return "undefined";
case LayoutDirection::LeftToRight:
return "ltr";
case LayoutDirection::RightToLeft:
return "rtl";
}
}
inline int toInt(const LayoutDirection &layoutDirection) {
switch (layoutDirection) {
case LayoutDirection::Undefined:
return 0;
case LayoutDirection::LeftToRight:
return 1;
case LayoutDirection::RightToLeft:
return 2;
}
}
inline int toInt(const DisplayType &displayType) {
switch (displayType) {
case DisplayType::None:
return 0;
case DisplayType::Flex:
return 1;
case DisplayType::Inline:
return 2;
}
}
inline std::string toString(const DisplayType &displayType) {
switch (displayType) {
case DisplayType::None:
return "none";
case DisplayType::Flex:
return "flex";
case DisplayType::Inline:
return "inline";
}
}
inline Size yogaMeassureToSize(int64_t value) {
static_assert(
sizeof(value) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
int32_t wBits = 0xFFFFFFFF & (value >> 32);
int32_t hBits = 0xFFFFFFFF & value;
float *measuredWidth = reinterpret_cast<float *>(&wBits);
float *measuredHeight = reinterpret_cast<float *>(&hBits);
return {*measuredWidth, *measuredHeight};
}
} // namespace react
} // namespace facebook