浏览代码

Managed external link menu

Marino Faggiana 8 年之前
父节点
当前提交
52a093df49
共有 2 个文件被更改,包括 39 次插入87 次删除
  1. 1 81
      iOSClient/Main/CCMain.m
  2. 38 6
      iOSClient/Main/CCMore.swift

+ 1 - 81
iOSClient/Main/CCMain.m

@@ -3209,72 +3209,6 @@
     if (app.reSelectMenu.isOpen || app.reMainMenu.isOpen)
         return;
     
-    NSMutableArray *menuArray = [NSMutableArray new];
-    
-    NSArray *externalSites = [CCCoreData getAllTableExternalSitesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
-    
-    // External Sites Present
-    
-    if([externalSites count] > 0) {
-        
-        CCMenuItem *item;
-        
-        for (TableExternalSites *tableExternalSites in externalSites) {
-            
-            // NSString *currentLanguageiOS = [[NSLocale preferredLanguages] objectAtIndex:0];
-            
-            // Verify lang
-            //if ([tableExternalSites.lang isEqualToString:@""] || [tableExternalSites.lang isEqualToString:currentLanguageiOS]) {
-            
-                item = [CCMenuItem new];
-                
-                item.title = tableExternalSites.name;
-                item.image = [UIImage imageNamed:image_MenuExternalSites];
-                item.target = self;
-                item.action = @selector(goToWebVC:);
-                item.argument = tableExternalSites.url;
-                [menuArray addObject:item];
-            //}
-        }
-        
-        if ([menuArray count] > 0) {
-            
-            OptionalConfiguration options;
-            Color textColor, backgroundColor;
-            
-            textColor.R = 0;
-            textColor.G = 0;
-            textColor.B = 0;
-            
-            backgroundColor.R = 1;
-            backgroundColor.G = 1;
-            backgroundColor.B = 1;
-            
-            NSInteger originY = 60;
-            
-            options.arrowSize = 9;
-            options.marginXSpacing = 7;
-            options.marginYSpacing = 10;
-            options.intervalSpacing = 20;
-            options.menuCornerRadius = 6.5;
-            options.maskToBackground = NO;
-            options.shadowOfMenu = YES;
-            options.hasSeperatorLine = YES;
-            options.seperatorLineHasInsets = YES;
-            options.textColor = textColor;
-            options.menuBackgroundColor = backgroundColor;
-            
-            CGRect rect = self.view.frame;
-            rect.origin.y = rect.origin.y + originY;
-            rect.size.height = rect.size.height - originY;
-            
-            [CCMenuAccount setTitleFont:[UIFont systemFontOfSize:12.0]];
-            [CCMenuAccount showMenuInView:self.navigationController.view fromRect:rect menuItems:menuArray withOptions:options];
-        }
-        
-        return;
-    }
-
 #ifndef OPTION_MULTIUSER_DISABLE
     
     if ([app.netQueue operationCount] > 0 || [app.netQueueDownload operationCount] > 0 || [app.netQueueDownloadWWan operationCount] > 0 || [app.netQueueUpload operationCount] > 0 || [app.netQueueUploadWWan operationCount] > 0 || [CCCoreData countTableAutomaticUploadForAccount:app.activeAccount selector:nil] > 0) {
@@ -3284,7 +3218,7 @@
     }
     
     NSArray *listTableAccount = [CCCoreData getAllTableAccount];
-   
+    NSMutableArray *menuArray = [NSMutableArray new];
     
     for (TableAccount *record in listTableAccount) {
      
@@ -3360,20 +3294,6 @@
     });
 }
 
-- (void)goToWebVC:(CCMenuItem *)sender
-{
-    if (self.splitViewController.isCollapsed) {
-        
-        SwiftWebVC *webVC = [[SwiftWebVC alloc] initWithUrlString:sender.argument];
-        [self.navigationController pushViewController:webVC animated:YES];
-        
-    } else {
-        
-        SwiftModalWebVC *webVC = [[SwiftModalWebVC alloc] initWithUrlString:sender.argument];
-        [self presentViewController:webVC animated:YES completion:nil];
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== ReMenu ====
 #pragma --------------------------------------------------------------------------------------------

+ 38 - 6
iOSClient/Main/CCMore.swift

@@ -106,7 +106,20 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         
-        return self.itemsMenuLabelText[section].count
+        // Menu Function
+        if (section == 0) {
+            return self.itemsMenuLabelText[0].count
+        }
+        // Menu External Site
+        if (section == 1 && self.menuExternalSite != nil) {
+            return (self.menuExternalSite?.count)!
+        }
+        // Menu Settings
+        if ((section == 1 && self.menuExternalSite == nil) || (section == 2 && self.menuExternalSite != nil)) {
+            return self.itemsMenuLabelText[1].count
+        }
+        
+        return 0
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -118,24 +131,29 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         selectionColor.backgroundColor = Constant.GlobalConstants.k_Color_SelectBackgrond
         cell.selectedBackgroundView = selectionColor
         
-        // data
-        cell.imageIcon?.image = UIImage.init(named: self.itemsMenuImage[indexPath.section][indexPath.row])
-        cell.labelText?.text = NSLocalizedString(self.itemsMenuLabelText[indexPath.section][indexPath.row], comment: "")
-        
         // Menu Function
         if (indexPath.section == 0) {
+            
+            cell.imageIcon?.image = UIImage.init(named: self.itemsMenuImage[0][indexPath.row])
+            cell.labelText?.text = NSLocalizedString(self.itemsMenuLabelText[0][indexPath.row], comment: "")
             cell.labelText.textColor = Constant.GlobalConstants.k_Color_Nextcloud
         }
         // Menu External Site
         if (indexPath.section == 1 && self.menuExternalSite != nil) {
             
+            cell.imageIcon?.image = UIImage.init(named: "moreExternalSite")
+            let externalSite : TableExternalSites = self.menuExternalSite![indexPath.row]
+            cell.labelText?.text = externalSite.name
+            cell.labelText.textColor = .black
         }
         // Menu Settings
         if ((indexPath.section == 1 && self.menuExternalSite == nil) || (indexPath.section == 2 && self.menuExternalSite != nil)) {
+            
+            cell.imageIcon?.image = UIImage.init(named: self.itemsMenuImage[1][indexPath.row])
+            cell.labelText?.text = NSLocalizedString(self.itemsMenuLabelText[1][indexPath.row], comment: "")
             cell.labelText.textColor = Constant.GlobalConstants.k_Color_GrayMenuMore
         }
         
-        
         return cell
     }
 
@@ -159,6 +177,20 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         // Menu External Site
         if (indexPath.section == 1 && self.menuExternalSite != nil) {
             
+            let externalSite : TableExternalSites = self.menuExternalSite![indexPath.row]
+            let url : String = externalSite.url!
+            
+            if (self.splitViewController?.isCollapsed)! {
+                
+                let webVC = SwiftWebVC(urlString: url)
+                self.navigationController?.pushViewController(webVC, animated: true)
+                self.navigationController?.navigationBar.isHidden = false
+                
+            } else {
+                
+                let webVC = SwiftModalWebVC(urlString: url)
+                self.present(webVC, animated: true, completion: nil)
+            }
         }
         
         // Menu Settings