浏览代码

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

tangchao 1 年之前
父节点
当前提交
56a6a53b6b

+ 59 - 6
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -16,6 +16,11 @@ typealias KMHomeContentViewQucikToolsDidSelect = (_ view: KMHomeContentView, _ i
 typealias KMHomeContentViewQucikToolsAddAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 typealias KMHomeContentViewQucikToolsRemoveAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 
+enum KMHomeQucikToolsShowType {
+    case expand
+    case collapse
+}
+
 class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var qucikToolsLabel: NSTextField!
     @IBOutlet weak var qucikToolsView: KMQucikToolsView!
@@ -23,6 +28,7 @@ class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var pageLabel: NSTextField!
     @IBOutlet weak var rightButton: NSButton!
     @IBOutlet weak var moreButton: KMButton!
+    @IBOutlet weak var qucikToolsConstraintHeight: NSLayoutConstraint!
     
     
     @IBOutlet weak var recentlyLabel: NSTextField!
@@ -40,6 +46,17 @@ class KMHomeContentView: KMBaseXibView {
     var qucikToolsAddAction: KMHomeContentViewQucikToolsAddAction?
     var qucikToolsRemoveAction: KMHomeContentViewQucikToolsRemoveAction?
     
+    var qucikToolsType: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.qucikToolsView.type = qucikToolsType
+            if qucikToolsType == .collapse {
+                self.qucikToolsConstraintHeight.constant = 166
+            } else {
+                self.qucikToolsConstraintHeight.constant = 262
+            }
+        }
+    }
+    
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
 
@@ -131,13 +148,45 @@ extension KMHomeContentView {
         self.qucikToolsView.nextPage()
     }
     
-    @IBAction func moreButtonAction(_ sender: Any) {
-        let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
-        homeQuickToolsWindowController.window?.center()
-        NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
+    @IBAction func moreButtonAction(_ sender: NSButton) {
+        let collapse = NSLocalizedString("Collapse All", comment: "")
+        let quickTools = NSLocalizedString("Manage Quick Tools", comment: "")
+        let expand = NSLocalizedString("Expand All", comment: "")
+        
+        var array: [String] = []
+        if qucikToolsType == .expand {
+            array = [collapse, quickTools]
+        } else {
+            array = [expand, quickTools]
+        }
+        
+        let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(array)
+        let createFilePopover: NSPopover = NSPopover.init()
+        createFilePopover.contentViewController = vc
+        createFilePopover.delegate = self
+        createFilePopover.animates = true
+        createFilePopover.behavior = .semitransient
+        createFilePopover.setValue(true, forKey: "shouldHideAnchor")
+        createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
+        
+//        vc.customBoxWidthLayoutConstraint.constant = sender.frame.width
+        vc.downCallback = { [unowned self] (downEntered: Bool, count: String) -> Void in
+            if downEntered {
+                createFilePopover.close()
+                if count == collapse {
+                    self.qucikToolsType = .collapse
+                } else if count == expand {
+                    self.qucikToolsType = .expand
+                } else if count == quickTools {
+                    let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
+                    homeQuickToolsWindowController.window?.center()
+                    NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
 
-        homeQuickToolsWindowController.dataChange = { [unowned self] controller in
-            self.qucikToolsView.reloadData()
+                    homeQuickToolsWindowController.dataChange = { [unowned self] controller in
+                        self.qucikToolsView.reloadData()
+                    }
+                }
+            }
         }
     }
     
@@ -157,3 +206,7 @@ extension KMHomeContentView {
         callBack(self)
     }
 }
+
+extension KMHomeContentView: NSPopoverDelegate {
+    
+}

+ 1 - 0
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib

@@ -14,6 +14,7 @@
                 <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="qucikToolsConstraintHeight" destination="TWz-4G-1dS" id="Xlt-SU-0we"/>
                 <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"/>

+ 16 - 1
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift

@@ -20,6 +20,14 @@ class KMQucikToolsView: KMBaseXibView {
     var pageChange: KMQucikToolsViewPageChange?
     
     var data: [KMQucikToolsModel] = []
+    var type: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.collectionView.reloadData()
+//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
+//                self.collectionView.reloadData()
+//            }
+        }
+    }
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -110,6 +118,7 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
             view.model = self.data[indexPath.item]
         }
         
+        view.type = type
         view.addAction = { [unowned self] view, item in
             self.addAction?(view, item)
         }
@@ -125,7 +134,13 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
 extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
