瀏覽代碼

new share view

marinofaggiana 5 年之前
父節點
當前提交
c8d5871400
共有 3 個文件被更改,包括 23 次插入50 次删除
  1. 9 39
      iOSClient/Main/CCMain.m
  2. 11 11
      iOSClient/Main/NCMainCommon.swift
  3. 3 0
      iOSClient/Share/NCShareNetworking.swift

+ 9 - 39
iOSClient/Main/CCMain.m

@@ -3718,12 +3718,13 @@
 {
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     tableShare *shareCell;
-
+    BOOL isShare = false;
+    BOOL isMounted = false;
+    
     if (metadata == nil || [[NCManageDatabase sharedInstance] isTableInvalidated:metadata] || (_metadataFolder != nil && [[NCManageDatabase sharedInstance] isTableInvalidated:_metadataFolder])) {
         return [CCCellMain new];
     }
     
-    // have you share ?
     for (tableShare *share in appDelegate.shares) {
         if ([share.serverUrl isEqualToString:metadata.serverUrl] && [share.fileName isEqualToString:metadata.fileName]) {
             shareCell = share;
@@ -3736,51 +3737,20 @@
     // NORMAL - > MAIN
     
     if ([cell isKindOfClass:[CCCellMain class]]) {
-        
-        BOOL isShare = false;
-        BOOL isMounted = false;
-        
+                
         if (_metadataFolder) {
             isShare = [metadata.permissions containsString:k_permission_shared] && ![_metadataFolder.permissions containsString:k_permission_shared];
             isMounted = [metadata.permissions containsString:k_permission_mounted] && ![_metadataFolder.permissions containsString:k_permission_mounted];
         }
         
-        /*
-        // have you share ?
-        for (tableShare *share in appDelegate.shares) {
-            if ([share.fileName isEqualToString:metadata.fileName]) {
-                haveYouShare = true;
-                break;
-            }
-        }
-
         // Share add Tap
-        if (isShare || isMounted || haveYouShare) {
+        if (isShare || isMounted || shareCell) {
             
-            if (isShare || isMounted) {
-                
-                // Shared with you
-                
-                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionConnectionMounted:)];
-                [tap setNumberOfTapsRequired:1];
-                ((CCCellMain *)cell).shared.userInteractionEnabled = YES;
-                [((CCCellMain *)cell).shared addGestureRecognizer:tap];
-                
-            } else if (haveYouShare) {
-                
-                // You share
-                
-                if (metadata.directory) {
-                    ((CCCellMain *)cell).shared.userInteractionEnabled = NO;
-                } else {
-                    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
-                    [tap setNumberOfTapsRequired:1];
-                    ((CCCellMain *)cell).shared.userInteractionEnabled = YES;
-                    [((CCCellMain *)cell).shared addGestureRecognizer:tap];
-                }
-            }
+            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
+            [tap setNumberOfTapsRequired:1];
+            ((CCCellMain *)cell).shared.userInteractionEnabled = YES;
+            [((CCCellMain *)cell).shared addGestureRecognizer:tap];
         }
-        */
         
         // More
         if ([self canOpenMenuAction:metadata]) {

+ 11 - 11
iOSClient/Main/NCMainCommon.swift

@@ -612,17 +612,6 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                 if tableE2eEncryption != nil &&  NCUtility.sharedInstance.isEncryptedMetadata(metadata) {
                     cell.status.image = UIImage.init(named: "encrypted")
                 }
-                
-                // Share
-                if (isShare) {
-                    cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
-                } else if (isMounted) {
-                    cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMounted"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
-                } else if (tableShare != nil && tableShare!.shareType == Int(shareTypeLink.rawValue)) {
-                    cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
-                } else if (tableShare != nil && tableShare!.shareType != Int(shareTypeLink.rawValue)) {
-                    cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
-                }
             }
             
             //
@@ -634,6 +623,17 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                 cell.favorite.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), multiplier: 2, color: NCBrandColor.sharedInstance.yellowFavorite)
             }
             
+            // Share
+            if (isShare) {
+                cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+            } else if (isMounted) {
+                cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMounted"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+            } else if (tableShare != nil && tableShare!.shareType == Int(shareTypeLink.rawValue)) {
+                cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+            } else if (tableShare != nil && tableShare!.shareType != Int(shareTypeLink.rawValue)) {
+                cell.shared.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+            }
+            
             // More Image
             cell.more.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), multiplier: 1, color: NCBrandColor.sharedInstance.optionItem)
             

+ 3 - 0
iOSClient/Share/NCShareNetworking.swift

@@ -47,6 +47,7 @@ class NCShareNetworking: NSObject {
             if errorCode == 0 {
                 let itemsOCSharedDto = items as! [OCSharedDto]
                 self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
+                self.appDelegate.activeMain.tableView.reloadData()
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
             }
@@ -64,6 +65,7 @@ class NCShareNetworking: NSObject {
                     if errorCode == 0 {
                         let itemsOCSharedDto = items as! [OCSharedDto]
                         self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
+                        self.appDelegate.activeMain.tableView.reloadData()
                     } else {
                         self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     }
@@ -128,6 +130,7 @@ class NCShareNetworking: NSObject {
                     if errorCode == 0 {
                         let itemsOCSharedDto = items as! [OCSharedDto]
                         self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
+                        self.appDelegate.activeMain.tableView.reloadData()
                     } else {
                         self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     }