- 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
81 lines
3.0 KiB
Objective-C
81 lines
3.0 KiB
Objective-C
|
|
#import <ExpoFileSystem/EXFileSystemLocalFileHandler.h>
|
|
#import <ExpoFileSystem/NSData+EXFileSystem.h>
|
|
|
|
@implementation EXFileSystemLocalFileHandler
|
|
|
|
+ (void)getInfoForFile:(NSURL *)fileUri
|
|
withOptions:(NSDictionary *)options
|
|
resolver:(EXPromiseResolveBlock)resolve
|
|
rejecter:(EXPromiseRejectBlock)reject
|
|
{
|
|
NSString *path = fileUri.path;
|
|
BOOL isDirectory;
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]) {
|
|
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
|
|
NSMutableDictionary *result = [NSMutableDictionary dictionary];
|
|
result[@"exists"] = @(YES);
|
|
result[@"isDirectory"] = @(isDirectory);
|
|
result[@"uri"] = [NSURL fileURLWithPath:path].absoluteString;
|
|
if (options[@"md5"]) {
|
|
result[@"md5"] = [[NSData dataWithContentsOfFile:path] md5String];
|
|
}
|
|
result[@"size"] = @([EXFileSystemLocalFileHandler getFileSize:path attributes:attributes]);
|
|
// Uses required reason API based on the following reason: 0A2A.1
|
|
result[@"modificationTime"] = @(attributes.fileModificationDate.timeIntervalSince1970);
|
|
resolve(result);
|
|
} else {
|
|
resolve(@{@"exists": @(NO), @"isDirectory": @(NO)});
|
|
}
|
|
}
|
|
|
|
+ (unsigned long long)getFileSize:(NSString *)path attributes:(NSDictionary<NSFileAttributeKey, id> *)attributes
|
|
{
|
|
if (attributes.fileType != NSFileTypeDirectory) {
|
|
return attributes.fileSize;
|
|
}
|
|
|
|
// The path is pointing to the folder
|
|
NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
|
NSEnumerator *contentsEnumurator = [contents objectEnumerator];
|
|
NSString *file;
|
|
unsigned long long folderSize = 0;
|
|
while (file = [contentsEnumurator nextObject]) {
|
|
NSString *filePath = [path stringByAppendingPathComponent:file];
|
|
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
|
|
folderSize += [EXFileSystemLocalFileHandler getFileSize:filePath attributes:fileAttributes];
|
|
}
|
|
|
|
return folderSize;
|
|
}
|
|
|
|
+ (void)copyFrom:(NSURL *)from
|
|
to:(NSURL *)to
|
|
resolver:(EXPromiseResolveBlock)resolve
|
|
rejecter:(EXPromiseRejectBlock)reject
|
|
{
|
|
NSString *fromPath = [from.path stringByStandardizingPath];
|
|
NSString *toPath = [to.path stringByStandardizingPath];
|
|
|
|
NSError *error;
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:toPath]) {
|
|
if (![[NSFileManager defaultManager] removeItemAtPath:toPath error:&error]) {
|
|
reject(@"E_FILE_NOT_COPIED",
|
|
[NSString stringWithFormat:@"File '%@' could not be copied to '%@' because a file already exists at "
|
|
"the destination and could not be deleted.", from, to],
|
|
error);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if ([[NSFileManager defaultManager] copyItemAtPath:fromPath toPath:toPath error:&error]) {
|
|
resolve(nil);
|
|
} else {
|
|
reject(@"E_FILE_NOT_COPIED",
|
|
[NSString stringWithFormat:@"File '%@' could not be copied to '%@'.", from, to],
|
|
error);
|
|
}
|
|
}
|
|
|
|
@end
|