-        return NSSize(width: 216, height: 96)
+        if type == .collapse {
+            return NSSize(width: 172, height: 48)
+        } else if type == .expand {
+            return NSSize(width: 216, height: 96)
+        } else {
+            return NSSize(width: 216, height: 96)
+        }
     }
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {

+ 23 - 17
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -25,10 +25,18 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     @IBOutlet weak var tagView: NSView!
     @IBOutlet weak var tagLabel: NSTextField!
     
+    @IBOutlet weak var imageTopConstraint: NSLayoutConstraint!
+    @IBOutlet weak var handerViewTopConstraint: NSLayoutConstraint!
+    
     
     var addAction: KMQucikToolCollectionViewItemAddAction?
     var removeAction: KMQucikToolCollectionViewItemRemoveAction?
     
+    var type: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.reloadData()
+        }
+    }
     var model: KMQucikToolsModel? {
         didSet {
             self.reloadData()
@@ -90,11 +98,16 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
                 self.titleLabel.textColor = KMAppearance.Layout.w0Color()
                 self.subTitleLabel.textColor = KMAppearance.Layout.w70Color()
                 self.iconImageView.image = model?.iconImage(true)
+                
+                guard let model = self.model else { return }
+                self.handleView.isHidden = !model.canAdd()
             } else {
                 self.contentBox.fillColor = KMAppearance.Layout.l1Color()
                 self.titleLabel.textColor = KMAppearance.Layout.h0Color()
                 self.subTitleLabel.textColor = KMAppearance.Layout.h1Color()
                 self.iconImageView.image = model?.iconImage(false)
+                
+                self.handleView.isHidden = true
             }
         }
         
@@ -106,6 +119,16 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     func reloadData() {
         guard let model = model else { return }
         
+        if type == .expand {
+            imageTopConstraint.constant = 20
+            handerViewTopConstraint.constant = 44
+            subTitleLabel.isHidden = false
+        } else {
+            imageTopConstraint.constant = 14
+            handerViewTopConstraint.constant = 8
+            subTitleLabel.isHidden = true
+        }
+        
         self.titleLabel.stringValue = model.titleString()
         self.subTitleLabel.stringValue = model.subTitleString()
         self.iconImageView.image = model.iconImage()
@@ -124,20 +147,3 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     }
     
 }
-
-extension KMQucikToolCollectionViewItem {
-    override func mouseEntered(with event: NSEvent) {
-        self.view.backgroundColor(NSColor.green)
-        
-        
-        guard let model = self.model else { return }
-        self.handleView.isHidden = !model.canAdd()
-    }
-    
-    override func mouseExited(with event: NSEvent) {
-        self.view.backgroundColor(NSColor.red)
-        
-        self.handleView.isHidden = true
-    }
-    
-}

+ 7 - 6
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.xib

@@ -12,8 +12,10 @@
                 <outlet property="addBox" destination="WpY-hX-Iuh" id="fMG-vu-eRc"/>
                 <outlet property="addButton" destination="Sfr-Rz-iNv" id="t4A-h4-K0f"/>
                 <outlet property="contentBox" destination="Mqk-nf-F6P" id="NYS-b5-WXO"/>
+                <outlet property="handerViewTopConstraint" destination="MMu-GC-USf" id="foB-IM-weq"/>
                 <outlet property="handleView" destination="5hE-EB-Fbu" id="26F-NC-WO7"/>
                 <outlet property="iconImageView" destination="Vlz-sL-oSP" id="B0h-Nl-Kpf"/>
+                <outlet property="imageTopConstraint" destination="pxK-L8-ix9" id="gln-rv-V3f"/>
                 <outlet property="removeBox" destination="4I9-UP-8io" id="MX1-8C-cop"/>
                 <outlet property="removeButton" destination="HWd-oT-cNf" id="ZKr-wg-jc0"/>
                 <outlet property="subTitleLabel" destination="xUh-Dj-kJH" id="Tpg-Qr-ffJ"/>
@@ -47,7 +49,7 @@
                                         <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="KMImageNameHomeBackground" id="5wv-kB-Bkg"/>
                                     </imageView>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CuI-0G-xl6">
-                                        <rect key="frame" x="42" y="57" width="42" height="17"/>
+                                        <rect key="frame" x="42" y="58" width="42" height="17"/>
                                         <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="wMS-Vz-yLV">
                                             <font key="font" metaFont="systemBold" size="14"/>
                                             <color key="textColor" name="KMGray6Color"/>
