Parcourir la source

【UI替换】主页 - 悬浮按钮效果实现

lizhe il y a 1 an
Parent
commit
08f9f2ac01

+ 29 - 2
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -27,8 +27,8 @@ class KMHomeContentView: KMBaseXibView {
     
     @IBOutlet weak var recentlyLabel: NSTextField!
     @IBOutlet weak var historyListView: KMHomeHistoryListView!
-    @IBOutlet weak var horizontalButton: NSButton!
-    @IBOutlet weak var verticalButton: NSButton!
+    @IBOutlet weak var horizontalButton: KMButton!
+    @IBOutlet weak var verticalButton: KMButton!
     @IBOutlet weak var cleanButton: KMButton!
     
     var historyDidSelect: KMHomeContentViewHistoryDidSelect?
@@ -85,15 +85,40 @@ class KMHomeContentView: KMBaseXibView {
             callBack(self, item)
         }
         
+        cleanButton.mouseMoveCallback = { [unowned self] enter in
+            if enter {
+                self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletHor")
+            } else {
+                self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletNor")
+            }
+        }
         
+        moreButton.mouseMoveCallback = { [unowned self] enter in
+            if enter {
+                self.moreButton.image = NSImage(named: "KMImageNameUXIconHomeMorePre")
+            } else {
+                self.moreButton.image = NSImage(named: "KMImageNameUXIconHomeMoreNor")
+            }
+        }
         
         self.updatePageLabel()
+        self.updateRecentlyListState()
     }
     
     func updatePageLabel() {
         self.pageLabel.stringValue = "\(qucikToolsView.currentPage()) / \(qucikToolsView.pageCount())"
     }
     
+    func updateRecentlyListState() {
+        let showType = self.historyListView.showType
+        if showType == .horizontal {
+            verticalButton.image = NSImage(named: "KMImageNameUXIconHomeViewthumbnailNor")
+            horizontalButton.image = NSImage(named: "KMImageNameUXIconHomeViewlistPre")
+        } else if showType == .vertical {
+            verticalButton.image = NSImage(named: "KMImageNameUXIconHomeViewthumbnailPre")
+            horizontalButton.image = NSImage(named: "KMImageNameUXIconHomeViewlistNor")
+        }
+    }
 }
 
 //MARK: Action
@@ -118,10 +143,12 @@ extension KMHomeContentView {
     
     @IBAction func horizontalButtonAction(_ sender: Any) {
         self.historyListView.showType = .horizontal
+        self.updateRecentlyListState()
     }
     
     @IBAction func verticalButtonAction(_ sender: Any) {
         self.historyListView.showType = .vertical
+        self.updateRecentlyListState()
     }
     
     @IBAction func cleanButtonAction(_ sender: Any) {

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

@@ -10,7 +10,7 @@
             <connections>
                 <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="horizontalButton" destination="f8L-dW-OV5" id="cCu-bD-LVA"/>
                 <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"/>
@@ -18,7 +18,7 @@
                 <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="34n-6o-x3z" id="qKh-a6-NQL"/>
-                <outlet property="verticalButton" destination="oce-zR-GCX" id="DXr-S4-r67"/>
+                <outlet property="verticalButton" destination="oce-zR-GCX" id="DQn-7c-OlF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -51,7 +51,7 @@
                                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                         </textFieldCell>
                                                     </textField>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YVh-aT-yWA" customClass="KMButton">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YVh-aT-yWA" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
                                                         <rect key="frame" x="589" y="2" width="20" height="20"/>
                                                         <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXIconHomeMoreNor" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="H4M-FQ-wtf">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -144,7 +144,7 @@
                                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                         </textFieldCell>
                                                     </textField>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2pe-eQ-jim" customClass="KMButton">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2pe-eQ-jim" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
                                                         <rect key="frame" x="589" y="2" width="20" height="20"/>
                                                         <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameHomeDeletNor" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="unN-7z-cUu">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -165,7 +165,7 @@
                                                             <constraint firstAttribute="height" constant="20" id="kQu-ie-pMw"/>
                                                         </constraints>
                                                     </box>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oce-zR-GCX">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oce-zR-GCX" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
                                                         <rect key="frame" x="529" y="2" width="20" height="20"/>
                                                         <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXIconHomeViewthumbnailNor" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="0s5-A7-lRz">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -179,7 +179,7 @@
                                                             <action selector="verticalButtonAction:" target="-2" id="Tsa-n6-92q"/>
                                                         </connections>
                                                     </button>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f8L-dW-OV5">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f8L-dW-OV5" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
                                                         <rect key="frame" x="493" y="2" width="20" height="20"/>
                                                         <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXIconHomeViewlistNor" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="fSg-GB-X16">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>

+ 1 - 1
PDF Office/PDF Master/Class/KMAdvertisement/View/Tableview/Cell/KMAdvertisementCollectionViewItem.swift

@@ -31,7 +31,7 @@ class KMAdvertisementCollectionViewItem: NSCollectionViewItem {
         self.titleLabel.stringValue = KMAdvertisementModelTransition.transitionLanguage(langeuage: model?.name)
 //        self.titleLabel.font = NSFont.init(name: model?.title?.font?.name ?? "AppleSystemUIFont", size: CGFloat(model?.title?.font?.size ?? 13))
         self.contentView.toolTip = KMAdvertisementModelTransition.transitionLanguage(langeuage: model?.tooltip)
-        self.contentView.layer?.cornerRadius = 8
+        self.contentView.layer?.cornerRadius = 4
         self.updateColor(false)
     }