Просмотр исходного кода

组件库 - 简化外部调用接口,Token放入不需要外部再添加

wanjun 2 лет назад
Родитель
Сommit
e7768dabe7

+ 394 - 2
PDF Office/PDF Office/Class/Home/Category/NSViewController+DesignToken.swift

@@ -7,13 +7,382 @@
 
 import Foundation
 
+@objc enum TokenButtonType : Int {
+    case Cta = 0    //强调按钮
+    case Brand      //品牌按钮
+    case Sec        //二级按钮
+    case Sec_Icon
+    case Link       //链接按钮
+    case Text       //文字按钮
+    case Ghost      //幽灵按钮
+    case Icon_Fill  //icon按钮
+    case Upgrade    //升级按钮
+}
+
+@objc enum TokenButtonSize : Int {
+    case l = 0
+    case m
+    case s
+}
+
 @objc extension NSViewController {
     
     // MARK: - Button
 
-    func button(bg: String = "", text: String = "", height: NSLayoutConstraint = NSLayoutConstraint(), state: KMDesignTokenState = .Norm) -> Void {
+    func button(type: TokenButtonType, size: TokenButtonSize, height: NSLayoutConstraint = NSLayoutConstraint()) -> Void {
         if self is KMDesignButton {
-            KMDesignToken.shared.buttonDesignToken(bgToken: bg, textToken: text, heightConstraint: height, control: self as! KMDesignButton, state: state)
+            var bg = ""
+            var text = ""
+            var state: KMDesignTokenState = .Norm
+            let states = [KMDesignTokenState.Norm, KMDesignTokenState.Hov, KMDesignTokenState.Act, KMDesignTokenState.Disabled]
+            for s in states {
+                state = s
+                if (type == .Cta) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.cta.l.bg.norm"
+                            text = "btn.cta.l.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.cta.l.bg.hov"
+                            text = "btn.cta.l.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.cta.l.bg.act"
+                            text = "btn.cta.l.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.cta.l.bg.dis"
+                            text = "btn.cta.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.cta.m.bg.norm"
+                            text = "btn.cta.m.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.cta.m.bg.hov"
+                            text = "btn.cta.m.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.cta.m.bg.act"
+                            text = "btn.cta.m.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.cta.m.bg.dis"
+                            text = "btn.cta.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.cta.s.bg.norm"
+                            text = "btn.cta.s.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.cta.s.bg.hov"
+                            text = "btn.cta.s.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.cta.s.bg.act"
+                            text = "btn.cta.s.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.cta.s.bg.dis"
+                            text = "btn.cta.s.mac-text.dis"
+                        }
+                    }
+                }else if (type == .Brand) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.brand.l.bg.norm"
+                            text = "btn.brand.l.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.brand.l.bg.hov"
+                            text = "btn.brand.l.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.brand.l.bg.act"
+                            text = "btn.brand.l.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.brand.l.bg.dis"
+                            text = "btn.brand.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.brand.m.bg.norm"
+                            text = "btn.brand.m.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.brand.m.bg.hov"
+                            text = "btn.brand.m.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.brand.m.bg.act"
+                            text = "btn.brand.m.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.brand.m.bg.dis"
+                            text = "btn.brand.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.brand.s.bg.norm"
+                            text = "btn.brand.s.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.brand.s.bg.hov"
+                            text = "btn.brand.s.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.brand.s.bg.act"
+                            text = "btn.brand.s.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.brand.s.bg.dis"
+                            text = "btn.brand.s.mac-text.dis"
+                        }
+                    }
+                } else if (type == .Sec) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.sec.l.bg.norm"
+                            text = "btn.sec.l.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.sec.l.bg.hov"
+                            text = "btn.sec.l.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.sec.l.bg.act"
+                            text = "btn.sec.l.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.sec.l.bg.dis"
+                            text = "btn.sec.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.sec.m.bg.norm"
+                            text = "btn.sec.m.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.sec.m.bg.hov"
+                            text = "btn.sec.m.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.sec.m.bg.act"
+                            text = "btn.sec.m.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.sec.m.bg.dis"
+                            text = "btn.sec.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.sec.s.bg.norm"
+                            text = "btn.sec.s.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.sec.s.bg.hov"
+                            text = "btn.sec.s.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.sec.s.bg.act"
+                            text = "btn.sec.s.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.sec.s.bg.dis"
+                            text = "btn.sec.s.mac-text.dis"
+                        }
+                    }
+                } else if (type == .Sec_Icon) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.sec-icon.l.bg.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.sec-icon.l.bg.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.sec-icon.l.bg.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.sec-icon.l.bg.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.sec-icon.m.bg.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.sec-icon.m.bg.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.sec-icon.m.bg.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.sec-icon.m.bg.dis"
+                        }
+                    }
+                } else if (type == .Link) {
+                    if (size == .l) {
+                        bg = "btn.link.l.bg"
+                        if (s == .Norm) {
+                            text = "btn.link.l.mac-text.norm"
+                        } else if (s == .Hov) {
+                            text = "btn.link.l.mac-text.hov"
+                        } else if (s == .Act) {
+                            text = "btn.link.l.mac-text.act"
+                        } else if (s == .Disabled) {
+                            text = "btn.link.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        bg = "btn.link.m.bg"
+                        if (s == .Norm) {
+                            text = "btn.link.m.mac-text.norm"
+                        } else if (s == .Hov) {
+                            text = "btn.link.m.mac-text.hov"
+                        } else if (s == .Act) {
+                            text = "btn.link.m.mac-text.act"
+                        } else if (s == .Disabled) {
+                            text = "btn.link.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        bg = "btn.link.s.bg"
+                        if (s == .Norm) {
+                            text = "btn.link.s.mac-text.norm"
+                        } else if (s == .Hov) {
+                            text = "btn.link.s.mac-text.hov"
+                        } else if (s == .Act) {
+                            text = "btn.link.s.mac-text.act"
+                        } else if (s == .Disabled) {
+                            text = "btn.link.s.mac-text.dis"
+                        }
+                    }
+                } else if (type == .Text) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.text.l.bg.norm"
+                            text = "btn.text.l.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.text.l.bg.hov"
+                            text = "btn.text.l.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.text.l.bg.act"
+                            text = "btn.text.l.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.text.l.bg.dis"
+                            text = "btn.text.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.text.m.bg.norm"
+                            text = "btn.text.m.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.text.m.bg.hov"
+                            text = "btn.text.m.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.text.m.bg.act"
+                            text = "btn.text.m.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.text.m.bg.dis"
+                            text = "btn.text.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.text.s.bg.norm"
+                            text = "btn.text.s.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.text.s.bg.hov"
+                            text = "btn.text.s.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.text.s.bg.act"
+                            text = "btn.text.s.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.text.s.bg.dis"
+                            text = "btn.text.s.mac-text.dis"
+                        }
+                    }
+                } else if (type == .Ghost) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.ghost.l.bg.norm"
+                            text = "btn.ghost.l.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.ghost.l.bg.hov"
+                            text = "btn.ghost.l.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.ghost.l.bg.act"
+                            text = "btn.ghost.l.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.ghost.l.bg.dis"
+                            text = "btn.ghost.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.ghost.m.bg.norm"
+                            text = "btn.ghost.m.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.ghost.m.bg.hov"
+                            text = "btn.ghost.m.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.ghost.m.bg.act"
+                            text = "btn.ghost.m.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.ghost.m.bg.dis"
+                            text = "btn.ghost.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.ghost.s.bg.norm"
+                            text = "btn.ghost.s.mac-text.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.ghost.s.bg.hov"
+                            text = "btn.ghost.s.mac-text.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.ghost.s.bg.act"
+                            text = "btn.ghost.s.mac-text.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.ghost.s.bg.dis"
+                            text = "btn.ghost.s.mac-text.dis"
+                        }
+                    }
+                } else if (type == .Icon_Fill) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.icon-fill.l.bg.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.icon-fill.l.bg.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.icon-fill.l.bg.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.icon-fill.l.bg.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.icon-fill.m.bg.norm"
+                        } else if (s == .Hov) {
+                            bg = "btn.icon-fill.m.bg.hov"
+                        } else if (s == .Act) {
+                            bg = "btn.icon-fill.m.bg.act"
+                        } else if (s == .Disabled) {
+                            bg = "btn.icon-fill.m.bg.dis"
+                        }
+                    }
+                } else if (type == .Upgrade) {
+                    if (size == .l) {
+                        if (s == .Norm) {
+                            bg = "btn.upgrade.l.bg.norm"
+                            text = "btn.upgrade.l.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.upgrade.l.bg.hov"
+                            text = "btn.upgrade.l.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.upgrade.l.bg.act"
+                            text = "btn.upgrade.l.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.upgrade.l.bg.dis"
+                            text = "btn.upgrade.l.mac-text.dis"
+                        }
+                    } else if (size == .m) {
+                        if (s == .Norm) {
+                            bg = "btn.upgrade.m.bg.norm"
+                            text = "btn.upgrade.m.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.upgrade.m.bg.hov"
+                            text = "btn.upgrade.m.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.upgrade.m.bg.act"
+                            text = "btn.upgrade.m.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.upgrade.m.bg.dis"
+                            text = "btn.upgrade.m.mac-text.dis"
+                        }
+                    } else if (size == .s) {
+                        if (s == .Norm) {
+                            bg = "btn.upgrade.s.bg.norm"
+                            text = "btn.upgrade.s.mac-text.def"
+                        } else if (s == .Hov) {
+                            bg = "btn.upgrade.s.bg.hov"
+                            text = "btn.upgrade.s.mac-text.def"
+                        } else if (s == .Act) {
+                            bg = "btn.upgrade.s.bg.act"
+                            text = "btn.upgrade.s.mac-text.def"
+                        } else if (s == .Disabled) {
+                            bg = "btn.upgrade.s.bg.dis"
+                            text = "btn.upgrade.s.mac-text.dis"
+                        }
+                    }
+                }
+                KMDesignToken.shared.buttonDesignToken(bgToken: bg, textToken: text, heightConstraint: height, control: self as! KMDesignButton, state: state)
+            }
         } else {
             print("传入视图类型错误,组件库处理失败,本接口应传入 KMDesignButton 对象")
         }
