Browse Source

【UI替换】主页 - 快捷工具完善)
- 前一页后一页
- 按钮悬浮效果

lizhe 1 year ago
parent
commit
6c9f48daf9

+ 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
-            
-            //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
+//        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"
+//            }
 //            
-//            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
+//            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 {
-//                isSelect = false
-//                mainBox.fillColor = .clear
-//                mainBox.borderWidth = 0.0
-//                mainBox.cornerRadius = 0.0
+//                fileTime = lastTime
 //            }
-//            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
-        }
+//
+//            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
+////            
+////            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
+//        }
     }
     
     func fileSizeString(_ fSize: Float) -> String {

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

@@ -123,7 +123,7 @@ extension KMHomeHistoryListView: NSCollectionViewDelegateFlowLayout {
         if showType == .horizontal {
             return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
         } else {
-            return NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
+            return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 10)
         }
     }
 }

+ 30 - 16
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -8,11 +8,13 @@
 import Cocoa
 
 typealias KMHomeContentViewHistoryDidSelect = (_ view: KMHomeContentView, _ url: URL) -> Void
+typealias KMHomeContentViewQucikToolsDidSelect = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 
 class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var qucikToolsLabel: NSTextField!
     @IBOutlet weak var qucikToolsView: KMQucikToolsView!
     @IBOutlet weak var leftButton: NSButton!
+    @IBOutlet weak var pageLabel: NSTextField!
     @IBOutlet weak var rightButton: NSButton!
     @IBOutlet weak var moreButton: KMButton!
     
@@ -24,6 +26,7 @@ class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var cleanButton: KMButton!
     
     var historyDidSelect: KMHomeContentViewHistoryDidSelect?
+    var qucikToolsDidSelect: KMHomeContentViewQucikToolsDidSelect?
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -33,40 +36,51 @@ class KMHomeContentView: KMBaseXibView {
     }
     
     override func setup() {
-        self.historyListViewSetup()
+        self.pageLabel.textColor = KMAppearance.Layout.h0Color()
+        self.qucikToolsView.didSelect = { [unowned self] view, item in
+            guard let callBack = qucikToolsDidSelect else { return }
+            
+            callBack(self, item)
+        }
+        
+        self.qucikToolsView.pageChange = { [unowned self] view in
+            self.updatePageLabel()
+        }
+        
+        self.historyListView.didSelect = { [unowned self] view, url in
+            guard let callBack = historyDidSelect else { return }
+            
+            callBack(self, url)
+        }
+        
+        self.updatePageLabel()
     }
+    
+    func updatePageLabel() {
+        self.pageLabel.stringValue = "\(qucikToolsView.currentPage()) / \(qucikToolsView.pageCount())"
+    }
+    
 }
 
