Browse Source

Rework cell preview loading

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>
Philippe Weidmann 4 years ago
parent
commit
e6534305b0

+ 12 - 12
Nextcloud.xcodeproj/project.pbxproj

@@ -14,6 +14,9 @@
 		2C33C48623E2C475005F963B /* Notification Service Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 2C33C47F23E2C475005F963B /* Notification Service Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		2CB7D1CA23E2EDCB00376EF9 /* NCPushNotificationEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = F72D1005210B6882009C96B7 /* NCPushNotificationEncryption.m */; };
 		3704EB2A23D5A58400455C5B /* NCMenu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3704EB2923D5A58400455C5B /* NCMenu.storyboard */; };
+		370D26AD248A3BB800121797 /* CCCellMainTransfer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AC248A3BB800121797 /* CCCellMainTransfer.swift */; };
+		370D26AF248A3D7A00121797 /* NCImageCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AE248A3D7A00121797 /* NCImageCellProtocol.swift */; };
+		370D26B1248A3E1A00121797 /* CCCellMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26B0248A3E1A00121797 /* CCCellMain.swift */; };
 		371B5A2E23D0B04500FAFAE9 /* NCMainMenuTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371B5A2D23D0B04500FAFAE9 /* NCMainMenuTableViewController.swift */; };
 		371B5A3323D0BD5500FAFAE9 /* FloatingPanel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 371B5A3223D0BD5500FAFAE9 /* FloatingPanel.framework */; };
 		3757A35523D9D76300EC369E /* NCMenuPanelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3757A35423D9D76300EC369E /* NCMenuPanelController.swift */; };
@@ -239,10 +242,8 @@
 		F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42F1BAC0268006C0017 /* CCManageAutoUpload.m */; };
 		F77B0E5F1D118A16002130FE /* CCSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE4311BAC0268006C0017 /* CCSettings.m */; };
 		F77B0E8F1D118A16002130FE /* CCSection.m in Sources */ = {isa = PBXBuildFile; fileRef = F78F6FAF1CC8CCB700F4EA25 /* CCSection.m */; };
-		F77B0E921D118A16002130FE /* CCCellMainTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = F70211F81BAC56E9003FC03E /* CCCellMainTransfer.m */; };
 		F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42D1BAC0268006C0017 /* CCManageAccount.m */; };
 		F77B0EA61D118A16002130FE /* NSString+TruncateToWidth.m in Sources */ = {isa = PBXBuildFile; fileRef = F73049B91CB567F000C7C320 /* NSString+TruncateToWidth.m */; };
-		F77B0EC61D118A16002130FE /* CCCellMain.m in Sources */ = {isa = PBXBuildFile; fileRef = F70211F51BAC56E9003FC03E /* CCCellMain.m */; };
 		F77B0ED11D118A16002130FE /* Acknowledgements.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42A1BAC0268006C0017 /* Acknowledgements.m */; };
 		F77B0ED51D118A16002130FE /* PHAsset+Utility.m in Sources */ = {isa = PBXBuildFile; fileRef = F777F0311C29717F00CE81CB /* PHAsset+Utility.m */; };
 		F77B0ED91D118A16002130FE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F67BAD1A24D27800EE80DA /* main.m */; };
