|
@@ -9,13 +9,13 @@ import Cocoa
|
|
|
import AppKit
|
|
|
|
|
|
public class ComponentCardFile: ComponentBaseXibView {
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var contendBox: NSBox!
|
|
|
@IBOutlet var iconImage: NSImageView!
|
|
|
@IBOutlet var infoLabel: NSTextField!
|
|
|
@IBOutlet var subTitleLabel: NSTextField!
|
|
|
@IBOutlet var markImage: NSImageView!
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var iconImageWidthConstraint:NSLayoutConstraint!
|
|
|
@IBOutlet var iconImageHeightConstraint:NSLayoutConstraint!
|
|
|
@IBOutlet var infoLabelHeightConstraint:NSLayoutConstraint!
|
|
@@ -24,12 +24,12 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
@IBOutlet var iconImageTopConstraint:NSLayoutConstraint!
|
|
|
@IBOutlet var infoLabelTopConstraint:NSLayoutConstraint!
|
|
|
@IBOutlet var bottomConstraint:NSLayoutConstraint!
|
|
|
-
|
|
|
+
|
|
|
private var _properties : ComponentCardFileProperty = ComponentCardFileProperty()
|
|
|
-
|
|
|
+
|
|
|
public override func draw(_ dirtyRect: NSRect) {
|
|
|
super.draw(dirtyRect)
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -51,28 +51,33 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
|
|
|
public override func awakeFromNib() {
|
|
|
super.awakeFromNib()
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//MARK: - Setter and Getter
|
|
|
public var properties : ComponentCardFileProperty {
|
|
|
get {
|
|
|
- return _properties
|
|
|
+ return _properties
|
|
|
}
|
|
|
set {
|
|
|
_properties = newValue
|
|
|
|
|
|
ComponentLibrary.shared.configCardFileComponent(properties: _properties)
|
|
|
|
|
|
- setupUI()
|
|
|
+ setupUI()
|
|
|
|
|
|
- refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//MARK: - SetupUI
|
|
|
func setupUI() {
|
|
|
+ iconImage.wantsLayer = true
|
|
|
+ iconImage.layer?.cornerRadius = ComponentLibrary.shared.getComponentValueFromKey("comp-field/radius") as? CGFloat ?? 4
|
|
|
+ iconImage.layer?.borderWidth = 1
|
|
|
+ iconImage.layer?.borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider").cgColor
|
|
|
+
|
|
|
iconImage.image = properties.icon
|
|
|
infoLabel.stringValue = properties.text ?? ""
|
|
|
subTitleLabel.stringValue = properties.subText ?? ""
|
|
@@ -82,8 +87,7 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
}
|
|
|
|
|
|
func refreshUI() {
|
|
|
-
|
|
|
- contendBox.cornerRadius = properties.propertyInfo.cornerRadius
|
|
|
+ contendBox.cornerRadius = properties.propertyInfo.cornerRadius
|
|
|
var borderWidth: CGFloat = 0
|
|
|
var borderColor: NSColor?
|
|
|
var fillColor: NSColor?
|
|
@@ -91,7 +95,7 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
var textFont: NSFont?
|
|
|
var subTextColor: NSColor?
|
|
|
var subTextFont: NSFont?
|
|
|
-
|
|
|
+
|
|
|
if properties.state == .normal {
|
|
|
borderWidth = properties.propertyInfo.borderWidth
|
|
|
borderColor = properties.propertyInfo.borderColor_nor
|
|
@@ -118,18 +122,18 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
subTextFont = properties.propertyInfo.subTextFont
|
|
|
}
|
|
|
|
|
|
- contendBox.borderWidth = borderWidth
|
|
|
+ contendBox.borderWidth = borderWidth
|
|
|
if let color = borderColor {
|
|
|
- contendBox.borderColor = color
|
|
|
+ contendBox.borderColor = color
|
|
|
}
|
|
|
if let color = fillColor {
|
|
|
- contendBox.fillColor = color
|
|
|
+ contendBox.fillColor = color
|
|
|
}
|
|
|
if let color = textColor {
|
|
|
- infoLabel.textColor = color
|
|
|
+ infoLabel.textColor = color
|
|
|
}
|
|
|
if let font = textFont {
|
|
|
- infoLabel.font = font
|
|
|
+ infoLabel.font = font
|
|
|
}
|
|
|
|
|
|
if let color = subTextColor {
|
|
@@ -149,15 +153,15 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
properties.propertyInfo.topIconOffset = iconImageTopConstraint.constant
|
|
|
properties.propertyInfo.topLabelOffset = infoLabelTopConstraint.constant
|
|
|
properties.propertyInfo.bottomOffset = bottomConstraint.constant
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//MARK: - Public Method
|
|
|
public func reloadData() {
|
|
|
|
|
|
- setupUI()
|
|
|
+ setupUI()
|
|
|
|
|
|
- refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
}
|
|
|
|
|
@@ -165,9 +169,9 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
public override func mouseEntered(with event: NSEvent) {
|
|
|
super.mouseEntered(with: event)
|
|
|
if properties.state != .pressed {
|
|
|
- properties.state = .hover
|
|
|
+ properties.state = .hover
|
|
|
|
|
|
- refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -179,12 +183,12 @@ public class ComponentCardFile: ComponentBaseXibView {
|
|
|
|
|
|
public override func mouseExited(with event: NSEvent) {
|
|
|
super.mouseExited(with: event)
|
|
|
-
|
|
|
+
|
|
|
if properties.state != .pressed {
|
|
|
- properties.state = .normal
|
|
|
+ properties.state = .normal
|
|
|
|
|
|
- refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|