Files
smart-city-digital-twin-mar…/smart-app-city/frontend/node_modules/react-native-gesture-handler/apple/RNGestureHandlerButton.m
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

86 lines
2.8 KiB
Objective-C

//
// RNGestureHandlerButton.m
// RNGestureHandler
//
// Created by Krzysztof Magiera on 12/10/2017.
// Copyright © 2017 Software Mansion. All rights reserved.
//
#import "RNGestureHandlerButton.h"
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#endif
/**
* Gesture Handler Button components overrides standard mechanism used by RN
* to determine touch target, which normally would reurn the UIView that is placed
* as the deepest element in the view hierarchy.
* It's done this way as it allows for the actual target determination to run in JS
* where we can travers up the view ierarchy to find first element that want to became
* JS responder.
*
* Since we want to use native button (or actually a `UIControl`) we need to determine
* the target in native. This makes it impossible for JS responder based components to
* function as a subviews of the button component. Here we override `hitTest:withEvent:`
* method and we only determine the target to be either a subclass of `UIControl` or a
* view that has gesture recognizers registered.
*
* This "default" behaviour of target determinator should be sufficient in most of the
* cases as in fact it is not that common UI pattern to have many nested buttons (usually
* there are just two levels e.g. when you have clickable table cells with additional
* buttons). In cases when the default behaviour is insufficient it is recommended to use
* `TapGestureHandler` instead of a button which gives much better flexibility as far as
* controlling the touch flow.
*/
@implementation RNGestureHandlerButton
- (instancetype)init
{
self = [super init];
if (self) {
_hitTestEdgeInsets = UIEdgeInsetsZero;
_userEnabled = YES;
#if !TARGET_OS_TV && !TARGET_OS_OSX
[self setExclusiveTouch:YES];
#endif
}
return self;
}
- (BOOL)shouldHandleTouch:(RNGHUIView *)view
{
if ([view isKindOfClass:[RNGestureHandlerButton class]]) {
RNGestureHandlerButton *button = (RNGestureHandlerButton *)view;
return button.userEnabled;
}
#if !TARGET_OS_OSX
return [view isKindOfClass:[UIControl class]] || [view.gestureRecognizers count] > 0;
#else
return [view isKindOfClass:[NSControl class]] || [view.gestureRecognizers count] > 0;
#endif
}
#if !TARGET_OS_OSX
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (UIEdgeInsetsEqualToEdgeInsets(self.hitTestEdgeInsets, UIEdgeInsetsZero)) {
return [super pointInside:point withEvent:event];
}
CGRect hitFrame = UIEdgeInsetsInsetRect(self.bounds, self.hitTestEdgeInsets);
return CGRectContainsPoint(hitFrame, point);
}
- (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
RNGHUIView *inner = [super hitTest:point withEvent:event];
while (inner && ![self shouldHandleTouch:inner]) {
inner = inner.superview;
}
return inner;
}
#endif
@end