@@ -407,6 +408,9 @@
 		2C33C48123E2C475005F963B /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
 		2C33C48A23E2CC26005F963B /* Notification_Service_Extension-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Notification_Service_Extension-Bridging-Header.h"; sourceTree = "<group>"; };
 		3704EB2923D5A58400455C5B /* NCMenu.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCMenu.storyboard; sourceTree = "<group>"; };
+		370D26AC248A3BB800121797 /* CCCellMainTransfer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCCellMainTransfer.swift; sourceTree = "<group>"; };
+		370D26AE248A3D7A00121797 /* NCImageCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCImageCellProtocol.swift; sourceTree = "<group>"; };
+		370D26B0248A3E1A00121797 /* CCCellMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCCellMain.swift; sourceTree = "<group>"; };
 		371B5A2D23D0B04500FAFAE9 /* NCMainMenuTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainMenuTableViewController.swift; sourceTree = "<group>"; };
 		371B5A3223D0BD5500FAFAE9 /* FloatingPanel.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FloatingPanel.framework; path = Carthage/Build/iOS/FloatingPanel.framework; sourceTree = "<group>"; };
 		3757A35423D9D76300EC369E /* NCMenuPanelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMenuPanelController.swift; sourceTree = "<group>"; };
@@ -423,10 +427,7 @@
 		F700510222DF6897003A3356 /* Parchment.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Parchment.framework; path = Carthage/Build/iOS/Parchment.framework; sourceTree = "<group>"; };
 		F700510422DF6A89003A3356 /* NCShare.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShare.swift; sourceTree = "<group>"; };
 		F7020FCD2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCCreateFormUploadVoiceNote.swift; sourceTree = "<group>"; };
-		F70211F51BAC56E9003FC03E /* CCCellMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCCellMain.m; sourceTree = "<group>"; };
 		F70211F61BAC56E9003FC03E /* CCCellMain.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CCCellMain.xib; sourceTree = "<group>"; };
-		F70211F71BAC56E9003FC03E /* CCCellMainTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCellMainTransfer.h; sourceTree = "<group>"; };
-		F70211F81BAC56E9003FC03E /* CCCellMainTransfer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCCellMainTransfer.m; sourceTree = "<group>"; };
 		F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CCCellMainTransfer.xib; sourceTree = "<group>"; };
 		F70211FA1BAC56E9003FC03E /* CCMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMain.h; sourceTree = "<group>"; };
 		F70211FB1BAC56E9003FC03E /* CCMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCMain.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
@@ -836,7 +837,6 @@
 		F7FCFFD61D70798C000E6E29 /* CCPeekPop.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = CCPeekPop.storyboard; sourceTree = "<group>"; };
 		F7FCFFDD1D707B83000E6E29 /* CCPeekPop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPeekPop.h; sourceTree = "<group>"; };
 		F7FCFFDE1D707B83000E6E29 /* CCPeekPop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCPeekPop.m; sourceTree = "<group>"; };
-		F7FFEACE1F82BB23005E5C17 /* CCCellMain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCCellMain.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1229,13 +1229,12 @@
 		F78ACD3E21903BA20088454D /* Cell */ = {
 			isa = PBXGroup;
 			children = (
-				F7FFEACE1F82BB23005E5C17 /* CCCellMain.h */,
-				F70211F51BAC56E9003FC03E /* CCCellMain.m */,
+				370D26B0248A3E1A00121797 /* CCCellMain.swift */,
 				F70211F61BAC56E9003FC03E /* CCCellMain.xib */,
-				F70211F71BAC56E9003FC03E /* CCCellMainTransfer.h */,
-				F70211F81BAC56E9003FC03E /* CCCellMainTransfer.m */,
+				370D26AC248A3BB800121797 /* CCCellMainTransfer.swift */,
 				F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */,
 				F78ACD3F21903CC20088454D /* NCGridCell.swift */,
+				370D26AE248A3D7A00121797 /* NCImageCellProtocol.swift */,
 				F78ACD4521903D010088454D /* NCGridCell.xib */,
 				F77444F322281649000D5EB0 /* NCGridMediaCell.swift */,
 				F77444F422281649000D5EB0 /* NCGridMediaCell.xib */,
@@ -2234,6 +2233,7 @@
 				F7E09CE323E3088000FB3E9E /* NCMainRefreshControl.swift in Sources */,
 				F77B0DF41D118A16002130FE /* CCMain.m in Sources */,
 				F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */,
+				370D26AF248A3D7A00121797 /* NCImageCellProtocol.swift in Sources */,
 				F7E9C41B20F4CA870040CF18 /* CCTransfers.m in Sources */,
 				37C83A0F24532BA600618A3B /* CCMain+Swift.swift in Sources */,
 				F77B0DF51D118A16002130FE /* CCUtility.m in Sources */,
@@ -2243,6 +2243,7 @@
 				F710D1FE24057E5E00A6033D /* NCActionSheetHeader.swift in Sources */,
 				F77B0DFF1D118A16002130FE /* OCNetworking.m in Sources */,
 				F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */,
+				370D26AD248A3BB800121797 /* CCCellMainTransfer.swift in Sources */,
 				F78ACD4021903CC20088454D /* NCGridCell.swift in Sources */,
 				37ECC83B23D0C7410082EFA2 /* NCMenuAction.swift in Sources */,
 				F75B0ABD244C4DBB00E58DCA /* NCNetworkingNotificationCenter.swift in Sources */,
@@ -2339,7 +2340,6 @@
 				F769454422E9F142000A798A /* NCShareUserMenuView.swift in Sources */,
 				F77B0E8F1D118A16002130FE /* CCSection.m in Sources */,
 				F7CA1ED720E7E3FE002CC65E /* PKDownloadButton.m in Sources */,
-				F77B0E921D118A16002130FE /* CCCellMainTransfer.m in Sources */,
 				F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */,
 				F755BD9B20594AC7008C5FBB /* NCService.swift in Sources */,
 				F711CCD2246AC99E0009B204 /* OCHTTPRequestOperation.m in Sources */,
@@ -2372,12 +2372,12 @@
 				F7A321551E9E2A070069AD1B /* CCFavorites.m in Sources */,
 				F711CCCA246AC99E0009B204 /* NCXMLGetAppPasswordParser.m in Sources */,
 				F704FA5C232A343F00BBA952 /* IMImagemeterViewer.swift in Sources */,
+				370D26B1248A3E1A00121797 /* CCCellMain.swift in Sources */,
 				F711CCDA246AC99E0009B204 /* OCActivity.m in Sources */,
 				F7CA1ED220E7E3FE002CC65E /* PKCircleView.m in Sources */,
 				F745B253222D88AE00346520 /* NCLoginQRCode.swift in Sources */,
 				F7169A1C1EE590930086BD69 /* NCShares.m in Sources */,
 				F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */,
-				F77B0EC61D118A16002130FE /* CCCellMain.m in Sources */,
 				F7C9555521F0C5470024296E /* NCActivity.swift in Sources */,
 				F711CCD0246AC99E0009B204 /* OCXMLServerErrorsParser.m in Sources */,
 				F7CA1ED820E7E3FE002CC65E /* PKBorderedButton.m in Sources */,

+ 0 - 2
iOSClient/Favorites/CCFavorites.h

@@ -24,8 +24,6 @@
 #import <UIKit/UIKit.h>
 #import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
 
-#import "CCCellMain.h"
-#import "CCCellMainTransfer.h"
 #import "CCUtility.h"
 #import "CCMain.h"
 #import "CCGraphics.h"

+ 0 - 2
iOSClient/Main/CCMain.h

@@ -29,8 +29,6 @@
 
 #import "NSString+TruncateToWidth.h"
 #import "CCLogin.h"
-#import "CCCellMain.h"
-#import "CCCellMainTransfer.h"
 #import "CCGraphics.h"
 #import "CCSection.h"
 #import "CCUtility.h"

+ 0 - 43
iOSClient/Main/Cell/CCCellMain.h

@@ -1,43 +0,0 @@
-//
-//  CCCellMain.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 05/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <UIKit/UIKit.h>
-#import <MGSwipeTableCell/MGSwipeTableCell.h>
-
-@interface CCCellMain : MGSwipeTableCell
-
-@property(nonatomic, weak) IBOutlet UIImageView *file;
-@property(nonatomic, weak) IBOutlet UIImageView *status;
-@property(nonatomic, weak) IBOutlet UIImageView *favorite;
-@property(nonatomic, weak) IBOutlet UIImageView *local;
-@property(nonatomic, weak) IBOutlet UIImageView *comment;
-@property(nonatomic, weak) IBOutlet UIImageView *shared;
-@property(nonatomic, weak) IBOutlet UIView *viewShared;
-@property(nonatomic, weak) IBOutlet UIImageView *more;
-@property(nonatomic, weak) IBOutlet UILabel *labelTitle;
-@property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
-
-
-@property(nonatomic, weak) IBOutlet NSLayoutConstraint *labelTitleTrailingConstraint;
-
-@end

+ 0 - 47
iOSClient/Main/Cell/CCCellMain.m

@@ -1,47 +0,0 @@
-//
-//  CCCellMain.m
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 05/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import "CCCellMain.h"
-#import "NCBridgeSwift.h"
-
-@implementation CCCellMain
-
-- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
-{
-    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
-    if (self) {
-        // Initialization code
-        
-    }
-    return self;
-}
-
-- (void)setSelected:(BOOL)selected animated:(BOOL)animated
-{
-    [super setSelected:selected animated:animated];
-
-    // Configure the view for the selected state
-    self.contentView.preservesSuperviewLayoutMargins = NO;
-}
-
-@end

+ 74 - 0
iOSClient/Main/Cell/CCCellMain.swift

@@ -0,0 +1,74 @@
+//
+//  CCCellMain.swift
+//  Nextcloud
+//
+//  Created by Philippe Weidmann on 05.06.20.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
+//
+
+import UIKit
+import MGSwipeTableCell
+
+class CCCellMain: MGSwipeTableCell, NCImageCellProtocol {
+
+    @IBOutlet weak var file: UIImageView!
+    @IBOutlet weak var status: UIImageView!
+    @IBOutlet weak var favorite: UIImageView!
+    @IBOutlet weak var local: UIImageView!
+    @IBOutlet weak var comment: UIImageView!
+    @IBOutlet weak var shared: UIImageView!
+    @IBOutlet weak var viewShared: UIView!
+    @IBOutlet weak var more: UIImageView!
+    @IBOutlet weak var labelTitle: UILabel!
+    @IBOutlet weak var labelInfoFile: UILabel!
+
+    @IBOutlet weak var labelTitleTrailingConstraint: NSLayoutConstraint!
+
+    var filePreviewImageView : UIImageView {
+        get{
+         return file
+        }
+    }
+    
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        self.initCell()
+    }
+    
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        self.initCell()
+    }
+
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+
+        self.contentView.preservesSuperviewLayoutMargins = false
+    }
+    
+    func initCell() {
+        separatorInset = UIEdgeInsets.init(top: 0, left: 60, bottom: 0, right: 0)
+        accessoryType = UITableViewCell.AccessoryType.none
+        file.image = nil
+        file.layer.cornerRadius = 6
+        file.layer.masksToBounds = true
+        status.image = nil
+        favorite.image = nil
+        shared.image = nil
+        local.image = nil
+        comment.image = nil
+        shared.isUserInteractionEnabled = false
+        backgroundColor = NCBrandColor.sharedInstance.backgroundView
+        
+        // change color selection
+        let selectionColor = UIView()
+        selectionColor.backgroundColor = NCBrandColor.sharedInstance.select
+        selectedBackgroundView = selectionColor
+        tintColor = NCBrandColor.sharedInstance.brandElement
+        
+        labelTitle.textColor = NCBrandColor.sharedInstance.textView
+        
+        file.backgroundColor = nil
+    }
+
+}

