Skip to content

Commit

Permalink
Update conversions.h
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis authored Nov 12, 2022
1 parent 0e94c17 commit 0f5cca2
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions ReactCommon/react/renderer/components/scrollview/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ inline void fromRawValue(
abort();
}

inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
ScrollViewMaintainVisibleContentPosition &result) {
auto map = (butter::map<std::string, RawValue>)value;

auto minIndexForVisible = map.find("minIndexForVisible");
if (minIndexForVisible != map.end()) {
fromRawValue(
context, minIndexForVisible->second, result.minIndexForVisible);
}
auto autoscrollToTopThreshold = map.find("autoscrollToTopThreshold");
if (autoscrollToTopThreshold != map.end()) {
fromRawValue(
context,
autoscrollToTopThreshold->second,
result.autoscrollToTopThreshold);
}
}

#if RN_DEBUG_STRING_CONVERTIBLE

inline std::string toString(const ScrollViewSnapToAlignment &value) {
switch (value) {
case ScrollViewSnapToAlignment::Start:
Expand Down Expand Up @@ -145,26 +167,6 @@ inline std::string toString(const ContentInsetAdjustmentBehavior &value) {
}
}

inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
ScrollViewMaintainVisibleContentPosition &result) {
auto map = (butter::map<std::string, RawValue>)value;

auto minIndexForVisible = map.find("minIndexForVisible");
if (minIndexForVisible != map.end()) {
fromRawValue(
context, minIndexForVisible->second, result.minIndexForVisible);
}
auto autoscrollToTopThreshold = map.find("autoscrollToTopThreshold");
if (autoscrollToTopThreshold != map.end()) {
fromRawValue(
context,
autoscrollToTopThreshold->second,
result.autoscrollToTopThreshold);
}
}

inline std::string toString(
const std::optional<ScrollViewMaintainVisibleContentPosition> &value) {
if (!value) {
Expand All @@ -175,5 +177,7 @@ inline std::string toString(
toString(value.value().autoscrollToTopThreshold) + "}";
}

#endif

} // namespace react
} // namespace facebook

0 comments on commit 0f5cca2

Please sign in to comment.