- 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
232 lines
7.2 KiB
Plaintext
232 lines
7.2 KiB
Plaintext
//
|
|
// RNNativeViewHandler.m
|
|
// RNGestureHandler
|
|
//
|
|
// Created by Krzysztof Magiera on 12/10/2017.
|
|
// Copyright © 2017 Software Mansion. All rights reserved.
|
|
//
|
|
|
|
#import "RNNativeViewHandler.h"
|
|
|
|
#if !TARGET_OS_OSX
|
|
#import <UIKit/UIGestureRecognizerSubclass.h>
|
|
#endif
|
|
|
|
#import <React/RCTConvert.h>
|
|
#import <React/UIView+React.h>
|
|
|
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
#import <React/RCTScrollViewComponentView.h>
|
|
#else
|
|
#import <React/RCTScrollView.h>
|
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
|
|
#if !TARGET_OS_OSX
|
|
|
|
#pragma mark RNDummyGestureRecognizer
|
|
|
|
@implementation RNDummyGestureRecognizer {
|
|
__weak RNGestureHandler *_gestureHandler;
|
|
}
|
|
|
|
- (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler
|
|
{
|
|
if ((self = [super initWithTarget:gestureHandler action:@selector(handleGesture:)])) {
|
|
_gestureHandler = gestureHandler;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
|
|
{
|
|
[_gestureHandler setCurrentPointerType:event];
|
|
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];
|
|
}
|
|
|
|
- (void)touchesMoved:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
|
|
{
|
|
[_gestureHandler.pointerTracker touchesMoved:touches withEvent:event];
|
|
}
|
|
|
|
- (void)touchesEnded:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
|
|
{
|
|
[_gestureHandler.pointerTracker touchesEnded:touches withEvent:event];
|
|
self.state = UIGestureRecognizerStateFailed;
|
|
[self reset];
|
|
}
|
|
|
|
- (void)touchesCancelled:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
|
|
{
|
|
[_gestureHandler.pointerTracker touchesCancelled:touches withEvent:event];
|
|
self.state = UIGestureRecognizerStateCancelled;
|
|
[self reset];
|
|
}
|
|
|
|
- (void)reset
|
|
{
|
|
[_gestureHandler.pointerTracker reset];
|
|
[super reset];
|
|
[_gestureHandler reset];
|
|
}
|
|
|
|
@end
|
|
|
|
#pragma mark RNNativeViewGestureHandler
|
|
|
|
@implementation RNNativeViewGestureHandler {
|
|
BOOL _shouldActivateOnStart;
|
|
BOOL _disallowInterruption;
|
|
}
|
|
|
|
- (instancetype)initWithTag:(NSNumber *)tag
|
|
{
|
|
if ((self = [super initWithTag:tag])) {
|
|
_recognizer = [[RNDummyGestureRecognizer alloc] initWithGestureHandler:self];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)configure:(NSDictionary *)config
|
|
{
|
|
[super configure:config];
|
|
_shouldActivateOnStart = [RCTConvert BOOL:config[@"shouldActivateOnStart"]];
|
|
_disallowInterruption = [RCTConvert BOOL:config[@"disallowInterruption"]];
|
|
}
|
|
|
|
- (void)bindToView:(UIView *)view
|
|
{
|
|
// For UIControl based views (UIButton, UISwitch) we provide special handling that would allow
|
|
// for properties like `disallowInterruption` to work.
|
|
if ([view isKindOfClass:[UIControl class]]) {
|
|
UIControl *control = (UIControl *)view;
|
|
[control addTarget:self action:@selector(handleTouchDown:forEvent:) forControlEvents:UIControlEventTouchDown];
|
|
[control addTarget:self
|
|
action:@selector(handleTouchUpOutside:forEvent:)
|
|
forControlEvents:UIControlEventTouchUpOutside];
|
|
[control addTarget:self
|
|
action:@selector(handleTouchUpInside:forEvent:)
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
[control addTarget:self action:@selector(handleDragExit:forEvent:) forControlEvents:UIControlEventTouchDragExit];
|
|
[control addTarget:self action:@selector(handleDragEnter:forEvent:) forControlEvents:UIControlEventTouchDragEnter];
|
|
[control addTarget:self action:@selector(handleTouchCancel:forEvent:) forControlEvents:UIControlEventTouchCancel];
|
|
} else {
|
|
[super bindToView:view];
|
|
}
|
|
|
|
// We can restore default scrollview behaviour to delay touches to scrollview's children
|
|
// because gesture handler system can handle cancellation of scroll recognizer when JS responder
|
|
// is set
|
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
if ([view isKindOfClass:[RCTScrollViewComponentView class]]) {
|
|
UIScrollView *scrollView = ((RCTScrollViewComponentView *)view).scrollView;
|
|
scrollView.delaysContentTouches = YES;
|
|
}
|
|
#else
|
|
if ([view isKindOfClass:[RCTScrollView class]]) {
|
|
// This part of the code is coupled with RN implementation of ScrollView native wrapper and
|
|
// we expect for RCTScrollView component to contain a subclass of UIScrollview as the only
|
|
// subview
|
|
UIScrollView *scrollView = [view.subviews objectAtIndex:0];
|
|
scrollView.delaysContentTouches = YES;
|
|
}
|
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
}
|
|
|
|
- (void)handleTouchDown:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
[self setCurrentPointerType:event];
|
|
[self reset];
|
|
|
|
if (_disallowInterruption) {
|
|
// When `disallowInterruption` is set we cancel all gesture handlers when this UIControl
|
|
// gets DOWN event
|
|
for (RNGHUITouch *touch in [event allTouches]) {
|
|
for (UIGestureRecognizer *recogn in [touch gestureRecognizers]) {
|
|
recogn.enabled = NO;
|
|
recogn.enabled = YES;
|
|
}
|
|
}
|
|
}
|
|
|
|
[self sendEventsInState:RNGestureHandlerStateActive
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
|
|
}
|
|
|
|
- (void)handleTouchUpOutside:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
[self sendEventsInState:RNGestureHandlerStateEnd
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
|
|
}
|
|
|
|
- (void)handleTouchUpInside:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
[self sendEventsInState:RNGestureHandlerStateEnd
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
|
|
}
|
|
|
|
- (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
// Pointer is moved outside of the view bounds, we cancel button when `shouldCancelWhenOutside` is set
|
|
if (self.shouldCancelWhenOutside) {
|
|
UIControl *control = (UIControl *)sender;
|
|
[control cancelTrackingWithEvent:event];
|
|
[self sendEventsInState:RNGestureHandlerStateEnd
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
|
|
} else {
|
|
[self sendEventsInState:RNGestureHandlerStateActive
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
|
|
}
|
|
}
|
|
|
|
- (void)handleDragEnter:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
[self sendEventsInState:RNGestureHandlerStateActive
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
|
|
}
|
|
|
|
- (void)handleTouchCancel:(UIView *)sender forEvent:(UIEvent *)event
|
|
{
|
|
[self sendEventsInState:RNGestureHandlerStateCancelled
|
|
forViewWithTag:sender.reactTag
|
|
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
|
|
}
|
|
|
|
@end
|
|
|
|
#else
|
|
|
|
#pragma mark RNDummyGestureRecognizer
|
|
|
|
@implementation RNDummyGestureRecognizer
|
|
|
|
- (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler
|
|
{
|
|
self = [super initWithTarget:gestureHandler action:@selector(handleGesture:)];
|
|
return self;
|
|
}
|
|
|
|
@end
|
|
|
|
#pragma mark RNNativeViewGestureHandler
|
|
|
|
@implementation RNNativeViewGestureHandler
|
|
|
|
- (instancetype)initWithTag:(NSNumber *)tag
|
|
{
|
|
RCTLogWarn(@"NativeViewGestureHandler is not supported on macOS");
|
|
if ((self = [super initWithTag:tag])) {
|
|
_recognizer = [NSGestureRecognizer alloc];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
@end
|
|
|
|
#endif
|