@@ -56,6 +425,29 @@ import Foundation
         }
     }
     
+    // MARK: - Pagination
+    
+    func pagination() -> Void {
+        if self is KMDesignButton {
+            var bg = ""
+            var state: KMDesignTokenState = .Norm
+            let states = [KMDesignTokenState.Norm, KMDesignTokenState.Hov, KMDesignTokenState.Disabled]
+            for s in states {
+                state = s
+                if (s == .Norm) {
+                    bg = "pagination.selector.bg.norm"
+                } else if (s == .Hov) {
+                    bg = "pagination.selector.bg.hov"
+                } else if (s == .Disabled) {
+                    bg = "pagination.selector.bg.dis"
+                }
+                KMDesignToken.shared.buttonDesignToken(bgToken: bg, textToken: "", heightConstraint: NSLayoutConstraint(), control: self as! KMDesignButton, state: state)
+            }
+        } else {
+            print("传入视图类型错误,组件库处理失败,本接口应传入 KMDesignButton 对象")
+        }
+    }
+    
     // MARK: - Select
     
     func select(bg: String = "", text: String = "", textbg: String = "", height: NSLayoutConstraint = NSLayoutConstraint(), state: KMDesignTokenState = .Norm) -> Void {

+ 2 - 8
PDF Office/PDF Office/Class/Home/ViewController/KMHomeFastToolViewController.swift

@@ -70,20 +70,14 @@ class KMHomeFastToolViewController: NSViewController {
         fastToolAllToolsBox.contentView = fastToolAllToolsButtonVC.view
         fastToolAllToolsButtonVC.target = self
         fastToolAllToolsButtonVC.action = #selector(fastToolAllToolsAction(_:))
-        fastToolAllToolsButtonVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: fastToolAllToolsBoxHeight)
-        fastToolAllToolsButtonVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        fastToolAllToolsButtonVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        fastToolAllToolsButtonVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        fastToolAllToolsButtonVC.button(type: .Sec, size: .m, height: fastToolAllToolsBoxHeight)
 
         fastToolMoreBox.fillColor = .clear
         fastToolMoreBox.contentView = fastToolMoreButtonVC.view
         fastToolMoreButtonVC.target = self
         fastToolMoreButtonVC.action = #selector(fastToolMoreAction(_:))
         fastToolMoreButtonVC.image = NSImage(named: "icon_btn_more_false_false")!
-        fastToolMoreButtonVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: fastToolMoreBoxHeight)
-        fastToolMoreButtonVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        fastToolMoreButtonVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        fastToolMoreButtonVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        fastToolMoreButtonVC.button(type: .Sec, size: .m, height: fastToolMoreBoxHeight)
     }
     
     func initLocalization() {

+ 1 - 4
PDF Office/PDF Office/Class/Home/ViewController/KMHomeHistoryFileViewController.swift

@@ -305,10 +305,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
         deleteButtonVC.target = self
         deleteButtonVC.action = #selector(deleteAction(_:))
         deleteButtonVC.image = NSImage(named: "icon_btn_clear_false_norm")!
-        deleteButtonVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: deleteBoxHeight)
-        deleteButtonVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        deleteButtonVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        deleteButtonVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        deleteButtonVC.button(type: .Sec, size: .m, height: deleteBoxHeight)
 
         historyFileLabel.font = NSFont(name: "SFProText-Semibold", size: 20)
         historyFileLabel.textColor = NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0)