+ 1 - 1
iOSClient/Main/Cell/CCCellMain.xib

@@ -9,7 +9,7 @@
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CustomCellFileAndDirectory"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="CellMain" id="2" customClass="CCCellMain">
+        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="CellMain" id="2" customClass="CCCellMain" customModule="Nextcloud" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">

+ 0 - 38
iOSClient/Main/Cell/CCCellMainTransfer.h

@@ -1,38 +0,0 @@
-//
-//  CCCellMainTransfer.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 05/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <UIKit/UIKit.h>
-#import "PKDownloadButton.h"
-
-@interface CCCellMainTransfer : UITableViewCell
-
-@property(nonatomic, weak) IBOutlet UIImageView *file;
-@property(nonatomic, weak) IBOutlet UIImageView *status;
-@property(nonatomic, weak) IBOutlet UIImageView *user;
-
-@property(nonatomic, weak) IBOutlet UILabel *labelTitle;
-@property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
-
-@property(nonatomic, weak) IBOutlet PKStopDownloadButton *transferButton;
-
-@end

+ 0 - 38
iOSClient/Main/Cell/CCCellMainTransfer.m

@@ -1,38 +0,0 @@
-//
-//  CCCellMainTransfer.m
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 05/05/15.
-//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import "CCCellMainTransfer.h"
-
-@implementation CCCellMainTransfer
-
-- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
-{
-    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
-    if (self) {
-        // Initialization code
-        
-    }
-    return self;
-}
-
-@end

