- 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
106 lines
2.7 KiB
Objective-C
106 lines
2.7 KiB
Objective-C
/*
|
|
* 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 "RCTI18nUtil.h"
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
@implementation RCTI18nUtil
|
|
|
|
+ (instancetype)sharedInstance
|
|
{
|
|
static RCTI18nUtil *sharedInstance;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
sharedInstance = [self new];
|
|
[sharedInstance swapLeftAndRightInRTL:true];
|
|
});
|
|
|
|
return sharedInstance;
|
|
}
|
|
|
|
/**
|
|
* Check if the app is currently running on an RTL locale.
|
|
* This only happens when the app:
|
|
* - is forcing RTL layout, regardless of the active language (for development purpose)
|
|
* - allows RTL layout when using RTL locale
|
|
*/
|
|
- (BOOL)isRTL
|
|
{
|
|
if ([self isRTLForced]) {
|
|
return YES;
|
|
}
|
|
if ([self isRTLAllowed] && [self isApplicationPreferredLanguageRTL]) {
|
|
return YES;
|
|
}
|
|
return NO;
|
|
}
|
|
|
|
/**
|
|
* Should be used very early during app start up
|
|
* Before the bridge is initialized
|
|
* @return whether the app allows RTL layout, default is true
|
|
*/
|
|
- (BOOL)isRTLAllowed
|
|
{
|
|
NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"RCTI18nUtil_allowRTL"];
|
|
if (value == nil) {
|
|
return YES;
|
|
}
|
|
return [value boolValue];
|
|
}
|
|
|
|
- (void)allowRTL:(BOOL)rtlStatus
|
|
{
|
|
[[NSUserDefaults standardUserDefaults] setBool:rtlStatus forKey:@"RCTI18nUtil_allowRTL"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
}
|
|
|
|
/**
|
|
* Could be used to test RTL layout with English
|
|
* Used for development and testing purpose
|
|
*/
|
|
- (BOOL)isRTLForced
|
|
{
|
|
BOOL rtlStatus = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"];
|
|
return rtlStatus;
|
|
}
|
|
|
|
- (void)forceRTL:(BOOL)rtlStatus
|
|
{
|
|
[[NSUserDefaults standardUserDefaults] setBool:rtlStatus forKey:@"RCTI18nUtil_forceRTL"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
}
|
|
|
|
- (BOOL)doLeftAndRightSwapInRTL
|
|
{
|
|
return [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"];
|
|
}
|
|
|
|
- (void)swapLeftAndRightInRTL:(BOOL)value
|
|
{
|
|
[[NSUserDefaults standardUserDefaults] setBool:value forKey:@"RCTI18nUtil_makeRTLFlipLeftAndRightStyles"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
}
|
|
|
|
// Check if the current device language is RTL
|
|
- (BOOL)isDevicePreferredLanguageRTL
|
|
{
|
|
NSLocaleLanguageDirection direction =
|
|
[NSLocale characterDirectionForLanguage:[[NSLocale preferredLanguages] objectAtIndex:0]];
|
|
return direction == NSLocaleLanguageDirectionRightToLeft;
|
|
}
|
|
|
|
// Check if the current application language is RTL
|
|
- (BOOL)isApplicationPreferredLanguageRTL
|
|
{
|
|
NSWritingDirection direction = [NSParagraphStyle defaultWritingDirectionForLanguage:nil];
|
|
return direction == NSWritingDirectionRightToLeft;
|
|
}
|
|
|
|
@end
|