Переглянути джерело

【UI替换】主页 - 最近列表数据显示优化

lizhe 1 рік тому
батько
коміт
09967ca73e

+ 47 - 0
PDF Office/PDF Master.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -14397,6 +14397,21 @@
                   endingLineNumber = "50"
                   offsetFromSymbolStart = "76">
                </Location>
+               <Location
+                  uuid = "50D38F2B-1299-49C2-966D-CB1B2BCD37E9 - 4699751821b294db"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMHomeContentView.moreButtonAction(Any) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/Home/View/HomeContentView/KMHomeContentView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "50"
+                  endingLineNumber = "50"
+                  offsetFromSymbolStart = "88">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -14494,6 +14509,38 @@
             endingLineNumber = "175"
             landmarkName = "removeButtonAction(_:)"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "F3AEDC41-016A-42B8-AD4D-D8D708C24D86 - 2112011286eb620f"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMHomeQuickToolsCollectionView.removeButtonAction(Any) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/Home/WindowController/HomeQuickToolsWindowController/View/KMHomeQuickToolsCollectionView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "175"
+                  endingLineNumber = "175"
+                  offsetFromSymbolStart = "352">
+               </Location>
+               <Location
+                  uuid = "F3AEDC41-016A-42B8-AD4D-D8D708C24D86 - 2112011286eb620f"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMHomeQuickToolsCollectionView.removeButtonAction(Any) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/Home/WindowController/HomeQuickToolsWindowController/View/KMHomeQuickToolsCollectionView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "175"
+                  endingLineNumber = "175"
+                  offsetFromSymbolStart = "520">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>

+ 78 - 78
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.swift

@@ -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 {

+ 1 - 3
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.swift

@@ -28,9 +28,7 @@ class KMHomeHistoryListView: KMBaseXibView {
     
     override func draw(_ dirtyRect: NSRect) {
         if dirtyRect.size.width != self.bounds.size.width {
-            let indexPathsToReload = Set([IndexPath(item: 0, section: 0)/*, IndexPath(item: 1, section: 0)*/]) // 要刷新的单元项的索引路径
-            collectionView.reloadItems(at: indexPathsToReload)
-//            collectionView.updateLayer()
+            collectionView.reloadSections(IndexSet(integer: 0))
         }
         super.draw(dirtyRect)
     }