|
@@ -28,6 +28,11 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
|
|
|
var file: URL?
|
|
|
var selectUrls: [URL] = []
|
|
|
var isSelect: Bool = false
|
|
|
+ var isHover: Bool = false {
|
|
|
+ didSet {
|
|
|
+ self.updateCellState()
|
|
|
+ }
|
|
|
+ }
|
|
|
var currentWindowController: NSWindowController?
|
|
|
|
|
|
// MARK: Init
|
|
@@ -37,26 +42,8 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
|
|
|
|
|
|
mainBox.menu = tableCellMenu
|
|
|
documentName.maximumNumberOfLines = 1
|
|
|
- mainBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
- if !self.isSelect {
|
|
|
- if mouseEntered {
|
|
|
- self.documentName.textColor = NSColor(hex: "#252629")
|
|
|
- self.documentType.textColor = NSColor(hex: "#94989C")
|
|
|
- self.documentSize.textColor = NSColor(hex: "#94989C")
|
|
|
- self.lastModificationTime.textColor = NSColor(hex: "#94989C")
|
|
|
- self.mainBox.fillColor = NSColor(hex: "#EDEEF0")
|
|
|
- self.mainBox.borderWidth = 0
|
|
|
- self.mainBox.cornerRadius = 4.0
|
|
|
- } else {
|
|
|
- self.documentName.textColor = NSColor(hex: "#252629")
|
|
|
- self.documentType.textColor = NSColor(hex: "#94989C")
|
|
|
- self.documentSize.textColor = NSColor(hex: "#94989C")
|
|
|
- self.lastModificationTime.textColor = NSColor(hex: "#94989C")
|
|
|
- self.mainBox.fillColor = .clear
|
|
|
- self.mainBox.borderWidth = 0
|
|
|
- self.mainBox.cornerRadius = 0.0
|
|
|
- }
|
|
|
- }
|
|
|
+ mainBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
+ self.isHover = mouseEntered
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -168,9 +155,34 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
|
|
|
let components = Calendar.current.dateComponents([Calendar.Component.weekOfYear], from: date)
|
|
|
return components.weekOfYear ?? 0
|
|
|
}
|
|
|
+
|
|
|
+ //MARK: update
|
|
|
+ func updateCellState() {
|
|
|
+ if fileImageView != nil {
|
|
|
+ if !self.isSelect {
|
|
|
+ if self.isHover {
|
|
|
+ self.documentName.textColor = NSColor(hex: "#252629")
|
|
|
+ self.documentType.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.documentSize.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.lastModificationTime.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.mainBox.fillColor = NSColor(hex: "#EDEEF0")
|
|
|
+ self.mainBox.borderWidth = 0
|
|
|
+ self.mainBox.cornerRadius = 4.0
|
|
|
+ } else {
|
|
|
+ print("updateCellState hover")
|
|
|
+ self.documentName.textColor = NSColor(hex: "#252629")
|
|
|
+ self.documentType.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.documentSize.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.lastModificationTime.textColor = NSColor(hex: "#94989C")
|
|
|
+ self.mainBox.fillColor = .clear
|
|
|
+ self.mainBox.borderWidth = 0
|
|
|
+ self.mainBox.cornerRadius = 0.0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// MARK: Menu
|
|
|
-
|
|
|
lazy var tableCellMenu: NSMenu = {
|
|
|
let tableCellMenu = NSMenu()
|
|
|
var item = NSMenuItem()
|
|
@@ -280,6 +292,8 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
|
|
|
var deleteButtonVC: KMDesignButton!
|
|
|
|
|
|
+ //hover
|
|
|
+ var hoverRow: Int = 0
|
|
|
// MARK: Init
|
|
|
|
|
|
override func viewWillAppear() {
|
|
@@ -782,6 +796,20 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ cellView.mainBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
+ if self.hoverRow != row {
|
|
|
+ self.historyFileTableView.reloadData(forRowIndexes: IndexSet(integer: self.hoverRow), columnIndexes: IndexSet(integer: 0))
|
|
|
+ }
|
|
|
+
|
|
|
+ self.hoverRow = row
|
|
|
+ cellView.isHover = mouseEntered
|
|
|
+ }
|
|
|
+
|
|
|
+ if row != self.hoverRow {
|
|
|
+ let cell: KMHomeHistoryFileTableviewCell = self.historyFileTableView.rowView(atRow: self.hoverRow, makeIfNecessary: false) as? KMHomeHistoryFileTableviewCell ?? KMHomeHistoryFileTableviewCell()
|
|
|
+ cell.isHover = false
|
|
|
+ }
|
|
|
return cellView
|
|
|
}
|
|
|
|