This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,21 @@
/*
* 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 "AndroidDialogPickerShadowNode.h"
#include <react/core/ConcreteComponentDescriptor.h>
namespace facebook {
namespace react {
using AndroidDialogPickerComponentDescriptor =
ConcreteComponentDescriptor<AndroidDialogPickerShadowNode>;
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,23 @@
/*
* 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.
*/
#include "AndroidDialogPickerEventEmitter.h"
namespace facebook {
namespace react {
void AndroidDialogPickerEventEmitter::onSelect(
AndroidDialogPickerOnSelectStruct event) const {
dispatchEvent("select", [event = std::move(event)](jsi::Runtime &runtime) {
auto payload = jsi::Object(runtime);
payload.setProperty(runtime, "position", event.position);
return payload;
});
}
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,27 @@
/*
* 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/components/view/ViewEventEmitter.h>
namespace facebook {
namespace react {
struct AndroidDialogPickerOnSelectStruct {
int position;
};
class AndroidDialogPickerEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
void onSelect(AndroidDialogPickerOnSelectStruct value) const;
};
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,28 @@
/*
* 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.
*/
#include "AndroidDialogPickerProps.h"
#include <react/components/image/conversions.h>
#include <react/core/propsConversions.h>
namespace facebook {
namespace react {
AndroidDialogPickerProps::AndroidDialogPickerProps(
const AndroidDialogPickerProps &sourceProps,
const RawProps &rawProps)
: ViewProps(sourceProps, rawProps),
color(convertRawProp(rawProps, "color", sourceProps.color, {})),
enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})),
items(convertRawProp(rawProps, "items", sourceProps.items, {})),
prompt(convertRawProp(rawProps, "prompt", sourceProps.prompt, {""})),
selected(
convertRawProp(rawProps, "selected", sourceProps.selected, {0})) {}
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,77 @@
/*
* 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/components/view/ViewProps.h>
#include <react/core/propsConversions.h>
#include <react/graphics/Color.h>
#include <react/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

View File

@ -0,0 +1,16 @@
/*
* 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.
*/
#include "AndroidDialogPickerShadowNode.h"
namespace facebook {
namespace react {
extern const char AndroidDialogPickerComponentName[] = "AndroidDialogPicker";
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,29 @@
/*
* 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 "AndroidDialogPickerEventEmitter.h"
#include "AndroidDialogPickerProps.h"
#include <react/components/view/ConcreteViewShadowNode.h>
namespace facebook {
namespace react {
extern const char AndroidDialogPickerComponentName[];
/*
* `ShadowNode` for <AndroidDialogPicker> component.
*/
using AndroidDialogPickerShadowNode = ConcreteViewShadowNode<
AndroidDialogPickerComponentName,
AndroidDialogPickerProps,
AndroidDialogPickerEventEmitter>;
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,21 @@
/*
* 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 "AndroidDropdownPickerShadowNode.h"
#include <react/core/ConcreteComponentDescriptor.h>
namespace facebook {
namespace react {
using AndroidDropdownPickerComponentDescriptor =
ConcreteComponentDescriptor<AndroidDropdownPickerShadowNode>;
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,23 @@
/*
* 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.
*/
#include "AndroidDropdownPickerEventEmitter.h"
namespace facebook {
namespace react {
void AndroidDropdownPickerEventEmitter::onSelect(
AndroidDropdownPickerOnSelectStruct event) const {
dispatchEvent("select", [event = std::move(event)](jsi::Runtime &runtime) {
auto payload = jsi::Object(runtime);
payload.setProperty(runtime, "position", event.position);
return payload;
});
}
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,27 @@
/*
* 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/components/view/ViewEventEmitter.h>
namespace facebook {
namespace react {
struct AndroidDropdownPickerOnSelectStruct {
int position;
};
class AndroidDropdownPickerEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
void onSelect(AndroidDropdownPickerOnSelectStruct value) const;
};
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,28 @@
/*
* 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.
*/
#include "AndroidDropdownPickerProps.h"
#include <react/components/image/conversions.h>
#include <react/core/propsConversions.h>
namespace facebook {
namespace react {
AndroidDropdownPickerProps::AndroidDropdownPickerProps(
const AndroidDropdownPickerProps &sourceProps,
const RawProps &rawProps)
: ViewProps(sourceProps, rawProps),
color(convertRawProp(rawProps, "color", sourceProps.color, {})),
enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})),
items(convertRawProp(rawProps, "items", sourceProps.items, {})),
prompt(convertRawProp(rawProps, "prompt", sourceProps.prompt, {""})),
selected(
convertRawProp(rawProps, "selected", sourceProps.selected, {0})) {}
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,77 @@
/*
* 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/components/view/ViewProps.h>
#include <react/core/propsConversions.h>
#include <react/graphics/Color.h>
#include <react/imagemanager/primitives.h>
#include <cinttypes>
#include <vector>
namespace facebook {
namespace react {
struct AndroidDropdownPickerItemsStruct {
std::string label;
int color;
};
static inline void fromRawValue(
const RawValue &value,
AndroidDropdownPickerItemsStruct &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 AndroidDropdownPickerItemsStruct &value) {
return "[Object AndroidDropdownPickerItemsStruct]";
}
static inline void fromRawValue(
const RawValue &value,
std::vector<AndroidDropdownPickerItemsStruct> &result) {
auto items = (std::vector<RawValue>)value;
for (const auto &item : items) {
AndroidDropdownPickerItemsStruct newItem;
fromRawValue(item, newItem);
result.emplace_back(newItem);
}
}
class AndroidDropdownPickerProps final : public ViewProps {
public:
AndroidDropdownPickerProps() = default;
AndroidDropdownPickerProps(
const AndroidDropdownPickerProps &sourceProps,
const RawProps &rawProps);
#pragma mark - Props
const SharedColor color{};
const bool enabled{true};
const std::vector<AndroidDropdownPickerItemsStruct> items{};
const std::string prompt{""};
const int selected{0};
};
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,17 @@
/*
* 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.
*/
#include "AndroidDropdownPickerShadowNode.h"
namespace facebook {
namespace react {
extern const char AndroidDropdownPickerComponentName[] =
"AndroidDropdownPicker";
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,29 @@
/*
* 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 "AndroidDropdownPickerEventEmitter.h"
#include "AndroidDropdownPickerProps.h"
#include <react/components/view/ConcreteViewShadowNode.h>
namespace facebook {
namespace react {
extern const char AndroidDropdownPickerComponentName[];
/*
* `ShadowNode` for <AndroidDropdownPicker> component.
*/
using AndroidDropdownPickerShadowNode = ConcreteViewShadowNode<
AndroidDropdownPickerComponentName,
AndroidDropdownPickerProps,
AndroidDropdownPickerEventEmitter>;
} // namespace react
} // namespace facebook