+ 55 - 0
iOSClient/Main/Cell/CCCellMainTransfer.swift

@@ -0,0 +1,55 @@
+//
+//  CCCellMainTransfer.swift
+//  Nextcloud
+//
+//  Created by Philippe Weidmann on 05.06.20.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
+//
+
+import UIKit
+
+class CCCellMainTransfer: UITableViewCell, NCImageCellProtocol {
+
+    @IBOutlet weak var file: UIImageView!
+    @IBOutlet weak var status: UIImageView!
+    @IBOutlet weak var user: UIImageView!
+
+    @IBOutlet weak var labelTitle: UILabel!
+    @IBOutlet weak var labelInfoFile: UILabel!
+
+    @IBOutlet weak var transferButton: PKStopDownloadButton!
+
+    var filePreviewImageView: UIImageView {
+        get {
+            return file
+        }
+    }
+
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        self.initCell()
+    }
+
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        self.initCell()
+    }
+
+    func initCell() {
+        separatorInset = UIEdgeInsets.init(top: 0, left: 60, bottom: 0, right: 0)
+        accessoryType = UITableViewCell.AccessoryType.none
+        file.image = nil
+        file.layer.cornerRadius = 6
+        file.layer.masksToBounds = true
+        status.image = nil
+        user.image = nil
+        backgroundColor = NCBrandColor.sharedInstance.backgroundView
+
+        labelTitle.textColor = NCBrandColor.sharedInstance.textView
+        transferButton.tintColor = NCBrandColor.sharedInstance.optionItem
+        labelTitle.isEnabled = true
+        labelInfoFile.isEnabled = true
+        file.backgroundColor = nil
+    }
+
+}

