|
@@ -9,7 +9,8 @@ import Cocoa
|
|
|
|
|
|
class KMNoteFooterCellView: NSTableCellView, NibLoadable {
|
|
|
@IBOutlet weak var replyBox: NSBox!
|
|
|
- @IBOutlet weak var inputBox: NSBox!
|
|
|
+ @IBOutlet weak var inputBox: KMBox!
|
|
|
+ @IBOutlet weak var inputTextF: KMTextField!
|
|
|
@IBOutlet weak var replyButton: NSButton!
|
|
|
@IBOutlet weak var cancelButton: NSButton!
|
|
|
|
|
@@ -23,8 +24,13 @@ class KMNoteFooterCellView: NSTableCellView, NibLoadable {
|
|
|
@IBOutlet weak var operationIv2: NSImageView!
|
|
|
@IBOutlet weak var operationButton: NSButton!
|
|
|
|
|
|
+ @IBOutlet weak var inputBoxHeightConst: NSLayoutConstraint!
|
|
|
+ @IBOutlet weak var replyButtonTopConst: NSLayoutConstraint!
|
|
|
+
|
|
|
var itemClick: KMCommonClickBlock?
|
|
|
|
|
|
+ private var flag_ = false
|
|
|
+
|
|
|
override func draw(_ dirtyRect: NSRect) {
|
|
|
|
|
|
super.draw(dirtyRect)
|
|
@@ -35,6 +41,37 @@ class KMNoteFooterCellView: NSTableCellView, NibLoadable {
|
|
|
override func awakeFromNib() {
|
|
|
super.awakeFromNib()
|
|
|
|
|
|
+ self.flag_ = false
|
|
|
+
|
|
|
+ self.inputBox.borderColor = NSColor(white: 0, alpha: 0.2)
|
|
|
+ self.inputBox.fillColor = .white
|
|
|
+ self.inputBox.moveCallback = { [weak self] enter, theBox in
|
|
|
+ if enter {
|
|
|
+ theBox.borderColor = NSColor.km_init(hex: "#1770F4")
|
|
|
+ } else {
|
|
|
+// let focus = theBox.window?.firstResponder == self?.inputTextF
|
|
|
+ let focus = self?.flag_ ?? false
|
|
|
+ if focus == false {
|
|
|
+ theBox.borderColor = NSColor(white: 0, alpha: 0.2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.inputTextF.drawsBackground = false
|
|
|
+ self.inputTextF.isBordered = false
|
|
|
+ self.inputTextF.isBezeled = false
|
|
|
+ self.inputTextF.focusRingType = .none
|
|
|
+ self.inputTextF.backgroundColor = .clear
|
|
|
+ self.inputTextF.wantsLayer = true
|
|
|
+ self.inputTextF.layer?.backgroundColor = .clear
|
|
|
+ self.inputTextF.delegate = self
|
|
|
+ self.inputTextF.firstResponderHandler = { [weak self] result in
|
|
|
+ self?.flag_ = result
|
|
|
+ if result {
|
|
|
+ self?.inputBox.borderColor = NSColor.km_init(hex: "#1770F4")
|
|
|
+ } else {
|
|
|
+ self?.inputBox.borderColor = NSColor(white: 0, alpha: 0.2)
|
|
|
+ }
|
|
|
+ }
|
|
|
self.replyButton.title = NSLocalizedString("Reply", comment: "")
|
|
|
self.replyButton.wantsLayer = true
|
|
|
self.replyButton.setTitleColor(color: .white, font: .SFProTextRegularFont(14))
|
|
@@ -58,10 +95,36 @@ class KMNoteFooterCellView: NSTableCellView, NibLoadable {
|
|
|
self.operationButton.title = ""
|
|
|
self.operationButton.target = self
|
|
|
self.operationButton.action = #selector(operationAction)
|
|
|
+
|
|
|
+ self.updateUI(expand: false, animated: false)
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateUI(expand: Bool, animated: Bool) {
|
|
|
+ if expand {
|
|
|
+ // 64
|
|
|
+ if animated {
|
|
|
+ self.inputBoxHeightConst.animator().constant = 64
|
|
|
+ } else {
|
|
|
+ self.inputBoxHeightConst.constant = 64
|
|
|
+ }
|
|
|
+ // 12
|
|
|
+ self.replyButtonTopConst.constant = 8
|
|
|
+ self.replyBox.isHidden = false
|
|
|
+ } else {
|
|
|
+ // 64
|
|
|
+ if animated {
|
|
|
+ self.inputBoxHeightConst.animator().constant = 0
|
|
|
+ } else {
|
|
|
+ self.inputBoxHeightConst.constant = 0
|
|
|
+ }
|
|
|
+ // 12
|
|
|
+ self.replyButtonTopConst.constant = 0
|
|
|
+ self.replyBox.isHidden = true
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@objc func replyAction(_ sender: NSButton) {
|
|
|
- self.itemClick?(3)
|
|
|
+ self.itemClick?(3, self.inputTextF.stringValue)
|
|
|
}
|
|
|
|
|
|
@objc func cancelAction(_ sender: NSButton) {
|
|
@@ -76,3 +139,12 @@ class KMNoteFooterCellView: NSTableCellView, NibLoadable {
|
|
|
self.itemClick?(2, sender)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension KMNoteFooterCellView: NSTextFieldDelegate {
|
|
|
+ func controlTextDidEndEditing(_ obj: Notification) {
|
|
|
+ if self.inputTextF.isEqual(to: obj.object) {
|
|
|
+ self.inputBox.borderColor = NSColor(white: 0, alpha: 0.2)
|
|
|
+ self.flag_ = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|