@@ -55,7 +57,7 @@
                                         </textFieldCell>
                                     </textField>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xUh-Dj-kJH">
-                                        <rect key="frame" x="42" y="19" width="160" height="34"/>
+                                        <rect key="frame" x="42" y="20" width="160" height="34"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="34" id="gc3-Ff-Nhi"/>
                                         </constraints>
@@ -109,7 +111,6 @@
                                                 </view>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="24" id="ZZ8-sN-RHF"/>
-                                                    <constraint firstAttribute="width" constant="88" id="mSV-Jb-zUY"/>
                                                 </constraints>
                                                 <color key="fillColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                             </box>
@@ -139,7 +140,6 @@
                                                 </view>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="24" id="L9o-vl-BZL"/>
-                                                    <constraint firstAttribute="width" constant="88" id="lQZ-xc-ZE5"/>
                                                 </constraints>
                                                 <color key="fillColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                             </box>
@@ -148,6 +148,7 @@
                                             <constraint firstAttribute="trailing" secondItem="4I9-UP-8io" secondAttribute="trailing" id="H7I-ef-a1Z"/>
                                             <constraint firstItem="WpY-hX-Iuh" firstAttribute="centerY" secondItem="5hE-EB-Fbu" secondAttribute="centerY" id="PCT-YL-AFj"/>
                                             <constraint firstItem="4I9-UP-8io" firstAttribute="leading" secondItem="WpY-hX-Iuh" secondAttribute="trailing" constant="8" id="chG-Dz-V3u"/>
+                                            <constraint firstItem="WpY-hX-Iuh" firstAttribute="width" secondItem="4I9-UP-8io" secondAttribute="width" id="dGf-z5-YOL"/>
                                             <constraint firstItem="4I9-UP-8io" firstAttribute="centerY" secondItem="WpY-hX-Iuh" secondAttribute="centerY" id="hCY-iE-6l4"/>
                                             <constraint firstItem="WpY-hX-Iuh" firstAttribute="leading" secondItem="5hE-EB-Fbu" secondAttribute="leading" id="hH9-RV-mUU"/>
                                         </constraints>
@@ -155,15 +156,15 @@
                                 </subviews>
                                 <constraints>
                                     <constraint firstAttribute="bottom" secondItem="5hE-EB-Fbu" secondAttribute="bottom" constant="8" id="D7T-JK-rEj"/>
+                                    <constraint firstItem="5hE-EB-Fbu" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="44" id="MMu-GC-USf"/>
                                     <constraint firstItem="xUh-Dj-kJH" firstAttribute="leading" secondItem="CuI-0G-xl6" secondAttribute="leading" id="N72-QY-RBz"/>
                                     <constraint firstItem="CuI-0G-xl6" firstAttribute="leading" secondItem="Vlz-sL-oSP" secondAttribute="trailing" constant="8" id="WfY-mk-msC"/>
-                                    <constraint firstItem="CuI-0G-xl6" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="22" id="YjZ-Fj-3Oa"/>
                                     <constraint firstItem="5hE-EB-Fbu" firstAttribute="leading" secondItem="B7V-zv-Z6E" secondAttribute="leading" constant="16" id="Z1n-qt-ohg"/>
                                     <constraint firstItem="xUh-Dj-kJH" firstAttribute="top" secondItem="CuI-0G-xl6" secondAttribute="bottom" constant="4" id="bxk-x0-9pl"/>
                                     <constraint firstAttribute="trailing" secondItem="5hE-EB-Fbu" secondAttribute="trailing" constant="16" id="fM1-OU-rRd"/>
-                                    <constraint firstItem="5hE-EB-Fbu" firstAttribute="top" secondItem="Vlz-sL-oSP" secondAttribute="bottom" constant="4" id="kxS-do-AqU"/>
                                     <constraint firstItem="Vlz-sL-oSP" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="20" id="pxK-L8-ix9"/>
                                     <constraint firstItem="Vlz-sL-oSP" firstAttribute="leading" secondItem="B7V-zv-Z6E" secondAttribute="leading" constant="16" id="s3q-BH-Q5c"/>
+                                    <constraint firstItem="CuI-0G-xl6" firstAttribute="centerY" secondItem="Vlz-sL-oSP" secondAttribute="centerY" id="zD0-2k-XCt"/>
                                     <constraint firstAttribute="trailing" secondItem="xUh-Dj-kJH" secondAttribute="trailing" constant="16" id="zX8-gf-kxj"/>
                                 </constraints>
                             </view>