|
@@ -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 = url.pathExtension.isEmpty ? "" : url.pathExtension
|
|
|
-// 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 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 = url.pathExtension.isEmpty ? "" : url.pathExtension
|
|
|
+ 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
|
|
|
+
|
|
|
+ //path
|
|
|
+ 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
|
|
|
+
|
|
|
+ // documentName.attributedStringValue = NSAttributedString(string: fileName, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+// documentType.attributedStringValue = NSAttributedString(string: fileType, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+ sizeLabel.attributedStringValue = NSAttributedString(string: fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+ timeLabel.attributedStringValue = NSAttributedString(string: fileTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+// mainBox.toolTip = fileName
|
|
|
//
|
|
|
-// //path
|
|
|
-// 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])
|
|
|
+// if selectUrls.contains(fileUrl) {
|
|
|
+// isSelect = true
|
|
|
+// mainBox.fillColor = NSColor.km_init(hex: "#CED0D4", alpha: 0.6)
|
|
|
+// mainBox.borderWidth = 1.0
|
|
|
+// mainBox.borderColor = NSColor.km_init(hex: "#CED0D4")
|
|
|
+// mainBox.cornerRadius = 4.0
|
|
|
// } else {
|
|
|
-// string.setString(fileUrl.path.deletingLastPathComponent)
|
|
|
+// isSelect = false
|
|
|
+// mainBox.fillColor = .clear
|
|
|
+// mainBox.borderWidth = 0.0
|
|
|
+// mainBox.cornerRadius = 0.0
|
|
|
// }
|
|
|
-//
|
|
|
-// pathLabel.stringValue = string as String
|
|
|
-//
|
|
|
-// // documentName.attributedStringValue = NSAttributedString(string: fileName, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
-//// documentType.attributedStringValue = NSAttributedString(string: fileType, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
-// sizeLabel.attributedStringValue = NSAttributedString(string: fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
-// timeLabel.attributedStringValue = NSAttributedString(string: fileTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
-//// mainBox.toolTip = fileName
|
|
|
-////
|
|
|
-//// if selectUrls.contains(fileUrl) {
|
|
|
-//// isSelect = true
|
|
|
-//// mainBox.fillColor = NSColor.km_init(hex: "#CED0D4", alpha: 0.6)
|
|
|
-//// mainBox.borderWidth = 1.0
|
|
|
-//// mainBox.borderColor = NSColor.km_init(hex: "#CED0D4")
|
|
|
-//// mainBox.cornerRadius = 4.0
|
|
|
-//// } else {
|
|
|
-//// isSelect = false
|
|
|
-//// mainBox.fillColor = .clear
|
|
|
-//// mainBox.borderWidth = 0.0
|
|
|
-//// mainBox.cornerRadius = 0.0
|
|
|
-//// }
|
|
|
-//// documentName.backgroundColor = .clear
|
|
|
-//// documentName.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-//// documentName.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
-//// documentType.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
-//// documentSize.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
-//// documentName.backgroundColor = .clear
|
|
|
-//// lastModificationTime.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
-//// lastModificationTime.backgroundColor = .clear
|
|
|
-//// moreButton.image = NSImage(named: "KMHomeMoreTools")
|
|
|
-// let image: NSImage = NSImage.previewForFile(path: fileUrl, ofSize: self.view.bounds.size, asIcon: true) ?? NSImage()
|
|
|
-// showImageView.image = image
|
|
|
-// }
|
|
|
+// documentName.backgroundColor = .clear
|
|
|
+// documentName.textColor = NSColor.km_init(hex: "#252629")
|
|
|
+// documentName.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
+// documentType.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
+// documentSize.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
+// documentName.backgroundColor = .clear
|
|
|
+// lastModificationTime.textColor = NSColor.km_init(hex: "#94989C")
|
|
|
+// lastModificationTime.backgroundColor = .clear
|
|
|
+// moreButton.image = NSImage(named: "KMHomeMoreTools")
|
|
|
+ let image: NSImage = NSImage.previewForFile(path: fileUrl, ofSize: self.view.bounds.size, asIcon: true) ?? NSImage()
|
|
|
+ showImageView.image = image
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func fileSizeString(_ fSize: Float) -> String {
|