+//MARK: Action
 extension KMHomeContentView {
     @IBAction func leftButtonAction(_ sender: Any) {
-        
+        self.qucikToolsView.previousPage()
     }
     
     @IBAction func rightButtonAction(_ sender: Any) {
-        
+        self.qucikToolsView.nextPage()
     }
     
     @IBAction func moreButtonAction(_ sender: Any) {
         let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
         homeQuickToolsWindowController.window?.center()
-//        homeQuickToolsWindowController.window?.orderFront(sender)
         NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
-//        NSWindow.currentWindow().beginSheet(homeQuickToolsWindowController.window!)
+
         homeQuickToolsWindowController.dataChange = { [unowned self] controller in
             self.qucikToolsView.reloadData()
         }
     }
-}
-
-extension KMHomeContentView {
-    func historyListViewSetup() {
-        self.historyListView.didSelect = { [unowned self] view, url in
-            guard let callBack = historyDidSelect else { return }
-            
-            callBack(self, url)
-        }
-        
-    }
     
     @IBAction func horizontalButtonAction(_ sender: Any) {
         self.historyListView.showType = .horizontal

+ 31 - 17
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib

@@ -11,12 +11,13 @@
                 <outlet property="cleanButton" destination="2pe-eQ-jim" id="NzZ-si-Lah"/>
                 <outlet property="historyListView" destination="wMw-AS-5yG" id="HHc-lb-Uau"/>
                 <outlet property="horizontalButton" destination="f8L-dW-OV5" id="2bQ-AH-t3U"/>
-                <outlet property="leftButton" destination="PwG-OP-iJ7" id="eZg-FR-Kro"/>
+                <outlet property="leftButton" destination="WXY-wn-hPk" id="hp6-fa-w4J"/>
                 <outlet property="moreButton" destination="YVh-aT-yWA" id="M54-rm-tnw"/>
+                <outlet property="pageLabel" destination="AZq-VF-EUc" id="CCP-bH-lFT"/>
                 <outlet property="qucikToolsLabel" destination="FaJ-2q-2cQ" id="q0S-ez-pED"/>
                 <outlet property="qucikToolsView" destination="ynU-RA-kWD" id="t4n-b1-mpf"/>
                 <outlet property="recentlyLabel" destination="Jq6-Hl-amd" id="cL6-5Q-9jC"/>
-                <outlet property="rightButton" destination="WPD-Y0-yC2" id="ZEL-I1-FmC"/>
+                <outlet property="rightButton" destination="34n-6o-x3z" id="qKh-a6-NQL"/>
                 <outlet property="verticalButton" destination="oce-zR-GCX" id="DXr-S4-r67"/>
             </connections>
         </customObject>
@@ -60,45 +61,58 @@
                                                             <action selector="moreButtonAction:" target="-2" id="4JY-gV-CUq"/>
                                                         </connections>
                                                     </button>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WPD-Y0-yC2">
+                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AZq-VF-EUc">
+                                                        <rect key="frame" x="526" y="4" width="25" height="16"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="height" constant="16" id="ysy-ux-uwA"/>
+                                                        </constraints>
+                                                        <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="1/2" id="VoQ-Tz-nCY">
+                                                            <font key="font" metaFont="cellTitle"/>
+                                                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
+                                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                        </textFieldCell>
+                                                    </textField>
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="34n-6o-x3z">
                                                         <rect key="frame" x="557" y="2" width="16" height="21"/>
-                                                        <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSTouchBarGoForwardTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="mRw-z9-Pze">
+                                                        <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSTouchBarGoForwardTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="vf1-qw-7He">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                             <font key="font" metaFont="system"/>
                                                         </buttonCell>
                                                         <constraints>
-                                                            <constraint firstAttribute="width" constant="16" id="ASJ-At-7qY"/>
-                                                            <constraint firstAttribute="height" constant="16" id="x37-9K-xk3"/>
+                                                            <constraint firstAttribute="width" constant="16" id="k4Q-hn-f2N"/>
+                                                            <constraint firstAttribute="height" constant="16" id="yiF-N3-Zwz"/>
                                                         </constraints>
                                                         <connections>
-                                                            <action selector="rightButtonAction:" target="-2" id="noR-iP-jsC"/>
+                                                            <action selector="rightButtonAction:" target="-2" id="SCM-qa-djR"/>
                                                         </connections>
                                                     </button>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PwG-OP-iJ7">
-                                                        <rect key="frame" x="509" y="2" width="16" height="21"/>
-                                                        <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="NSTouchBarGoBackTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="bil-yH-Akb">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WXY-wn-hPk">
+                                                        <rect key="frame" x="504" y="2" width="16" height="21"/>
+                                                        <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="NSTouchBarGoBackTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="his-Ac-2Du">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                             <font key="font" metaFont="system"/>
                                                         </buttonCell>
                                                         <constraints>
-                                                            <constraint firstAttribute="height" constant="16" id="Dw9-LS-jOQ"/>
-                                                            <constraint firstAttribute="width" constant="16" id="Wzf-Iv-uw7"/>
+                                                            <constraint firstAttribute="height" constant="16" id="07e-1r-Vje"/>
+                                                            <constraint firstAttribute="width" constant="16" id="CGy-dK-xkf"/>
                                                         </constraints>
                                                         <connections>
-                                                            <action selector="leftButtonAction:" target="-2" id="U2S-eX-FI8"/>
+                                                            <action selector="leftButtonAction:" target="-2" id="Ic9-Y6-q8s"/>
                                                         </connections>
                                                     </button>
                                                 </subviews>
                                                 <constraints>
-                                                    <constraint firstItem="WPD-Y0-yC2" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="1mQ-di-yW2"/>
-                                                    <constraint firstItem="WPD-Y0-yC2" firstAttribute="leading" secondItem="PwG-OP-iJ7" secondAttribute="trailing" constant="32" id="2o2-jt-hDj"/>
+                                                    <constraint firstItem="34n-6o-x3z" firstAttribute="leading" secondItem="AZq-VF-EUc" secondAttribute="trailing" constant="8" id="5b1-3H-yqn"/>
                                                     <constraint firstAttribute="trailing" secondItem="YVh-aT-yWA" secondAttribute="trailing" id="C9W-JG-W8s"/>
+                                                    <constraint firstItem="34n-6o-x3z" firstAttribute="centerY" secondItem="WXY-wn-hPk" secondAttribute="centerY" id="HqR-w0-aOA"/>
                                                     <constraint firstItem="FaJ-2q-2cQ" firstAttribute="leading" secondItem="69z-SV-dL5" secondAttribute="leading" id="UZc-nM-Aqt"/>
                                                     <constraint firstAttribute="height" constant="24" id="VF5-NT-Dua"/>
                                                     <constraint firstItem="FaJ-2q-2cQ" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="e4G-eL-brO"/>
-                                                    <constraint firstItem="YVh-aT-yWA" firstAttribute="leading" secondItem="WPD-Y0-yC2" secondAttribute="trailing" constant="16" id="sIP-zf-cQy"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="leading" secondItem="WXY-wn-hPk" secondAttribute="trailing" constant="8" id="epd-Mx-BL8"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="fCt-K0-F68"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="centerY" secondItem="WXY-wn-hPk" secondAttribute="centerY" id="hgj-vL-sIT"/>
                                                     <constraint firstItem="YVh-aT-yWA" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="u3H-Ys-UG6"/>
-                                                    <constraint firstItem="PwG-OP-iJ7" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="ygX-nH-XYo"/>
+                                                    <constraint firstItem="YVh-aT-yWA" firstAttribute="leading" secondItem="34n-6o-x3z" secondAttribute="trailing" constant="16" id="wW8-yX-vAt"/>
                                                 </constraints>
                                             </customView>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="ynU-RA-kWD" customClass="KMQucikToolsView" customModule="PDF_Master" customModuleProvider="target">

+ 65 - 7
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift

@@ -7,10 +7,18 @@
 
 import Cocoa
 
+typealias KMQucikToolsViewDidSelect = (_ view: KMQucikToolsView, _ item: KMQucikToolsModel) -> Void
+typealias KMQucikToolsViewPageChange = (_ view: KMQucikToolsView) -> Void
+
 class KMQucikToolsView: KMBaseXibView {
     @IBOutlet weak var collectionView: NSCollectionView!
     
+    
+    var didSelect: KMQucikToolsViewDidSelect?
+    var pageChange: KMQucikToolsViewPageChange?
+    
     var data: [KMQucikToolsModel] = []
+    
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
 
@@ -33,6 +41,7 @@ class KMQucikToolsView: KMBaseXibView {
         //注册cell
         self.collectionView.register(KMQucikToolCollectionViewItem.self, forItemWithIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMQucikToolCollectionViewItem"))
         
+        NotificationCenter.default.addObserver(self, selector: #selector(scrollViewDidScroll(notification:)), name: NSScrollView.didLiveScrollNotification, object: collectionView.enclosingScrollView)
 //        self.backgroundColor(KMAppearance.Layout.l0Color())
     }
     
@@ -46,24 +55,41 @@ class KMQucikToolsView: KMBaseXibView {
     }
 }
 
+//Notification
+extension KMQucikToolsView  {
+    @objc func scrollViewDidScroll(notification: Notification) {
+        // 处理滚动事件
+        if let scrollView = notification.object as? NSScrollView {
+            print("NSScrollView did scroll.")
+            // 获取滚动位置等信息
+            let contentOffset = scrollView.contentView.bounds.origin
+            print("Content Offset: \(contentOffset)")
+            
+        }
+        
+        guard let callBack = pageChange else { return }
+        callBack(self)
+    }
+}
+
 extension KMQucikToolsView: NSCollectionViewDelegate {
     //当item被选中
     public func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
         print("点击")
         let view = collectionView.item(at: indexPaths.first!) as! KMQucikToolCollectionViewItem
         
-//        let content = view.model
+        let content = view.model
         
-//        guard let callBack = didSelect else { return }
-//        
-//        content?.index = indexPaths.first!.item
-//        callBack(self, content!)
+        guard let callBack = didSelect else { return }
+        callBack(self, content!)
     }
     
    //当item取消选中
     public func collectionView(_ collectionView: NSCollectionView, didDeselectItemsAt indexPaths: Set<IndexPath>) {
         _ = collectionView.item(at: indexPaths.first!) as! KMQucikToolCollectionViewItem
     }
+    
+    
 }
 
 extension KMQucikToolsView: NSCollectionViewDataSource {
@@ -83,7 +109,6 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
         }
         return view
     }
-    
 }
 
 extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
@@ -93,6 +118,39 @@ extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
     }
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {
-        return NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
+        return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 10)
+    }
+}
+
+//Collection Page
+extension KMQucikToolsView {
+    func pageCount() -> Int {
+        return Int(ceilf(Float(self.collectionView.frame.size.width / self.collectionView.visibleRect.size.width)))
+    }
+    
+    func currentPage() -> Int {
+        return Int(ceilf(Float(self.collectionView.visibleRect.origin.x / self.collectionView.visibleRect.size.width))) + 1
+    }
+    
+    func nextPage() {
+        let currentPage = self.currentPage()
+        let pageCount = self.pageCount()
+        if currentPage < pageCount {
+            self.collectionView.scroll(CGPoint(x: Int(self.collectionView.visibleRect.size.width) * currentPage, y: 0))
+            
+            guard let callBack = pageChange else { return }
+            callBack(self)
+        }
+    }
+    
+    func previousPage() {
+        let currentPage = self.currentPage()
+        let pageCount = self.pageCount()
+        if currentPage > 1 {
+            self.collectionView.scroll(CGPoint(x: Int(self.collectionView.visibleRect.size.width) * (currentPage - 2), y: 0))
+            
+            guard let callBack = pageChange else { return }
+            callBack(self)
+        }
     }
 }

