|
@@ -40,6 +40,7 @@ class KMHomePopViewController: NSViewController {
|
|
|
var _state: KMDesignTokenState = .Norm
|
|
|
var enabled: Bool = true // 是否可点击
|
|
|
var canHover: Bool = true // 是否可悬浮
|
|
|
+ var disItems: [String] = []
|
|
|
|
|
|
func initWithPopViewDataArr(_ popViewDataArr: [String]) -> Self {
|
|
|
// self.dataArr = popViewDataArr.reverseObjectEnumerator().allObjects as NSArray
|
|
@@ -52,12 +53,13 @@ class KMHomePopViewController: NSViewController {
|
|
|
|
|
|
customBox.fillColor = NSColor(hex: "#FFFFFF")
|
|
|
|
|
|
- self.updateUI()
|
|
|
+// self.updateUI()
|
|
|
}
|
|
|
|
|
|
override func viewDidAppear() {
|
|
|
super.viewDidAppear()
|
|
|
-
|
|
|
+ self.updateUI()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// MARK: Private
|
|
@@ -151,6 +153,10 @@ class KMHomePopViewController: NSViewController {
|
|
|
// }
|
|
|
|
|
|
func createPopViewCellLabelWithFrame(_ mas_top: Float, stringValue: String) {
|
|
|
+ var isDisabled = false
|
|
|
+ if disItems.contains(stringValue) {
|
|
|
+ isDisabled = true
|
|
|
+ }
|
|
|
let box: KMBox = KMBox(frame: NSZeroRect)
|
|
|
box.boxType = .custom
|
|
|
box.borderWidth = 0.0
|
|
@@ -203,32 +209,32 @@ class KMHomePopViewController: NSViewController {
|
|
|
boxLabel.attributedStringValue = NSAttributedString(string: stringValue, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
|
|
|
box.moveCallback = {(mouseEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
- if mouseEntered {
|
|
|
-// if #available(macOS 10.14, *) {
|
|
|
-// box.fillColor = NSColor.controlAccentColor
|
|
|
-//// boxLabel.textColor = NSColor.white
|
|
|
-// } else {
|
|
|
-// box.fillColor = NSColor.init(red: 71/255.0, green: 126/255.0, blue: 222/255.0, alpha: 1.0)
|
|
|
-//// boxLabel.textColor = NSColor.white
|
|
|
-// }
|
|
|
- box.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.hov")
|
|
|
- } else {
|
|
|
- box.fillColor = NSColor.clear
|
|
|
-// boxLabel.textColor = NSColor.labelColor
|
|
|
+ if !isDisabled {
|
|
|
+ if mouseEntered {
|
|
|
+ box.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.hov")
|
|
|
+ } else {
|
|
|
+ box.fillColor = NSColor.clear
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
box.downCallback = {(downEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
- if downEntered {
|
|
|
- mouseBox.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.sel")
|
|
|
- boxLabel.textColor = KMDesignToken.shared.fill(withToken: "dropdown.m.mac-text.sel")
|
|
|
- if let callback = self.downCallback {
|
|
|
- callback(true, stringValue)
|
|
|
+ if !isDisabled {
|
|
|
+ if downEntered {
|
|
|
+ mouseBox.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.sel")
|
|
|
+ boxLabel.textColor = KMDesignToken.shared.fill(withToken: "dropdown.m.mac-text.sel")
|
|
|
+ if let callback = self.downCallback {
|
|
|
+ callback(true, stringValue)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mouseBox.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.norm")
|
|
|
+ boxLabel.textColor = KMDesignToken.shared.fill(withToken: "dropdown.m.mac-text.def")
|
|
|
}
|
|
|
- } else {
|
|
|
- mouseBox.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.norm")
|
|
|
- boxLabel.textColor = KMDesignToken.shared.fill(withToken: "dropdown.m.mac-text.def")
|
|
|
}
|
|
|
}
|
|
|
+ if isDisabled {
|
|
|
+ box.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.dis")
|
|
|
+ boxLabel.textColor = KMDesignToken.shared.fill(withToken: "dropdown.m.mac-text.dis")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func cellContentAdaptiveWidth(_ content: String) -> Float {
|