diff --git a/ownCloud/Client/ClientItemCell.swift b/ownCloud/Client/ClientItemCell.swift index d0bc5152e..44cd8ee5a 100644 --- a/ownCloud/Client/ClientItemCell.swift +++ b/ownCloud/Client/ClientItemCell.swift @@ -122,12 +122,14 @@ class ClientItemCell: ThemeTableViewCell { iconImage = item.icon(fitInSize: iconSize) - if item.type == .collection { - self.detailLabel.text = "Folder".localized - } else { - self.detailLabel.text = item.mimeType + var size: String = item.sizeInReadableFormat + + if item.size < 0 { + size = "Pending".localized } + self.detailLabel.text = size + " - " + item.lastModifiedInReadableFormat + self.accessoryType = .none if item.thumbnailAvailability != .none { diff --git a/ownCloud/Resources/en.lproj/Localizable.strings b/ownCloud/Resources/en.lproj/Localizable.strings index e46e6f83b..7c5eeed99 100644 --- a/ownCloud/Resources/en.lproj/Localizable.strings +++ b/ownCloud/Resources/en.lproj/Localizable.strings @@ -69,6 +69,7 @@ "size" = "size"; "date" = "date"; "Search this folder" = "Search this folder"; +"Pending" = "Pending"; /* Client Messages */ "Empty folder" = "Empty folder"; diff --git a/ownCloud/SDK Extensions/OCItem+Extension.swift b/ownCloud/SDK Extensions/OCItem+Extension.swift index fa7a55d5a..789ab3215 100644 --- a/ownCloud/SDK Extensions/OCItem+Extension.swift +++ b/ownCloud/SDK Extensions/OCItem+Extension.swift @@ -216,4 +216,29 @@ extension OCItem { func fileSuffix() -> String { return (self.name as NSString).pathExtension } + + var sizeInReadableFormat: String { + let size = OCItem.byteCounterFormatter.string(fromByteCount: Int64(self.size)) + return size + } + + var lastModifiedInReadableFormat: String { + let dateString = OCItem.dateFormatter.string(from: self.lastModified) + return dateString + } + + static private let byteCounterFormatter: ByteCountFormatter = { + let byteCounterFormatter = ByteCountFormatter() + byteCounterFormatter.allowsNonnumericFormatting = false + return byteCounterFormatter + }() + + static private let dateFormatter: DateFormatter = { + let dateFormatter: DateFormatter = DateFormatter() + dateFormatter.timeStyle = .none + dateFormatter.dateStyle = .medium + dateFormatter.locale = Locale.current + dateFormatter.doesRelativeDateFormatting = true + return dateFormatter + }() }