Files
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
2026-06-01 18:00:35 -04:00

94 lines
3.4 KiB
C++

#include "EventHandlerRegistry.h"
#include "WorkletEventHandler.h"
#include <utility>
namespace reanimated {
void EventHandlerRegistry::registerEventHandler(
const std::shared_ptr<WorkletEventHandler> &eventHandler) {
const std::lock_guard<std::mutex> lock(instanceMutex);
const auto &eventName = eventHandler->getEventName();
auto handlerId = eventHandler->getHandlerId();
if (eventHandler->shouldIgnoreEmitterReactTag()) {
eventMappingsWithoutTag[eventName][handlerId] = eventHandler;
} else {
const auto emitterReactTag = eventHandler->getEmitterReactTag();
const auto eventHash = std::make_pair(emitterReactTag, eventName);
eventMappingsWithTag[eventHash][handlerId] = eventHandler;
}
eventHandlers[handlerId] = eventHandler;
}
void EventHandlerRegistry::unregisterEventHandler(const uint64_t id) {
const std::lock_guard<std::mutex> lock(instanceMutex);
auto handlerIt = eventHandlers.find(id);
if (handlerIt != eventHandlers.end()) {
const auto &eventHandler = handlerIt->second;
const auto &eventName = eventHandler->getEventName();
if (eventHandler->shouldIgnoreEmitterReactTag()) {
const auto eventMappingIt = eventMappingsWithoutTag.find(eventName);
auto &handlersMap = eventMappingIt->second;
handlersMap.erase(id);
if (handlersMap.empty()) {
eventMappingsWithoutTag.erase(eventMappingIt);
}
} else {
const auto emitterReactTag = eventHandler->getEmitterReactTag();
const auto eventHash = std::make_pair(emitterReactTag, eventName);
const auto eventMappingIt = eventMappingsWithTag.find(eventHash);
auto &handlersMap = eventMappingIt->second;
handlersMap.erase(id);
if (handlersMap.empty()) {
eventMappingsWithTag.erase(eventMappingIt);
}
}
eventHandlers.erase(handlerIt);
}
}
void EventHandlerRegistry::processEvent(
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
const double eventTimestamp,
const std::string &eventName,
const int emitterReactTag,
const jsi::Value &eventPayload) {
std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
{
const std::lock_guard<std::mutex> lock(instanceMutex);
auto handlersIt = eventMappingsWithoutTag.find(eventName);
if (handlersIt != eventMappingsWithoutTag.end()) {
for (auto handler : handlersIt->second) {
handlersForEvent.push_back(handler.second);
}
}
const auto eventHash = std::make_pair(emitterReactTag, eventName);
auto handlersWithTagIt = eventMappingsWithTag.find(eventHash);
if (handlersWithTagIt != eventMappingsWithTag.end()) {
for (auto handler : handlersWithTagIt->second) {
handlersForEvent.push_back(handler.second);
}
}
}
jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
eventPayload.asObject(rt).setProperty(
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
for (auto handler : handlersForEvent) {
handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
}
}
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
const std::string &eventName,
const int emitterReactTag) {
const std::lock_guard<std::mutex> lock(instanceMutex);
const auto eventHash = std::make_pair(emitterReactTag, eventName);
auto it = eventMappingsWithTag.find(eventHash);
return it != eventMappingsWithTag.end() && !it->second.empty();
}
} // namespace reanimated