|
9 | 9 |
|
10 | 10 | import Cocoa
|
11 | 11 | import Darwin
|
| 12 | +import SwiftUI |
12 | 13 |
|
13 | 14 | /// A custom table row view that provides hover and selection effects
|
14 | 15 | class HoverTableRowView: NSTableRowView {
|
@@ -507,28 +508,15 @@ class MenuApp: NSObject, NSApplicationDelegate, NSTableViewDataSource, NSTableVi
|
507 | 508 | /// - row: The row for which to provide the view
|
508 | 509 | /// - Returns: The view to display in the table cell
|
509 | 510 | func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
510 |
| - let cellPadding: CGFloat = 4 |
511 |
| - let cell = NSTextField(labelWithString: filteredItems[row]) |
512 |
| - cell.textColor = NSColor.white |
513 |
| - cell.backgroundColor = NSColor.clear |
514 |
| - cell.isBordered = false |
515 |
| - cell.font = NSFont.systemFont(ofSize: 16, weight: .regular) |
516 |
| - cell.lineBreakMode = .byTruncatingTail |
517 |
| - |
518 |
| - // Create container for proper padding and hover state |
519 |
| - let container = NSView(frame: NSRect(x: 0, y: 0, width: tableView.frame.width, height: tableView.rowHeight)) |
520 |
| - container.wantsLayer = true |
521 |
| - |
522 |
| - // Center the cell vertically in its container and add side padding |
523 |
| - let cellHeight = cell.cell?.cellSize.height ?? 20 |
524 |
| - let yOffset = (container.frame.height - cellHeight) / 2 |
525 |
| - cell.frame = NSRect(x: cellPadding, |
526 |
| - y: yOffset, |
527 |
| - width: container.frame.width - (cellPadding * 2), |
528 |
| - height: cellHeight) |
529 |
| - |
530 |
| - container.addSubview(cell) |
531 |
| - return container |
| 511 | + let text = filteredItems[row] |
| 512 | + let hostingView = NSHostingView(rootView: |
| 513 | + Text(text) |
| 514 | + .font(.system(size: 16, weight: .regular)) |
| 515 | + .foregroundColor(.white) |
| 516 | + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) |
| 517 | + .padding(.leading, 4) |
| 518 | + ) |
| 519 | + return hostingView |
532 | 520 | }
|
533 | 521 |
|
534 | 522 | /// Provides a custom row view for the table
|
|
0 commit comments