5
5
// Created by Abe Malla on 3/16/25.
6
6
//
7
7
8
- import SwiftUI
9
8
import AppKit
10
9
11
10
class IssueTableViewCell : StandardTableViewCell {
12
11
13
12
private var nodeIconView : NSImageView ?
14
- private var detailLabel : NSTextField ?
15
13
16
14
var issueNode : ( any IssueNode ) ?
17
15
@@ -24,60 +22,62 @@ class IssueTableViewCell: StandardTableViewCell {
24
22
super. init ( frame: frameRect, isEditable: isEditable)
25
23
self . issueNode = node
26
24
27
- secondaryLabelRightAligned = false
28
25
configureForNode ( node)
29
26
}
30
27
31
28
override func configLabel( label: NSTextField , isEditable: Bool ) {
32
29
super. configLabel ( label: label, isEditable: isEditable)
33
- label. lineBreakMode = . byTruncatingTail
34
- }
35
30
36
- override func createIcon( ) -> NSImageView {
37
- let icon = super. createIcon ( )
38
- if let diagnosticNode = issueNode as? DiagnosticIssueNode {
39
- icon. contentTintColor = diagnosticNode. severityColor
31
+ if issueNode is DiagnosticIssueNode {
32
+ label. maximumNumberOfLines = 4
33
+ label. lineBreakMode = . byTruncatingTail
34
+ label. cell? . wraps = true
35
+ label. cell? . isScrollable = false
36
+ label. preferredMaxLayoutWidth = frame. width - iconWidth - 20
37
+ } else {
38
+ label. lineBreakMode = . byTruncatingTail
40
39
}
41
- return icon
40
+ }
41
+
42
+ override func configSecondaryLabel( secondaryLabel: NSTextField ) {
43
+ super. configSecondaryLabel ( secondaryLabel: secondaryLabel)
44
+ secondaryLabel. font = . systemFont( ofSize: fontSize- 2 , weight: . medium)
42
45
}
43
46
44
47
func configureForNode( _ node: ( any IssueNode ) ? ) {
45
48
guard let node = node else { return }
46
49
50
+ secondaryLabelRightAligned = true
47
51
textField? . stringValue = node. name
48
52
49
- if let fileIssueNode = node as? FileIssueNode {
53
+ if let projectIssueNode = node as? ProjectIssueNode {
54
+ imageView? . image = projectIssueNode. nsIcon
55
+ imageView? . contentTintColor = NSColor . folderBlue
56
+ } else if let fileIssueNode = node as? FileIssueNode {
50
57
imageView? . image = fileIssueNode. nsIcon
58
+ if Settings . shared. preferences. general. fileIconStyle == . color {
59
+ imageView? . contentTintColor = NSColor ( fileIssueNode. iconColor)
60
+ } else {
61
+ imageView? . contentTintColor = NSColor . coolGray
62
+ }
51
63
} else if let diagnosticNode = node as? DiagnosticIssueNode {
52
- imageView? . image = diagnosticNode. icon
64
+ imageView? . image = diagnosticNode. nsIcon
65
+ . withSymbolConfiguration (
66
+ NSImage . SymbolConfiguration ( paletteColors: [ . white, diagnosticNode. severityColor] )
67
+ )
53
68
imageView? . contentTintColor = diagnosticNode. severityColor
54
69
}
55
70
56
- if let diagnosticNode = node as? DiagnosticIssueNode {
57
- setupDetailLabel ( with: diagnosticNode. locationString)
58
- } else if let projectNode = node as? ProjectIssueNode {
71
+ if let projectNode = node as? ProjectIssueNode {
59
72
let issuesCount = projectNode. errorCount + projectNode. warningCount
60
73
61
74
if issuesCount > 0 {
75
+ secondaryLabelRightAligned = false
62
76
secondaryLabel? . stringValue = " \( issuesCount) issues "
63
77
}
64
78
}
65
79
}
66
80
67
- private func setupDetailLabel( with text: String ) {
68
- detailLabel? . removeFromSuperview ( )
69
-
70
- let detail = NSTextField ( labelWithString: text)
71
- detail. translatesAutoresizingMaskIntoConstraints = false
72
- detail. drawsBackground = false
73
- detail. isBordered = false
74
- detail. font = . systemFont( ofSize: fontSize- 2 )
75
- detail. textColor = . secondaryLabelColor
76
-
77
- addSubview ( detail)
78
- detailLabel = detail
79
- }
80
-
81
81
/// Returns the font size for the current row height. Defaults to `13.0`
82
82
private var fontSize : Double {
83
83
switch self . frame. height {
0 commit comments