|
@@ -8,18 +8,38 @@
|
|
|
import Foundation
|
|
|
import AppKit
|
|
|
|
|
|
+@objc public enum ComponentTagType : Int {
|
|
|
+ case rounded = 0
|
|
|
+ case rounded_secondary
|
|
|
+ case checkable
|
|
|
+ case mark_Blue
|
|
|
+ case mark_Blue_secondary
|
|
|
+ case mark_Dark
|
|
|
+ case mark_Dark_secondary
|
|
|
+ case mark_New
|
|
|
+ case mark_New_secondary
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
public class ComponentTagProperty: NSObject {
|
|
|
|
|
|
- public var size: ComponentSize = .m
|
|
|
+ public var tagType: ComponentTagType = .rounded
|
|
|
+ public var size: ComponentSize = .s
|
|
|
public var state: ComponentState = .normal
|
|
|
+ public var isSelected: Bool = false
|
|
|
public var text: String = "" //文字信息
|
|
|
|
|
|
public var propertyInfo = TagPropertyInfo()
|
|
|
|
|
|
- public init(size: ComponentSize = .m,
|
|
|
+ public init(tagType: ComponentTagType = .rounded,
|
|
|
+ size: ComponentSize = .s,
|
|
|
state: ComponentState = .normal,
|
|
|
+ isSelected: Bool = false,
|
|
|
text: String = "") {
|
|
|
+ self.tagType = tagType
|
|
|
self.size = size
|
|
|
+ self.state = state
|
|
|
+ self.isSelected = isSelected
|
|
|
self.text = text
|
|
|
}
|
|
|
|
|
@@ -27,9 +47,9 @@ public class ComponentTagProperty: NSObject {
|
|
|
|
|
|
public class TagPropertyInfo: ComponentPropertyInfo {
|
|
|
|
|
|
- var color_Sel_Hov: NSColor?
|
|
|
- var textColor_Sel_Hov: NSColor?
|
|
|
- var textFont_Sel_Hov: NSFont?
|
|
|
+ var color_Sel_Hov: NSColor = NSColor.clear
|
|
|
+ var textColor_Sel_Hov: NSColor = NSColor.clear
|
|
|
+ var textFont_Sel_Hov: NSFont = NSFont.systemFont(ofSize: 14)
|
|
|
|
|
|
//MARK: - Function
|
|
|
override init() {
|
|
@@ -43,92 +63,138 @@ public class TagPropertyInfo: ComponentPropertyInfo {
|
|
|
extension ComponentLibrary {
|
|
|
|
|
|
func configTagComponent(properties: ComponentTagProperty) -> Void {
|
|
|
-
|
|
|
- properties.propertyInfo.color_nor = NSColor.clear
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorFill/hov") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.color_hov = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.color_hov = NSColor.clear
|
|
|
- }
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorPrimary/bg-opacity-light") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.color_active = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.color_active = NSColor.clear
|
|
|
- }
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorPrimary/bg-opacity-dark") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.color_Sel_Hov = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.color_Sel_Hov = NSColor.clear
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ properties.propertyInfo.borderWidth = 0
|
|
|
properties.propertyInfo.borderColor_nor = NSColor.clear
|
|
|
- properties.propertyInfo.borderColor_hov = NSColor.clear
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorPrimary/border1") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.borderColor_active = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.borderColor_active = NSColor.clear
|
|
|
- }
|
|
|
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("radius/xs") {
|
|
|
- let currentValue = value as! CGFloat
|
|
|
- properties.propertyInfo.cornerRadius = currentValue
|
|
|
- }
|
|
|
-
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorText/2") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.textColor = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.textColor = NSColor.clear
|
|
|
- }
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorText/2") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.textColor_hov = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.textColor_hov = NSColor.clear
|
|
|
- }
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorPrimary/text") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.textColor_Active = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.textColor_Active = NSColor.clear
|
|
|
- }
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("colorPrimary/textLight") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
- properties.propertyInfo.textColor_Sel_Hov = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
- } else {
|
|
|
- properties.propertyInfo.textColor_Sel_Hov = NSColor.clear
|
|
|
+ if properties.tagType == .rounded {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorFill/black40")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/white1")
|
|
|
+
|
|
|
+ } else if properties.tagType == .rounded_secondary {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorFill/hov")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+
|
|
|
+ } else if properties.tagType == .checkable {
|
|
|
+ properties.propertyInfo.color_nor = NSColor.clear
|
|
|
+ properties.propertyInfo.color_hov = ComponentLibrary.shared.getComponentColorFromKey("colorFill/hov")
|
|
|
+ properties.propertyInfo.color_active = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/bg-opacity-light")
|
|
|
+ properties.propertyInfo.color_Sel_Hov = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/bg-opacity-dark")
|
|
|
+
|
|
|
+ properties.propertyInfo.borderColor_nor = NSColor.clear
|
|
|
+ properties.propertyInfo.borderColor_hov = NSColor.clear
|
|
|
+ properties.propertyInfo.borderColor_active = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/border1")
|
|
|
+
|
|
|
+
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ properties.propertyInfo.textColor_hov = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ properties.propertyInfo.textColor_Active = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/text")
|
|
|
+ properties.propertyInfo.textColor_Sel_Hov = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/textLight")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_Blue {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/base")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/white1")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_Blue_secondary {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/bg-opacity-light")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/text")
|
|
|
+ properties.propertyInfo.borderWidth = 1
|
|
|
+ properties.propertyInfo.borderColor_nor = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/border1")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_Dark {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorFill/dark")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/white1")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_Dark_secondary {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorFill/4")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ properties.propertyInfo.borderWidth = 1
|
|
|
+ properties.propertyInfo.borderColor_nor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/2")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_New {
|
|
|
+ properties.propertyInfo.color_nor = ComponentLibrary.shared.getComponentColorFromKey("colorSuccess/fillHov")
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/white1")
|
|
|
+
|
|
|
+ } else if properties.tagType == .mark_New_secondary {
|
|
|
+ properties.propertyInfo.color_nor = NSColor(red: 65/255, green: 197/255, blue: 136/255, alpha: 0.1)
|
|
|
+ properties.propertyInfo.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorSuccess/text")
|
|
|
+ properties.propertyInfo.borderWidth = 1
|
|
|
+ properties.propertyInfo.borderColor_nor = ComponentLibrary.shared.getComponentColorFromKey("colorSuccess/fillHov")
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-s-regular") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
+ if properties.tagType == .rounded ||
|
|
|
+ properties.tagType == .rounded_secondary {
|
|
|
|
|
|
- if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
- let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
- let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+ if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-s-regular") {
|
|
|
+ let currentValue = value as! [String : Any]
|
|
|
|
|
|
- let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
- if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
- properties.propertyInfo.textFont = newFont
|
|
|
+ if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
+ let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
+ let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+
|
|
|
+ let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
+ if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
+ properties.propertyInfo.textFont = newFont
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-s-medium") {
|
|
|
- let currentValue = value as! [String : Any]
|
|
|
|
|
|
- if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
- let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
- let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+ } else if properties.tagType == .mark_Blue ||
|
|
|
+ properties.tagType == .mark_Blue_secondary ||
|
|
|
+ properties.tagType == .mark_Dark ||
|
|
|
+ properties.tagType == .mark_Dark_secondary ||
|
|
|
+ properties.tagType == .mark_New ||
|
|
|
+ properties.tagType == .mark_New_secondary {
|
|
|
+
|
|
|
+ if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-xs-medium") {
|
|
|
+ let currentValue = value as! [String : Any]
|
|
|
|
|
|
- let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
- if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
- properties.propertyInfo.textFont_Sel_Hov = newFont
|
|
|
+ if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
+ let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
+ let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+
|
|
|
+ let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
+ if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
+ properties.propertyInfo.textFont = newFont
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ } else if properties.tagType == .checkable {
|
|
|
+ if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-s-regular") {
|
|
|
+ let currentValue = value as! [String : Any]
|
|
|
+
|
|
|
+ if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
+ let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
+ let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+
|
|
|
+ let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
+ if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
+ properties.propertyInfo.textFont = newFont
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if let value = ComponentLibrary.shared.getComponentValueFromKey("mac/body-s-medium") {
|
|
|
+ let currentValue = value as! [String : Any]
|
|
|
+
|
|
|
+ if let fontSize = currentValue["fontSize"] as? Float,
|
|
|
+ let fontFamily = currentValue["fontFamily"] as? String,
|
|
|
+ let fontWeight = currentValue["fontWeight"] as? String {
|
|
|
+
|
|
|
+ let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: fontFamily, NSFontDescriptor.AttributeName.face: fontWeight])
|
|
|
+ if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
|
|
|
+ properties.propertyInfo.textFont_Sel_Hov = newFont
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if let value = ComponentLibrary.shared.getComponentValueFromKey("radius/xs") {
|
|
|
+ let currentValue = value as! CGFloat
|
|
|
+ properties.propertyInfo.cornerRadius = currentValue
|
|
|
}
|
|
|
|
|
|
if properties.size == .s {
|