Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ struct ColorStop {
bool operator==(const ColorStop& other) const = default;
SharedColor color;
ValueUnit position;

#ifdef RN_SERIALIZABLE_STATE
folly::dynamic toDynamic() const {
folly::dynamic result = folly::dynamic::object();
result["color"] = *color;
result["position"] = position.toDynamic();
return result;
}
#endif
};

struct ProcessedColorStop {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#pragma once

#ifdef RN_SERIALIZABLE_STATE
#include <folly/dynamic.h>
#endif

namespace facebook::react {

enum class UnitType {
Expand Down Expand Up @@ -44,5 +48,18 @@ struct ValueUnit {
constexpr operator bool() const {
return unit != UnitType::Undefined;
}

#ifdef RN_SERIALIZABLE_STATE
folly::dynamic toDynamic() const {
switch (unit) {
case UnitType::Undefined:
return nullptr;
case UnitType::Point:
return value;
case UnitType::Percent:
return std::format("{}%", value);
}
}
#endif
};
} // namespace facebook::react
Loading