mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-19 10:58:27 +08:00
Summary: We are moving to more stable APIs removing all mentiones of the effort name from the codebase. Reviewed By: mdvacca Differential Revision: D12912894 fbshipit-source-id: 4a0c6b9e7454b8b14e62d419e9e9311dc0c56e7a
107 lines
2.4 KiB
C++
107 lines
2.4 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 <folly/dynamic.h>
|
|
#include <react/components/view/AccessibilityPrimitives.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
inline void fromString(const std::string &string, AccessibilityTraits &result) {
|
|
if (string == "none") {
|
|
result = AccessibilityTraits::None;
|
|
return;
|
|
}
|
|
if (string == "button") {
|
|
result = AccessibilityTraits::Button;
|
|
return;
|
|
}
|
|
if (string == "link") {
|
|
result = AccessibilityTraits::Link;
|
|
return;
|
|
}
|
|
if (string == "image") {
|
|
result = AccessibilityTraits::Image;
|
|
return;
|
|
}
|
|
if (string == "selected") {
|
|
result = AccessibilityTraits::Selected;
|
|
return;
|
|
}
|
|
if (string == "plays") {
|
|
result = AccessibilityTraits::PlaysSound;
|
|
return;
|
|
}
|
|
if (string == "keyboardkey") {
|
|
result = AccessibilityTraits::KeyboardKey;
|
|
return;
|
|
}
|
|
if (string == "text") {
|
|
result = AccessibilityTraits::StaticText;
|
|
return;
|
|
}
|
|
if (string == "disabled") {
|
|
result = AccessibilityTraits::NotEnabled;
|
|
return;
|
|
}
|
|
if (string == "frequentUpdates") {
|
|
result = AccessibilityTraits::UpdatesFrequently;
|
|
return;
|
|
}
|
|
if (string == "search") {
|
|
result = AccessibilityTraits::SearchField;
|
|
return;
|
|
}
|
|
if (string == "startsMedia") {
|
|
result = AccessibilityTraits::StartsMediaSession;
|
|
return;
|
|
}
|
|
if (string == "adjustable") {
|
|
result = AccessibilityTraits::Adjustable;
|
|
return;
|
|
}
|
|
if (string == "allowsDirectInteraction") {
|
|
result = AccessibilityTraits::AllowsDirectInteraction;
|
|
return;
|
|
}
|
|
if (string == "pageTurn") {
|
|
result = AccessibilityTraits::CausesPageTurn;
|
|
return;
|
|
}
|
|
if (string == "header") {
|
|
result = AccessibilityTraits::Header;
|
|
return;
|
|
}
|
|
abort();
|
|
}
|
|
|
|
inline void fromDynamic(
|
|
const folly::dynamic &value,
|
|
AccessibilityTraits &result) {
|
|
if (value.isString()) {
|
|
fromString(value.asString(), result);
|
|
return;
|
|
}
|
|
|
|
if (value.isArray()) {
|
|
result = {};
|
|
for (auto &item : value) {
|
|
auto string = item.asString();
|
|
AccessibilityTraits itemAccessibilityTraits;
|
|
fromString(value.asString(), itemAccessibilityTraits);
|
|
result = result | itemAccessibilityTraits;
|
|
}
|
|
}
|
|
|
|
abort();
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|