|
@@ -1058,19 +1058,35 @@ private extension ViewController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func meetActionButton(title: String, color: NSColor, textColor: NSColor, width: CGFloat, action: Selector) -> NSButton {
|
|
func meetActionButton(title: String, color: NSColor, textColor: NSColor, width: CGFloat, action: Selector) -> NSButton {
|
|
|
- let button = NSButton(title: title, target: self, action: action)
|
|
|
|
|
|
|
+ let button = HoverButton(title: title, target: self, action: action)
|
|
|
button.translatesAutoresizingMaskIntoConstraints = false
|
|
button.translatesAutoresizingMaskIntoConstraints = false
|
|
|
button.isBordered = false
|
|
button.isBordered = false
|
|
|
button.bezelStyle = .regularSquare
|
|
button.bezelStyle = .regularSquare
|
|
|
button.wantsLayer = true
|
|
button.wantsLayer = true
|
|
|
button.layer?.cornerRadius = 9
|
|
button.layer?.cornerRadius = 9
|
|
|
- button.layer?.backgroundColor = color.cgColor
|
|
|
|
|
- button.layer?.borderColor = (title == "Cancel" ? palette.inputBorder : palette.primaryBlueBorder).cgColor
|
|
|
|
|
|
|
+ let baseBackground = color
|
|
|
|
|
+ let hoverBlend = darkModeEnabled ? NSColor.white : NSColor.black
|
|
|
|
|
+ let hoverBackground = baseBackground.blended(withFraction: 0.10, of: hoverBlend) ?? baseBackground
|
|
|
|
|
+
|
|
|
|
|
+ let baseBorder = (title == "Cancel" ? palette.inputBorder : palette.primaryBlueBorder)
|
|
|
|
|
+ let hoverBorder = baseBorder.blended(withFraction: 0.18, of: hoverBlend) ?? baseBorder
|
|
|
|
|
+
|
|
|
|
|
+ button.layer?.backgroundColor = baseBackground.cgColor
|
|
|
|
|
+ button.layer?.borderColor = baseBorder.cgColor
|
|
|
button.layer?.borderWidth = 1
|
|
button.layer?.borderWidth = 1
|
|
|
button.font = typography.buttonText
|
|
button.font = typography.buttonText
|
|
|
button.contentTintColor = textColor
|
|
button.contentTintColor = textColor
|
|
|
button.widthAnchor.constraint(equalToConstant: width).isActive = true
|
|
button.widthAnchor.constraint(equalToConstant: width).isActive = true
|
|
|
button.heightAnchor.constraint(equalToConstant: 36).isActive = true
|
|
button.heightAnchor.constraint(equalToConstant: 36).isActive = true
|
|
|
|
|
+ button.onHoverChanged = { [weak self, weak button] hovering in
|
|
|
|
|
+ guard let self, let button else { return }
|
|
|
|
|
+ button.layer?.backgroundColor = (hovering ? hoverBackground : baseBackground).cgColor
|
|
|
|
|
+ button.layer?.borderColor = (hovering ? hoverBorder : baseBorder).cgColor
|
|
|
|
|
+ if title == "Cancel" {
|
|
|
|
|
+ button.contentTintColor = hovering ? (self.darkModeEnabled ? .white : self.palette.textPrimary) : textColor
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ button.onHoverChanged?(false)
|
|
|
return button
|
|
return button
|
|
|
}
|
|
}
|
|
|
|
|
|