mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This builds on previous diff to properly parse `<Picker.Item/>` into a cpp struct. This fixes the dummy text and text color TODOs. Changelog: [iOS][Fabric] Fabric Picker support Reviewed By: sammy-SC Differential Revision: D23964557 fbshipit-source-id: f42c6c9cf410bfc5e66ff078645b6378548481de
48 lines
1.3 KiB
C++
48 lines
1.3 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/iospicker/primitives.h>
|
|
|
|
#include <vector>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
inline void fromRawValue(
|
|
const RawValue &value,
|
|
std::vector<PickerItemsStruct> &items) {
|
|
assert(value.hasType<std::vector<RawValue>>());
|
|
auto array = (std::vector<RawValue>)value;
|
|
items.reserve(array.size());
|
|
|
|
for (auto const &val : array) {
|
|
bool check = val.hasType<better::map<std::string, RawValue>>();
|
|
assert(check);
|
|
auto map = (better::map<std::string, RawValue>)val;
|
|
PickerItemsStruct item;
|
|
|
|
if (map.find("label") != map.end()) {
|
|
assert(map.at("label").hasType<std::string>());
|
|
item.label = (std::string)map.at("label");
|
|
}
|
|
if (map.find("value") != map.end()) {
|
|
assert(map.at("value").hasType<std::string>());
|
|
item.value = (std::string)map.at("value");
|
|
}
|
|
if (map.find("textColor") != map.end()) {
|
|
assert(map.at("textColor").hasType<int>());
|
|
item.textColor = (int)map.at("textColor");
|
|
}
|
|
items.push_back(item);
|
|
}
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|