marinofaggiana 4 năm trước cách đây
mục cha
commit
b2486a8661

+ 2 - 0
iOSClient/AppDelegate.h

@@ -85,6 +85,8 @@
 
 
 @property (nonatomic, retain) TOPasscodeViewController *passcodeViewController;
 @property (nonatomic, retain) TOPasscodeViewController *passcodeViewController;
 
 
+@property (nonatomic, retain) NSString *activeServerUrl;
+
 @property (nonatomic, strong) CCMain *activeMain;
 @property (nonatomic, strong) CCMain *activeMain;
 @property (nonatomic, strong) CCMain *homeMain;
 @property (nonatomic, strong) CCMain *homeMain;
 @property (nonatomic, strong) NCFavorite *activeFavorite;
 @property (nonatomic, strong) NCFavorite *activeFavorite;

+ 3 - 0
iOSClient/Main/CCMain.m

@@ -219,6 +219,7 @@
 - (void)viewWillAppear:(BOOL)animated
 - (void)viewWillAppear:(BOOL)animated
 {
 {
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
+    
     [self updateNavBarShadow:self.tableView force:false];
     [self updateNavBarShadow:self.tableView force:false];
     if(_isViewDidLoad && _isRoot) {
     if(_isViewDidLoad && _isRoot) {
         self.navigationItem.hidesSearchBarWhenScrolling = false;
         self.navigationItem.hidesSearchBarWhenScrolling = false;
@@ -253,6 +254,8 @@
     if (self.searchController.isActive == false) {
     if (self.searchController.isActive == false) {
         [self reloadDatasource:self.serverUrl ocId:nil];
         [self reloadDatasource:self.serverUrl ocId:nil];
     }
     }
+    
+    appDelegate.activeServerUrl = self.serverUrl;
 }
 }
 
 
 - (void)viewDidAppear:(BOOL)animated
 - (void)viewDidAppear:(BOOL)animated

+ 55 - 2
iOSClient/Main/Collection/NCCollectionCommon.swift

@@ -30,6 +30,8 @@ class NCCollectionCommon: NSObject {
         instance.createImagesThemingColor()
         instance.createImagesThemingColor()
         return instance
         return instance
     }()
     }()
+    
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
 
     struct NCCollectionCommonImages {
     struct NCCollectionCommonImages {
         static var cellSharedImage = UIImage()
         static var cellSharedImage = UIImage()
@@ -73,11 +75,62 @@ class NCCollectionCommon: NSObject {
         NCCollectionCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
         NCCollectionCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
     }
     }
     
     
+    // MARK: -
+
+    @objc func createFolder() {
+        
+        let serverUrl = appDelegate.activeServerUrl
+    }
+    
+    /*
+        - (void)createFolder
+        {
+            NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
+            NSString *message;
+            UIAlertController *alertController;
+            
+            if ([serverUrl isEqualToString:[[NCUtility shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account]]) {
+                message = @"/";
+            } else {
+                message = [serverUrl lastPathComponent];
+            }
+            
+            alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_on_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+            
+            [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+                [textField addTarget:self action:@selector(minCharTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
+                
+                textField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
+            }];
+            
+            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }];
+            
+            UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                
+                UITextField *fileName = alertController.textFields.firstObject;
+                
+                [[NCNetworking shared] createFolderWithFileName:[fileName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] serverUrl:serverUrl account:appDelegate.account urlBase:appDelegate.urlBase overwrite:false completion:^(NSInteger errorCode, NSString *errorDescription) {
+                    if (errorCode != 0){
+                        [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode forced:false];
+                    }
+                }];
+            }];
+            
+            okAction.enabled = NO;
+            
+            [alertController addAction:cancelAction];
+            [alertController addAction:okAction];
+            
+            [self presentViewController:alertController animated:YES completion:nil];
+        }
+
+        */
+    
+    
     // MARK: -
     // MARK: -
     
     
     func cellForItemAt(indexPath: IndexPath, collectionView: UICollectionView, cell: UICollectionViewCell, metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, isEditMode: Bool, selectocId: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, downloadThumbnail: Bool, shares: [tableShare]?, source: UIViewController, dataSource: NCDataSource?) {
     func cellForItemAt(indexPath: IndexPath, collectionView: UICollectionView, cell: UICollectionViewCell, metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, isEditMode: Bool, selectocId: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, downloadThumbnail: Bool, shares: [tableShare]?, source: UIViewController, dataSource: NCDataSource?) {
         
         
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
         var tableShare: tableShare?
         var tableShare: tableShare?
         
         
         // Share
         // Share
@@ -209,7 +262,7 @@ class NCCollectionCommon: NSObject {
                     cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                     cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                 } else {
                 } else {
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size)) { (account, data, errorCode, errorMessage) in
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size)) { (account, data, errorCode, errorMessage) in
-                        if errorCode == 0 && account == appDelegate.account {
+                        if errorCode == 0 && account == self.appDelegate.account {
                             cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                             cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                         }
                         }
                     }
                     }

+ 1 - 0
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -146,6 +146,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
 
 
+        appDelegate.activeServerUrl = self.serverUrl
         self.navigationItem.title = titleCurrentFolder
         self.navigationItem.title = titleCurrentFolder
                 
                 
         // get auto upload folder
         // get auto upload folder