+ 3 - 12
PDF Office/PDF Office/Class/Home/ViewController/KMHomeViewController.swift

@@ -189,19 +189,13 @@ import KMAdvertisement
         openPDFBox.contentView = openPDFButtonVC.view
         openPDFButtonVC.target = self
         openPDFButtonVC.action = #selector(self.homeToolAction(_:))
-        openPDFButtonVC.button(bg: "btn.brand.l.bg.norm", text: "btn.brand.l.mac-text.def", height: openPDFBoxHeight)
-        openPDFButtonVC.button(bg: "btn.brand.l.bg.hov", text: "btn.brand.l.mac-text.def", state: .Hov)
-        openPDFButtonVC.button(bg: "btn.brand.l.bg.act", text: "btn.brand.l.mac-text.def", state: .Act)
-        openPDFButtonVC.button(bg: "btn.brand.l.bg.dis", text: "btn.brand.l.mac-text.dis", state: .Disabled)
+        openPDFButtonVC.button(type: .Brand, size: .l, height: openPDFBoxHeight)
 
         createPDFBox.fillColor = .clear
         createPDFBox.contentView = createPDFButtonVC.view
         createPDFButtonVC.target = self
         createPDFButtonVC.action = #selector(self.homeToolAction(_:))
-        createPDFButtonVC.button(bg: "btn.sec.l.bg.norm", text: "btn.sec.l.mac-text.def", height: createPDFBoxHeight)
-        createPDFButtonVC.button(bg: "btn.sec.l.bg.hov", text: "btn.sec.l.mac-text.def", state: .Hov)
-        createPDFButtonVC.button(bg: "btn.sec.l.bg.act", text: "btn.sec.l.mac-text.def", state: .Act)
-        createPDFButtonVC.button(bg: "btn.sec.l.bg.dis", text: "btn.sec.l.mac-text.dis", state: .Disabled)
+        createPDFButtonVC.button(type: .Sec, size: .l, height: createPDFBoxHeight)
         createPDFButtonVC.textButtonBox.move =  { [self](mouseEntered: Bool) -> Void in
             if mouseEntered {
                 if createPDFButtonVC.state != .Sel && createPDFButtonVC.canHover {
@@ -226,10 +220,7 @@ import KMAdvertisement
         createPDFImage.image = NSImage(named: "icon_btn_arrow_gray_down_s_norm_false")!
         createPDFImage.target = self
         createPDFImage.action = #selector(self.homeToolAction(_:))
-        createPDFImage.button(bg: "btn.icon-fill.m.bg.norm", height: createPDFViewHeight)
-        createPDFImage.button(bg: "btn.icon-fill.m.bg.hov", state: .Hov)
-        createPDFImage.button(bg: "btn.icon-fill.m.bg.act", state: .Act)
-        createPDFImage.button(bg: "btn.icon-fill.m.bg.dis", state: .Disabled)
+        createPDFImage.button(type: .Icon_Fill, size: .m, height: createPDFViewHeight)
 
         homeBox.fillColor = .clear
         homeBox.contentView = homeButtonVC.view

+ 4 - 17
PDF Office/PDF Office/Class/Home/ViewController/KMPDFToolsViewController.swift

@@ -114,20 +114,14 @@ class KMPDFToolsViewController: NSViewController {
         customizeBox.contentView = customizeVC.view
         customizeVC.target = self
         customizeVC.action = #selector(customButtonAction(_:))
-        customizeVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: customizeBoxHeight)
-        customizeVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        customizeVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        customizeVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        customizeVC.button(type: .Sec, size: .m, height: customizeBoxHeight)
         
         foldOrUnflodBox.fillColor = .clear
         foldOrUnflodBox.contentView = foldOrUnflodVC.view
         foldOrUnflodVC.image = NSImage(named: "icon_btn_more_false_false")!
         foldOrUnflodVC.target = self
         foldOrUnflodVC.action = #selector(foldOrUnflodButtonAction(_:))
-        foldOrUnflodVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: foldOrUnflodBoxHeight)
-        foldOrUnflodVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        foldOrUnflodVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        foldOrUnflodVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        foldOrUnflodVC.button(type: .Sec, size: .m, height: foldOrUnflodBoxHeight)
 
         pdfToolLabel.textColor = NSColor(hex: "#000000")
         pdfToolLabel.font = NSFont(name: "PingFangSC-Semibold", size: 16.0)
@@ -140,20 +134,13 @@ class KMPDFToolsViewController: NSViewController {
         confirmBox.contentView = confirmVC.view
         confirmVC.target = self
         confirmVC.action = #selector(confirmAction(_:))
-        confirmVC.button(bg: "btn.cta.m.bg.norm", text: "btn.cta.m.mac-text.def", height: confirmBoxHeight)
-        confirmVC.button(bg: "btn.cta.m.bg.hov", text: "btn.cta.m.mac-text.def", state: .Hov)
-        confirmVC.button(bg: "btn.cta.m.bg.act", text: "btn.cta.m.mac-text.def", state: .Act)
-        confirmVC.button(bg: "btn.cta.m.bg.dis", text: "btn.cta.m.mac-text.dis", state: .Disabled)
+        confirmVC.button(type: .Cta, size: .m, height: confirmBoxHeight)
 
         cancelBox.fillColor = .clear
         cancelBox.contentView = cancelVC.view
         cancelVC.target = self
         cancelVC.action = #selector(cancelAction(_:))
-        cancelVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def", height: cancelBoxHeight)
-        cancelVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        cancelVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        cancelVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
-        
+        cancelVC.button(type: .Sec, size: .m, height: cancelBoxHeight)
     }
     
     func initLocalization() -> Void {

+ 4 - 15
PDF Office/PDF Office/Class/PDFTools/Convert/Controller/KMConvertBaseWindowController.swift

@@ -221,9 +221,7 @@ class KMConvertBaseWindowController: NSWindowController {
         backButtonVC.action = #selector(backButtonAction)
         backButtonVC.image = NSImage(named: "KMImageNameLeftButtonImage")!
         backButtonVC.image_disabled = NSImage(named: "KMImageNameLeftButtonImageDis")!
-        backButtonVC.button(bg: "pagination.selector.bg.norm")
-        backButtonVC.button(bg: "pagination.selector.bg.hov", state: .Hov)
-        backButtonVC.button(bg: "pagination.selector.bg.dis", state: .Disabled)
+        backButtonVC.pagination()
         
         numberBox.wantsLayer = true
         self.numberBox.layer?.backgroundColor = NSColor.white.cgColor
@@ -239,9 +237,7 @@ class KMConvertBaseWindowController: NSWindowController {
         nextButtonVC.action = #selector(nextButtonAction)
         nextButtonVC.image = NSImage(named: "KMImageNameRightButtonImage")!
         nextButtonVC.image_disabled = NSImage(named: "KMImageNameRightButtonImageDis")!
-        nextButtonVC.button(bg: "pagination.selector.bg.norm")
-        nextButtonVC.button(bg: "pagination.selector.bg.hov", state: .Hov)
-        nextButtonVC.button(bg: "pagination.selector.bg.dis", state: .Disabled)
+        nextButtonVC.pagination()
 
         batchButton.title = NSLocalizedString("Batch", comment: "")
         batchButton.isBordered = false
@@ -257,21 +253,14 @@ class KMConvertBaseWindowController: NSWindowController {
         canelButtonVC.target = self
         canelButtonVC.action = #selector(cancelButtonAction)
         canelButtonVC.stringValue = NSLocalizedString("Cancel", comment: "")
-        canelButtonVC.button(bg: "btn.sec.m.bg.norm", text: "btn.sec.m.mac-text.def")
-        canelButtonVC.button(bg: "btn.sec.m.bg.hov", text: "btn.sec.m.mac-text.def", state: .Hov)
-        canelButtonVC.button(bg: "btn.sec.m.bg.act", text: "btn.sec.m.mac-text.def", state: .Act)
-        canelButtonVC.button(bg: "btn.sec.m.bg.dis", text: "btn.sec.m.mac-text.dis", state: .Disabled)
+        canelButtonVC.button(type: .Sec, size: .m)
         
         convertBox.fillColor = .clear
         convertBox.contentView = convertButtonVC.view
         convertButtonVC.target = self
         convertButtonVC.action = #selector(convertButtonAction)
         convertButtonVC.stringValue = NSLocalizedString("Convert", comment: "")
-        convertButtonVC.button(bg: "btn.cta.m.bg.norm", text: "btn.cta.m.mac-text.def")
-        convertButtonVC.button(bg: "btn.cta.m.bg.hov", text: "btn.cta.m.mac-text.def", state: .Hov)
-        convertButtonVC.button(bg: "btn.cta.m.bg.act", text: "btn.cta.m.mac-text.def", state: .Act)
-        convertButtonVC.button(bg: "btn.cta.m.bg.dis", text: "btn.cta.m.mac-text.dis", state: .Disabled)
-
+        convertButtonVC.button(type: .Cta, size: .m)
         
         self.rightScrollView.hasVerticalScroller = false
         self.rightScrollView.hasHorizontalScroller = false