Files
react-native/ReactCommon/react/renderer/components/picker/androidpicker/AndroidDialogPickerProps.h
T
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00

78 lines
2.1 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/components/view/ViewProps.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/imagemanager/primitives.h>
#include <cinttypes>
#include <vector>
namespace facebook {
namespace react {
struct AndroidDialogPickerItemsStruct {
std::string label;
int color;
};
static inline void fromRawValue(
const RawValue &value,
AndroidDialogPickerItemsStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto label = map.find("label");
if (label != map.end()) {
fromRawValue(label->second, result.label);
}
auto color = map.find("color");
// C++ props are not used on Android at the moment, so we can leave
// result.color uninitialized if the JS prop has a null value. TODO: revisit
// this once we start using C++ props on Android.
if (color != map.end() && color->second.hasValue()) {
fromRawValue(color->second, result.color);
}
}
static inline std::string toString(
const AndroidDialogPickerItemsStruct &value) {
return "[Object AndroidDialogPickerItemsStruct]";
}
static inline void fromRawValue(
const RawValue &value,
std::vector<AndroidDialogPickerItemsStruct> &result) {
auto items = (std::vector<RawValue>)value;
for (const auto &item : items) {
AndroidDialogPickerItemsStruct newItem;
fromRawValue(item, newItem);
result.emplace_back(newItem);
}
}
class AndroidDialogPickerProps final : public ViewProps {
public:
AndroidDialogPickerProps() = default;
AndroidDialogPickerProps(
const AndroidDialogPickerProps &sourceProps,
const RawProps &rawProps);
#pragma mark - Props
const SharedColor color{};
const bool enabled{true};
const std::vector<AndroidDialogPickerItemsStruct> items{};
const std::string prompt{""};
const int selected{0};
};
} // namespace react
} // namespace facebook