+ 8 - 6
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -78,13 +78,15 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
         self.contentBox.fillColor = KMAppearance.Layout.l1Color()
         self.contentBox.moveCallback = { [unowned self] mouseEntered, mouseBox in
             if (mouseEntered) {
-//                if (blockSelf.mouseMoveCallback) {
-//                    blockSelf.mouseMoveCallback(YES);
-//                }
+                self.contentBox.fillColor = KMAppearance.Interactive.a0Color()
+                self.titleLabel.textColor = KMAppearance.Layout.w0Color()
+                self.subTitleLabel.textColor = KMAppearance.Layout.w70Color()
+                self.iconImageView.image = model?.iconImage(true)
             } else {
-//                if (blockSelf.mouseMoveCallback) {
-//                    blockSelf.mouseMoveCallback(NO);
-//                }
+                self.contentBox.fillColor = KMAppearance.Layout.l1Color()
+                self.titleLabel.textColor = KMAppearance.Layout.h0Color()
+                self.subTitleLabel.textColor = KMAppearance.Layout.h1Color()
+                self.iconImageView.image = model?.iconImage(false)
             }
         }
         

+ 4 - 0
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -195,6 +195,10 @@ import Cocoa
         self.homeContentView.historyDidSelect = { [unowned self] view, url in
             self.openFile(withFilePath: url)
         }
+        
+        self.homeContentView.qucikToolsDidSelect = { [unowned self] view, item in
+            self.fastToolItemAction(item.type!)
+        }
     }
     
     // MARK: Init