|
@@ -128,87 +128,87 @@ extension KMHomeHistoryCollectionItem {
|
|
|
func updateFilesData() -> Void {
|
|
|
guard let fileUrl = url else { return }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ let attrib = try? FileManager.default.attributesOfItem(atPath: fileUrl.path) as? Dictionary<FileAttributeKey , Any>
|
|
|
+ if attrib != nil {
|
|
|
+ let dateFormatter: DateFormatter = DateFormatter.init()
|
|
|
+ let fileDate: Date = attrib![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
|
|
|
+ var fileTime: String = ""
|
|
|
+ if fileDate.isToday() {
|
|
|
+ dateFormatter.dateFormat = "HH:mm"
|
|
|
+ } else if self.isDateInCurrentWeek(fileDate) {
|
|
|
+ dateFormatter.dateFormat = "EEE, HH:mm"
|
|
|
+ } else {
|
|
|
+ dateFormatter.dateFormat = "MMM d, yyyy"
|
|
|
+ }
|
|
|
+
|
|
|
+ let fileName = fileUrl.lastPathComponent
|
|
|
+
|
|
|
+ let fileType = ""
|
|
|
+ let sizeFloat: Float = attrib![FileAttributeKey(rawValue: "NSFileSize")] as? Float ?? 0.0
|
|
|
+ let fileSize = fileSizeString(sizeFloat).isEmpty ? "" : fileSizeString(sizeFloat)
|
|
|
+ let lastTime = dateFormatter.string(from: fileDate)
|
|
|
+ if fileDate.isToday() {
|
|
|
+ fileTime = String(format: "%@, %@", NSLocalizedString("Today", comment: ""), lastTime)
|
|
|
+ } else if isDateInCurrentWeek(fileDate) {
|
|
|
+ fileTime = lastTime
|
|
|
+ } else {
|
|
|
+ fileTime = lastTime
|
|
|
+ }
|
|
|
+
|
|
|
+ let paragraphStyle = NSMutableParagraphStyle()
|
|
|
+ paragraphStyle.lineSpacing = 22.0
|
|
|
+ horizontalTitleLabel.stringValue = fileName
|
|
|
+ verticalTitleLabel.stringValue = fileName
|
|
|
+
|
|
|
+
|
|
|
+ let array = fileUrl.path
|
|
|
+ .deletingLastPathComponent
|
|
|
+ .components(separatedBy: "/")
|
|
|
+ let string = NSMutableString()
|
|
|
+
|
|
|
+ if array.count > 4 {
|
|
|
+ string.append(".../")
|
|
|
+ string.append(array[array.count - 3])
|
|
|
+ string.append("/")
|
|
|
+ string.append(array[array.count - 2])
|
|
|
+ string.append("/")
|
|
|
+ string.append(array[array.count - 1])
|
|
|
+ } else {
|
|
|
+ string.setString(fileUrl.path.deletingLastPathComponent)
|
|
|
+ }
|
|
|
+
|
|
|
+ pathLabel.stringValue = string as String
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sizeLabel.attributedStringValue = NSAttributedString(string: fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+ timeLabel.attributedStringValue = NSAttributedString(string: fileTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let image: NSImage = NSImage.previewForFile(path: fileUrl, ofSize: self.view.bounds.size, asIcon: true) ?? NSImage()
|
|
|
+ showImageView.image = image
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func fileSizeString(_ fSize: Float) -> String {
|