+ 6 - 8
iOSClient/Main/Cell/CCCellMainTransfer.xib

@@ -1,21 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CustomCellFileAndDirectory"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="CellMainTransfer" id="2" customClass="CCCellMainTransfer">
+        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="CellMainTransfer" id="2" customClass="CCCellMainTransfer" customModule="Nextcloud" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">
-                <rect key="frame" x="0.0" y="0.0" width="600" height="59.5"/>
+                <rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QNC-8X-DAC" userLabel="labelTitle">
@@ -25,7 +23,7 @@
                         <nil key="highlightedColor"/>
                     </label>
                     <label opaque="NO" userInteractionEnabled="NO" tag="102" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p7I-KN-FVZ" userLabel="labelInfoFile">
-                        <rect key="frame" x="65" y="31" width="484" height="15"/>
+                        <rect key="frame" x="65" y="31.5" width="484" height="15"/>
                         <fontDescription key="fontDescription" type="system" pointSize="12"/>
                         <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.63921568627450975" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <nil key="highlightedColor"/>

+ 13 - 1
iOSClient/Main/Cell/NCGridCell.swift

@@ -24,7 +24,7 @@
 import Foundation
 import UIKit
 
-class NCGridCell: UICollectionViewCell {
+class NCGridCell: UICollectionViewCell, NCImageCellProtocol {
     
     @IBOutlet weak var imageItem: UIImageView!
     
@@ -36,6 +36,13 @@ class NCGridCell: UICollectionViewCell {
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var buttonMore: UIButton!
 
+    var filePreviewImageView : UIImageView {
+        get{
+         return imageItem
+        }
+    }
+
+    
     var delegate: NCGridCellDelegate?
     
     var objectId = ""
@@ -47,6 +54,11 @@ class NCGridCell: UICollectionViewCell {
         buttonMore.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), multiplier: 2, color: NCBrandColor.sharedInstance.optionItem), for: UIControl.State.normal)
     }
     
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        imageItem.backgroundColor = nil
+    }
+    
     @IBAction func touchUpInsideMore(_ sender: Any) {
         delegate?.tapMoreGridItem(with: objectId, sender: sender)
     }

+ 14 - 7
iOSClient/Main/Cell/NCGridMediaCell.swift

