Skip to content

Commit

Permalink
item data (size, last modified) in the file's list cell detail label (#…
Browse files Browse the repository at this point in the history
…117)

* - New computed variables for readable size and readable date in OCItem+Extension.
- Now in the ClientItemCell's detail label appears the size and the last modified date for every item.

* Make static formatters for performance reasons

* - Changed the ByteCountFormatter to not use non-numeric formatting.
- Removed countStyle because .file is the default option.

* - Coded support for external storage folders without initial known size.

* - Localize Pending for not known external storage folder size.
  • Loading branch information
pablocarmu authored and jesmrec committed Sep 27, 2018
1 parent 5d9ae6f commit 33e317e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ownCloud/Client/ClientItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"size" = "size";
"date" = "date";
"Search this folder" = "Search this folder";
"Pending" = "Pending";

/* Client Messages */
"Empty folder" = "Empty folder";
Expand Down
25 changes: 25 additions & 0 deletions ownCloud/SDK Extensions/OCItem+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
}

0 comments on commit 33e317e

Please sign in to comment.