Files
react-native/ReactCommon/fabric/components/view/ViewEventEmitter.cpp
T
Ramanpreet Nara 7c0b707754 Extract TouchEventEmitter from ViewEventEmitter
Summary: In the future, we may want some components (like Virtual Text) to handle only touch events. Therefore, I've extracted `TouchEventEmitter` from `ViewEventEmitter`.

Reviewed By: shergin

Differential Revision: D9696903

fbshipit-source-id: f6acc90d8ff53b5e6badaa472a5e099fb7cf03ff
2018-09-10 11:41:32 -07:00

43 lines
1.0 KiB
C++

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "ViewEventEmitter.h"
namespace facebook {
namespace react {
#pragma mark - Accessibility
void ViewEventEmitter::onAccessibilityAction(const std::string &name) const {
dispatchEvent("accessibilityAction", folly::dynamic::object("action", name));
}
void ViewEventEmitter::onAccessibilityTap() const {
dispatchEvent("accessibilityTap");
}
void ViewEventEmitter::onAccessibilityMagicTap() const {
dispatchEvent("magicTap");
}
#pragma mark - Layout
void ViewEventEmitter::onLayout(const LayoutMetrics &layoutMetrics) const {
folly::dynamic payload = folly::dynamic::object();
const auto &frame = layoutMetrics.frame;
payload["layout"] = folly::dynamic::object
("x", frame.origin.x)
("y", frame.origin.y)
("width", frame.size.width)
("height", frame.size.height);
dispatchEvent("layout", payload);
}
} // namespace react
} // namespace facebook