From 86d058695521fda4a3ddee0e638de60773b2f0d9 Mon Sep 17 00:00:00 2001 From: Milen Pivchev Date: Thu, 19 Sep 2024 17:04:25 +0200 Subject: [PATCH 1/2] Handle SVGs/Fix cell height Signed-off-by: Milen Pivchev --- iOSClient/Activity/NCActivity.swift | 15 ++++---- iOSClient/Networking/NCService.swift | 1 - .../Advanced/NCShareNewUserAddComment.swift | 1 - iOSClient/Share/NCShareCommentsCell.xib | 35 ++++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 2e446ac16b..597216d9c7 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -25,6 +25,7 @@ import UIKit import SwiftRichString import NextcloudKit +import SVGKit class NCActivity: UIViewController, NCSharePagingContent { @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint! @@ -150,10 +151,6 @@ extension NCActivity: UITableViewDelegate { return 50 } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - return 80 - } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50)) view.backgroundColor = .clear @@ -223,7 +220,6 @@ extension NCActivity: UITableViewDataSource { cell.indexPath = indexPath cell.tableComments = comment cell.delegate = self - cell.sizeToFit() // Image let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: comment.actorId) @@ -233,7 +229,7 @@ extension NCActivity: UITableViewDataSource { cell.labelUser.textColor = NCBrandColor.shared.textColor // Date cell.labelDate.text = utility.dateDiff(comment.creationDateTime as Date) - cell.labelDate.textColor = .systemGray4 + cell.labelDate.textColor = .lightGray // Message cell.labelMessage.text = comment.message cell.labelMessage.textColor = NCBrandColor.shared.textColor @@ -244,6 +240,8 @@ extension NCActivity: UITableViewDataSource { cell.buttonMenu.isHidden = true } + cell.sizeToFit() + return cell } @@ -264,11 +262,14 @@ extension NCActivity: UITableViewDataSource { // icon if !activity.icon.isEmpty { + activity.icon = activity.icon.replacingOccurrences(of: ".png", with: ".svg") let fileNameIcon = (activity.icon as NSString).lastPathComponent let fileNameLocalPath = utilityFileSystem.directoryUserData + "/" + fileNameIcon + let image = fileNameIcon.contains(".svg") ? SVGKImage(contentsOfFile: fileNameLocalPath).uiImage : UIImage(contentsOfFile: fileNameLocalPath) + if FileManager.default.fileExists(atPath: fileNameLocalPath) { - if let image = UIImage(contentsOfFile: fileNameLocalPath) { + if let image { cell.icon.image = image.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) } } else { diff --git a/iOSClient/Networking/NCService.swift b/iOSClient/Networking/NCService.swift index 057c04179c..a1b9633d3d 100644 --- a/iOSClient/Networking/NCService.swift +++ b/iOSClient/Networking/NCService.swift @@ -22,7 +22,6 @@ // import UIKit -import SVGKit import NextcloudKit import RealmSwift diff --git a/iOSClient/Share/Advanced/NCShareNewUserAddComment.swift b/iOSClient/Share/Advanced/NCShareNewUserAddComment.swift index a4bd06855f..7d76452141 100644 --- a/iOSClient/Share/Advanced/NCShareNewUserAddComment.swift +++ b/iOSClient/Share/Advanced/NCShareNewUserAddComment.swift @@ -21,7 +21,6 @@ import UIKit import NextcloudKit -import SVGKit class NCShareNewUserAddComment: UIViewController, NCShareDetail { diff --git a/iOSClient/Share/NCShareCommentsCell.xib b/iOSClient/Share/NCShareCommentsCell.xib index cceef5a118..243aa83341 100755 --- a/iOSClient/Share/NCShareCommentsCell.xib +++ b/iOSClient/Share/NCShareCommentsCell.xib @@ -1,9 +1,9 @@ - + - + @@ -11,11 +11,11 @@ - - + + - + @@ -26,11 +26,11 @@ @@ -53,8 +53,8 @@ - @@ -93,7 +94,7 @@ - + @@ -102,10 +103,10 @@ - + - + From 6836fc39f2f1624293cbf07e9871851b389c9fce Mon Sep 17 00:00:00 2001 From: Milen Pivchev Date: Thu, 19 Sep 2024 17:07:19 +0200 Subject: [PATCH 2/2] WIP Signed-off-by: Milen Pivchev --- iOSClient/Activity/NCActivity.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 597216d9c7..ad1f021f44 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -266,9 +266,9 @@ extension NCActivity: UITableViewDataSource { let fileNameIcon = (activity.icon as NSString).lastPathComponent let fileNameLocalPath = utilityFileSystem.directoryUserData + "/" + fileNameIcon - let image = fileNameIcon.contains(".svg") ? SVGKImage(contentsOfFile: fileNameLocalPath).uiImage : UIImage(contentsOfFile: fileNameLocalPath) - if FileManager.default.fileExists(atPath: fileNameLocalPath) { + let image = fileNameIcon.contains(".svg") ? SVGKImage(contentsOfFile: fileNameLocalPath)?.uiImage : UIImage(contentsOfFile: fileNameLocalPath) + if let image { cell.icon.image = image.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) }