- 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
124 lines
3.1 KiB
Plaintext
124 lines
3.1 KiB
Plaintext
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <React/RCTSettingsManager.h>
|
|
|
|
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTConvert.h>
|
|
#import <React/RCTEventDispatcherProtocol.h>
|
|
#import <React/RCTUtils.h>
|
|
|
|
#import "RCTSettingsPlugins.h"
|
|
|
|
@interface RCTSettingsManager () <NativeSettingsManagerSpec>
|
|
@end
|
|
|
|
@implementation RCTSettingsManager {
|
|
BOOL _ignoringUpdates;
|
|
NSUserDefaults *_defaults;
|
|
}
|
|
|
|
@synthesize moduleRegistry = _moduleRegistry;
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (instancetype)init
|
|
{
|
|
return [self initWithUserDefaults:[NSUserDefaults standardUserDefaults]];
|
|
}
|
|
|
|
- (instancetype)initWithUserDefaults:(NSUserDefaults *)defaults
|
|
{
|
|
if ((self = [super init])) {
|
|
_defaults = defaults;
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
selector:@selector(userDefaultsDidChange:)
|
|
name:NSUserDefaultsDidChangeNotification
|
|
object:_defaults];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (facebook::react::ModuleConstants<JS::NativeSettingsManager::Constants>)constantsToExport
|
|
{
|
|
return (facebook::react::ModuleConstants<JS::NativeSettingsManager::Constants>)[self getConstants];
|
|
}
|
|
|
|
- (facebook::react::ModuleConstants<JS::NativeSettingsManager::Constants>)getConstants
|
|
{
|
|
return facebook::react::typedConstants<JS::NativeSettingsManager::Constants>(
|
|
{.settings = RCTJSONClean([_defaults dictionaryRepresentation])});
|
|
}
|
|
|
|
- (void)userDefaultsDidChange:(NSNotification *)note
|
|
{
|
|
if (_ignoringUpdates) {
|
|
return;
|
|
}
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
[[_moduleRegistry moduleForName:"EventDispatcher"]
|
|
sendDeviceEventWithName:@"settingsUpdated"
|
|
body:RCTJSONClean([_defaults dictionaryRepresentation])];
|
|
#pragma clang diagnostic pop
|
|
}
|
|
|
|
/**
|
|
* Set one or more values in the settings.
|
|
* TODO: would it be useful to have a callback for when this has completed?
|
|
*/
|
|
RCT_EXPORT_METHOD(setValues : (NSDictionary *)values)
|
|
{
|
|
_ignoringUpdates = YES;
|
|
[values enumerateKeysAndObjectsUsingBlock:^(NSString *key, id json, BOOL *stop) {
|
|
id plist = [RCTConvert NSPropertyList:json];
|
|
if (plist) {
|
|
[self->_defaults setObject:plist forKey:key];
|
|
} else {
|
|
[self->_defaults removeObjectForKey:key];
|
|
}
|
|
}];
|
|
|
|
[_defaults synchronize];
|
|
_ignoringUpdates = NO;
|
|
}
|
|
|
|
/**
|
|
* Remove some values from the settings.
|
|
*/
|
|
RCT_EXPORT_METHOD(deleteValues : (NSArray<NSString *> *)keys)
|
|
{
|
|
_ignoringUpdates = YES;
|
|
for (NSString *key in keys) {
|
|
[_defaults removeObjectForKey:key];
|
|
}
|
|
|
|
[_defaults synchronize];
|
|
_ignoringUpdates = NO;
|
|
}
|
|
|
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
{
|
|
return std::make_shared<facebook::react::NativeSettingsManagerSpecJSI>(params);
|
|
}
|
|
|
|
@end
|
|
|
|
Class RCTSettingsManagerCls(void)
|
|
{
|
|
return RCTSettingsManager.class;
|
|
}
|