@@ -24,19 +24,26 @@
 import Foundation
 import UIKit
 
-class NCGridMediaCell: UICollectionViewCell {
-    
+class NCGridMediaCell: UICollectionViewCell, NCImageCellProtocol {
+
     @IBOutlet weak var imageItem: UIImageView!
-    
+
     @IBOutlet weak var imageVisualEffect: UIVisualEffectView!
-    
+
     @IBOutlet weak var imageSelect: UIImageView!
     @IBOutlet weak var imageStatus: UIImageView!
     @IBOutlet weak var imageFavorite: UIImageView!
     @IBOutlet weak var imageLocal: UIImageView!
-    
-    override func awakeFromNib() {
-        super.awakeFromNib()
+
+    var filePreviewImageView: UIImageView {
+        get {
+            return imageItem
+        }
+    }
+
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        imageItem.backgroundColor = UIColor.lightGray
     }
 }
 

+ 13 - 0
iOSClient/Main/Cell/NCImageCellProtocol.swift

@@ -0,0 +1,13 @@
+//
+//  NCImageCellProtocol.swift
+//  Nextcloud
+//
+//  Created by Philippe Weidmann on 05.06.20.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
+//
+
+import Foundation
+
+protocol NCImageCellProtocol {
+    var filePreviewImageView: UIImageView {get}
+}

+ 12 - 1
iOSClient/Main/Cell/NCListCell.swift

@@ -24,7 +24,7 @@
 import Foundation
 import UIKit
 
-class NCListCell: UICollectionViewCell {
+class NCListCell: UICollectionViewCell, NCImageCellProtocol {
     
     @IBOutlet weak var imageItem: UIImageView!
     @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint!
@@ -45,6 +45,12 @@ class NCListCell: UICollectionViewCell {
     @IBOutlet weak var buttonMore: UIButton!
     
     @IBOutlet weak var separator: UIView!
+    
+    var filePreviewImageView : UIImageView {
+        get{
+         return imageItem
+        }
+    }
 
     var delegate: NCListCellDelegate?
     
@@ -59,6 +65,11 @@ class NCListCell: UICollectionViewCell {
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
     }
     
+    override func prepareForReuse() {
+        super.prepareForReuse()
+        imageItem.backgroundColor = nil
+    }
+    
     @IBAction func touchUpInsideShare(_ sender: Any) {
         delegate?.tapShareListItem(with: objectId, sender: sender)
     }

+ 42 - 64
iOSClient/Main/NCMainCommon.swift

@@ -295,7 +295,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
                 
                 if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)) {
                     cell.imageItem.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-                } else {
+                } else if(!metadata.hasPreview) {
                     if metadata.iconName.count > 0 {
                         cell.imageItem.image = UIImage.init(named: metadata.iconName)
                     } else {
@@ -420,7 +420,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
                 
                 if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)) {
                     cell.imageItem.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-                } else {
+                } else if(!metadata.hasPreview) {
                     if metadata.iconName.count > 0 {
                         cell.imageItem.image = UIImage.init(named: metadata.iconName)
                     } else {
@@ -472,26 +472,6 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
             // NORMAL
             
             let cell = tableView.dequeueReusableCell(withIdentifier: "CellMain", for: indexPath) as! CCCellMain
-            cell.separatorInset = UIEdgeInsets.init(top: 0, left: 60, bottom: 0, right: 0)
-            cell.accessoryType = UITableViewCell.AccessoryType.none
-            cell.file.image = nil
-            cell.file.layer.cornerRadius = 6
-            cell.file.layer.masksToBounds = true
-            cell.status.image = nil
-            cell.favorite.image = nil
-            cell.shared.image = nil
-            cell.local.image = nil
-            cell.comment.image = nil
-            cell.shared.isUserInteractionEnabled = false
-            cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
-            
-            // change color selection
-            let selectionColor = UIView()
-            selectionColor.backgroundColor = NCBrandColor.sharedInstance.select
-            cell.selectedBackgroundView = selectionColor
-            cell.tintColor = NCBrandColor.sharedInstance.brandElement
-            
-            cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
             cell.labelTitle.text = metadata.fileNameView
             
             // Download preview
@@ -546,8 +526,10 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
                 
                 // File Image
                 if iconFileExists {
+                    cell.file.backgroundColor = nil
                     cell.file.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-                } else {
+                } else if(!metadata.hasPreview){
+                    cell.file.backgroundColor = nil
                     if metadata.iconName.count > 0 {
                         cell.file.image = UIImage.init(named: metadata.iconName)
                     } else {
@@ -645,24 +627,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
             // TRASNFER
             
             let cell = tableView.dequeueReusableCell(withIdentifier: "CellMainTransfer", for: indexPath) as! CCCellMainTransfer
-            cell.separatorInset = UIEdgeInsets.init(top: 0, left: 60, bottom: 0, right: 0)
-            cell.accessoryType = UITableViewCell.AccessoryType.none
-            cell.file.image = nil
-            cell.file.layer.cornerRadius = 6
-            cell.file.layer.masksToBounds = true
-            cell.status.image = nil
-            cell.user.image = nil
-            
-            cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
-
             cell.labelTitle.text = metadata.fileNameView
-            cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
-            
-            cell.transferButton.tintColor = NCBrandColor.sharedInstance.optionItem
-            
-            cell.labelTitle.isEnabled = true
-            cell.labelInfoFile.isEnabled = true
-            
             var progress: CGFloat = 0.0
             var totalBytes: Double = 0.0
             //var totalBytesExpected : Double = 0
@@ -706,7 +671,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
 
             if iconFileExists {
                 cell.file.image =  UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            } else {
+            } else if(!metadata.hasPreview){
                 if metadata.iconName.count > 0 {
                     cell.file.image = UIImage.init(named: metadata.iconName)
                 } else {
@@ -1041,37 +1006,50 @@ class NCNetworkingMain: NSObject, IMImagemeterViewerDelegate {
     func downloadThumbnail(with metadata: tableMetadata, view: Any, indexPath: IndexPath, closure: @escaping () -> ()) {
         
         if !metadata.isInvalidated && metadata.hasPreview && (!CCUtility.fileProviderStorageIconExists(metadata.ocId, fileNameView: metadata.fileName) || metadata.typeFile == k_metadataTypeFile_document) {
-                        
+            var cell: NCImageCellProtocol?
+            
+            if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                cell = (view as! UICollectionView).cellForItem(at: indexPath) as? NCImageCellProtocol
+            } else  if view is UITableView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                cell = (view as! UITableView).cellForRow(at: indexPath) as? NCImageCellProtocol
+            }
+            
+            if (cell != nil) {
+                cell!.filePreviewImageView.image = nil
+                cell!.filePreviewImageView.backgroundColor = UIColor.lightGray
+            }
+            
             let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
                     
             NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNameLocalPath: fileNameLocalPath, width: Int(k_sizePreview), height: Int(k_sizePreview)) { (account, data, errorCode, errorMessage) in
+                var cell: NCImageCellProtocol?
                 
-                if errorCode == 0 && data != nil  {
-                    if let image = UIImage.init(data: data!) {
-                        
-                        if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                            if let cell = (view as! UICollectionView).cellForItem(at: indexPath) {
-                                if cell is NCListCell {
-                                    (cell as! NCListCell).imageItem.image = image
-                                } else if cell is NCGridCell {
-                                    (cell as! NCGridCell).imageItem.image = image
-                                } else if cell is NCGridMediaCell {
-                                    (cell as! NCGridMediaCell).imageItem.image = image
-                                }
-                            }
+                if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                    cell = (view as! UICollectionView).cellForItem(at: indexPath) as? NCImageCellProtocol
+                } else  if view is UITableView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                    cell = (view as! UITableView).cellForRow(at: indexPath) as? NCImageCellProtocol
+                }
+                
+                if (cell != nil) {
+                    var previewImage: UIImage!
+                    if errorCode == 0 && data != nil {
+                        if let image = UIImage(data: data!) {
+                            previewImage = image
                         }
-                        
-                        if view is UITableView && CCUtility.fileProviderStorageIconExists(metadata.ocId, fileNameView: metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                            if let cell = (view as! UITableView).cellForRow(at: indexPath) {
-                                if cell is CCCellMainTransfer {
-                                    (cell as! CCCellMainTransfer).file.image = image
-                                } else if cell is CCCellMain {
-                                    (cell as! CCCellMain).file.image = image
-                                }
-                            }
+                    } else {
+                        if metadata.iconName.count > 0 {
+                            previewImage = UIImage(named: metadata.iconName)
+                        } else {
+                            previewImage = UIImage(named: "file")
                         }
                     }
+                    cell!.filePreviewImageView.backgroundColor = nil
+                    UIView.transition(with: cell!.filePreviewImageView,
+                    duration: 0.75,
+                    options: .transitionCrossDissolve,
+                    animations: { cell!.filePreviewImageView.image = previewImage!},
+                    completion: nil)
                 }
                 return closure()
             }

+ 6 - 18
iOSClient/Media/NCMedia.swift

@@ -144,7 +144,6 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         
         coordinator.animate(alongsideTransition: nil) { _ in
             self.reloadDataThenPerform {
-                self.downloadThumbnail()
             }
         }
     }
@@ -303,7 +302,6 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
                         self.isEditMode = false
                         self.selectocId.removeAll()
                         self.reloadDataThenPerform {
-                            self.downloadThumbnail()
                         }
                     }
                 )
@@ -474,7 +472,9 @@ extension NCMedia: UICollectionViewDataSource {
         }
         
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
-                            
+        
+        NCNetworkingMain.sharedInstance.downloadThumbnail(with: metadata, view: self.collectionView as Any, indexPath: indexPath)
+
         cell.imageStatus.image = nil
         cell.imageLocal.image = nil
         cell.imageFavorite.image = nil
@@ -484,8 +484,10 @@ extension NCMedia: UICollectionViewDataSource {
         cell.imageVisualEffect.clipsToBounds = true
                     
         if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)) {
+            cell.imageItem.backgroundColor = nil
             cell.imageItem.image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-        } else {
+        } else if(!metadata.hasPreview) {
+            cell.imageItem.backgroundColor = nil
             if metadata.iconName.count > 0 {
                 cell.imageItem.image = UIImage.init(named: metadata.iconName)
             } else {
@@ -569,7 +571,6 @@ extension NCMedia {
                 }
                 
                 self.reloadDataThenPerform {
-                    self.downloadThumbnail()
                 }
                 
                 completion()
@@ -673,7 +674,6 @@ extension NCMedia {
                     }
                     
                     self.reloadDataThenPerform {
-                        self.downloadThumbnail()
                     }
                 }
              
@@ -706,7 +706,6 @@ extension NCMedia {
         }
         
         reloadDataThenPerform {
-            self.downloadThumbnail()
         }
     }
     
@@ -742,17 +741,6 @@ extension NCMedia {
             }
         }
     }
-    
-    private func downloadThumbnail() {
-        guard let collectionView = self.collectionView else { return }
-        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-            for item in collectionView.indexPathsForVisibleItems {
-                if let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(item, sectionDataSource: self.sectionDatasource) {
-                    NCNetworkingMain.sharedInstance.downloadThumbnail(with: metadata, view: self.collectionView as Any, indexPath: item)
-                }
-            }
-        }
-    }
 }
 
 // MARK: - ScrollView

+ 1 - 1
iOSClient/Nextcloud-Bridging-Header.h

@@ -23,5 +23,5 @@
 #import "NCRichDocumentTemplate.h"
 #import "HCFeatures.h"
 #import "NCComments.h"
-
+#import "PKStopDownloadButton.h"
 #import "NCNetworkingEndToEnd.h"

+ 0 - 1
iOSClient/Synchronize/CCSynchronize.h

@@ -24,7 +24,6 @@
 #import <Foundation/Foundation.h>
 
 #import "CCHud.h"
-#import "CCCellMain.h"
 
 @class tableMetadata;
 

+ 0 - 1
iOSClient/Transfers/CCTransfers.m

@@ -25,7 +25,6 @@
 #import "AppDelegate.h"
 #import "CCMain.h"
 #import "CCSection.h"
-#import "CCCellMainTransfer.h"
 #import "NCBridgeSwift.h"
 
 #define download 1