Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item data (size, last modified) in the file's list cell detail label #117

Merged
merged 5 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions ownCloud/Client/ClientItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ class ClientItemCell: ThemeTableViewCell {

iconImage = item.icon(fitInSize: iconSize)

if item.type == .collection {
self.detailLabel.text = "Folder".localized
} else {
self.detailLabel.text = item.mimeType
}
self.detailLabel.text = item.sizeInReadableFormat + " - " + item.lastModifiedInReadableFormat

self.accessoryType = .none

Expand Down
17 changes: 17 additions & 0 deletions ownCloud/SDK Extensions/OCItem+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,21 @@ extension OCItem {
func fileSuffix() -> String {
return (self.name as NSString).pathExtension
}

var sizeInReadableFormat: String {
let byteCountFormatter = ByteCountFormatter()
byteCountFormatter.countStyle = .file
let size = byteCountFormatter.string(fromByteCount: Int64(self.size))
return size
}

var lastModifiedInReadableFormat: String {
mneuwert marked this conversation as resolved.
Show resolved Hide resolved
let dateFormatter = DateFormatter()
dateFormatter.timeStyle = .none
dateFormatter.dateStyle = .medium
dateFormatter.locale = Locale.current
dateFormatter.doesRelativeDateFormatting = true
let dateString = dateFormatter.string(from: self.lastModified)
return dateString
}
}