2018-05-17 20:03:37 -07:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-17 20:03:37 -07:00
|
|
|
*
|
|
|
|
* 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 <folly/dynamic.h>
|
2018-11-10 14:19:08 -08:00
|
|
|
#include <react/components/scrollview/primitives.h>
|
2018-05-17 20:03:37 -07:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2018-10-05 11:01:08 -07:00
|
|
|
inline void fromDynamic(
|
|
|
|
const folly::dynamic &value,
|
|
|
|
ScrollViewSnapToAlignment &result) {
|
2018-05-17 20:03:37 -07:00
|
|
|
auto string = value.asString();
|
2018-10-05 11:01:08 -07:00
|
|
|
if (string == "start") {
|
|
|
|
result = ScrollViewSnapToAlignment::Start;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "center") {
|
|
|
|
result = ScrollViewSnapToAlignment::Center;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "end") {
|
|
|
|
result = ScrollViewSnapToAlignment::End;
|
|
|
|
return;
|
|
|
|
}
|
2018-05-17 20:03:37 -07:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2018-10-05 11:01:08 -07:00
|
|
|
inline void fromDynamic(
|
|
|
|
const folly::dynamic &value,
|
|
|
|
ScrollViewIndicatorStyle &result) {
|
2018-05-17 20:03:37 -07:00
|
|
|
auto string = value.asString();
|
2018-10-05 11:01:08 -07:00
|
|
|
if (string == "default") {
|
|
|
|
result = ScrollViewIndicatorStyle::Default;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "black") {
|
|
|
|
result = ScrollViewIndicatorStyle::Black;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "white") {
|
|
|
|
result = ScrollViewIndicatorStyle::White;
|
|
|
|
return;
|
|
|
|
}
|
2018-05-17 20:03:37 -07:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2018-10-05 11:01:08 -07:00
|
|
|
inline void fromDynamic(
|
|
|
|
const folly::dynamic &value,
|
|
|
|
ScrollViewKeyboardDismissMode &result) {
|
2018-05-17 20:03:37 -07:00
|
|
|
auto string = value.asString();
|
2018-10-05 11:01:08 -07:00
|
|
|
if (string == "none") {
|
|
|
|
result = ScrollViewKeyboardDismissMode::None;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "on-drag") {
|
|
|
|
result = ScrollViewKeyboardDismissMode::OnDrag;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (string == "interactive") {
|
|
|
|
result = ScrollViewKeyboardDismissMode::Interactive;
|
|
|
|
return;
|
|
|
|
}
|
2018-05-17 20:03:37 -07:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string toString(const ScrollViewSnapToAlignment &value) {
|
|
|
|
switch (value) {
|
2018-10-05 11:01:08 -07:00
|
|
|
case ScrollViewSnapToAlignment::Start:
|
|
|
|
return "start";
|
|
|
|
case ScrollViewSnapToAlignment::Center:
|
|
|
|
return "center";
|
|
|
|
case ScrollViewSnapToAlignment::End:
|
|
|
|
return "end";
|
2018-05-17 20:03:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string toString(const ScrollViewIndicatorStyle &value) {
|
|
|
|
switch (value) {
|
2018-10-05 11:01:08 -07:00
|
|
|
case ScrollViewIndicatorStyle::Default:
|
|
|
|
return "default";
|
|
|
|
case ScrollViewIndicatorStyle::Black:
|
|
|
|
return "black";
|
|
|
|
case ScrollViewIndicatorStyle::White:
|
|
|
|
return "white";
|
2018-05-17 20:03:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string toString(const ScrollViewKeyboardDismissMode &value) {
|
|
|
|
switch (value) {
|
2018-10-05 11:01:08 -07:00
|
|
|
case ScrollViewKeyboardDismissMode::None:
|
|
|
|
return "none";
|
|
|
|
case ScrollViewKeyboardDismissMode::OnDrag:
|
|
|
|
return "on-drag";
|
|
|
|
case ScrollViewKeyboardDismissMode::Interactive:
|
|
|
|
return "interactive";
|
2018-05-17 20:03:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|