55// Created by Abe Malla on 3/16/25.
66//
77
8- import SwiftUI
98import AppKit
109
1110class IssueTableViewCell : StandardTableViewCell {
1211
1312 private var nodeIconView : NSImageView ?
14- private var detailLabel : NSTextField ?
1513
1614 var issueNode : ( any IssueNode ) ?
1715
@@ -24,60 +22,62 @@ class IssueTableViewCell: StandardTableViewCell {
2422 super. init ( frame: frameRect, isEditable: isEditable)
2523 self . issueNode = node
2624
27- secondaryLabelRightAligned = false
2825 configureForNode ( node)
2926 }
3027
3128 override func configLabel( label: NSTextField , isEditable: Bool ) {
3229 super. configLabel ( label: label, isEditable: isEditable)
33- label. lineBreakMode = . byTruncatingTail
34- }
3530
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
4039 }
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)
4245 }
4346
4447 func configureForNode( _ node: ( any IssueNode ) ? ) {
4548 guard let node = node else { return }
4649
50+ secondaryLabelRightAligned = true
4751 textField? . stringValue = node. name
4852
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 {
5057 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+ }
5163 } 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+ )
5368 imageView? . contentTintColor = diagnosticNode. severityColor
5469 }
5570
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 {
5972 let issuesCount = projectNode. errorCount + projectNode. warningCount
6073
6174 if issuesCount > 0 {
75+ secondaryLabelRightAligned = false
6276 secondaryLabel? . stringValue = " \( issuesCount) issues "
6377 }
6478 }
6579 }
6680
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-
8181 /// Returns the font size for the current row height. Defaults to `13.0`
8282 private var fontSize : Double {
8383 switch self . frame. height {
0 commit comments