Skip to content
This repository was archived by the owner on Jun 21, 2025. It is now read-only.

Commit 2614d1b

Browse files
Search table styling
1 parent 7597b05 commit 2614d1b

File tree

2 files changed

+59
-63
lines changed

2 files changed

+59
-63
lines changed

macOS/Source/UI/Search/Search.xib

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -241,47 +241,15 @@ Gw
241241
<rect key="frame" x="1" y="1" width="458" height="377"/>
242242
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
243243
<subviews>
244-
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" headerView="1Rx-VA-4ps" viewBased="YES" id="jrU-2c-JGF">
244+
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="24" rowSizeStyle="automatic" headerView="1Rx-VA-4ps" viewBased="YES" id="jrU-2c-JGF">
245245
<rect key="frame" x="0.0" y="0.0" width="458" height="349"/>
246246
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
247247
<size key="intercellSpacing" width="17" height="0.0"/>
248248
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
249249
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
250250
<tableColumns>
251-
<tableColumn identifier="cid_searchResultTrack" width="200" minWidth="40" maxWidth="1000" id="YOq-Dd-FG8">
252-
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Track">
253-
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
254-
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
255-
</tableHeaderCell>
256-
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="afA-cE-wbZ">
257-
<font key="font" metaFont="system"/>
258-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
259-
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
260-
</textFieldCell>
261-
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
262-
<prototypeCellViews>
263-
<tableCellView identifier="cid_searchResultTrack" id="3oJ-Ve-UAc">
264-
<rect key="frame" x="8" y="0.0" width="198" height="24"/>
265-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
266-
<subviews>
267-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="10d-XA-Igb">
268-
<rect key="frame" x="0.0" y="4" width="198" height="16"/>
269-
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
270-
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="aL8-zz-7hx">
271-
<font key="font" usesAppearanceFont="YES"/>
272-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
273-
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
274-
</textFieldCell>
275-
</textField>
276-
</subviews>
277-
<connections>
278-
<outlet property="textField" destination="10d-XA-Igb" id="DA1-vk-yA0"/>
279-
</connections>
280-
</tableCellView>
281-
</prototypeCellViews>
282-
</tableColumn>
283-
<tableColumn identifier="cid_searchResultLocation" width="115" minWidth="40" maxWidth="1000" id="aYA-JS-tx4">
284-
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Location">
251+
<tableColumn identifier="cid_Index" width="45" minWidth="45" maxWidth="80" id="aYA-JS-tx4">
252+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Index">
285253
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
286254
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
287255
</tableHeaderCell>
@@ -292,12 +260,12 @@ Gw
292260
</textFieldCell>
293261
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
294262
<prototypeCellViews>
295-
<tableCellView identifier="cid_searchResultLocation" id="bMC-F6-CrY">
296-
<rect key="frame" x="223" y="0.0" width="115" height="24"/>
263+
<tableCellView id="bMC-F6-CrY" customClass="AuralTableCellView" customModule="Aural" customModuleProvider="target">
264+
<rect key="frame" x="8" y="0.0" width="43" height="24"/>
297265
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
298266
<subviews>
299267
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Sla-Cx-CNi">
300-
<rect key="frame" x="0.0" y="4" width="115" height="16"/>
268+
<rect key="frame" x="0.0" y="4" width="43" height="16"/>
301269
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
302270
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="bPw-iL-ZHs">
303271
<font key="font" usesAppearanceFont="YES"/>
@@ -312,34 +280,34 @@ Gw
312280
</tableCellView>
313281
</prototypeCellViews>
314282
</tableColumn>
315-
<tableColumn identifier="cid_searchResultMatchedField" width="97" minWidth="10" maxWidth="3.4028234663852886e+38" id="t8t-1z-mFu">
316-
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Matched Field">
283+
<tableColumn identifier="cid_Name" width="380" minWidth="40" maxWidth="1000" id="YOq-Dd-FG8">
284+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Track">
317285
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
318-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
286+
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
319287
</tableHeaderCell>
320-
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="VLH-n3-zMS">
288+
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="afA-cE-wbZ">
321289
<font key="font" metaFont="system"/>
322290
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
323291
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
324292
</textFieldCell>
325293
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
326294
<prototypeCellViews>
327-
<tableCellView identifier="cid_searchResultMatchedField" id="jLX-UE-PK6">
328-
<rect key="frame" x="355" y="0.0" width="94" height="17"/>
295+
<tableCellView id="3oJ-Ve-UAc" customClass="AuralTableCellView" customModule="Aural" customModuleProvider="target">
296+
<rect key="frame" x="68" y="0.0" width="377" height="24"/>
329297
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
330298
<subviews>
331-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="iLB-Sm-cTr">
332-
<rect key="frame" x="0.0" y="1" width="94" height="16"/>
299+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="10d-XA-Igb">
300+
<rect key="frame" x="0.0" y="4" width="377" height="16"/>
333301
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
334-
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="dvb-aU-qbm">
302+
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="aL8-zz-7hx">
335303
<font key="font" usesAppearanceFont="YES"/>
336304
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
337305
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
338306
</textFieldCell>
339307
</textField>
340308
</subviews>
341309
<connections>
342-
<outlet property="textField" destination="iLB-Sm-cTr" id="zRA-RZ-GNP"/>
310+
<outlet property="textField" destination="10d-XA-Igb" id="DA1-vk-yA0"/>
343311
</connections>
344312
</tableCellView>
345313
</prototypeCellViews>

macOS/Source/UI/Search/SearchViewController+TableView.swift

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,61 @@ extension SearchViewController: NSTableViewDataSource {
2020

2121
extension SearchViewController: NSTableViewDelegate {
2222

23+
// Adjust row height based on if the text wraps over to the next line
24+
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
25+
30
26+
}
27+
28+
func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
29+
false
30+
}
31+
2332
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
2433

25-
guard let columnId = tableColumn?.identifier,
26-
let cell = tableView.makeView(withIdentifier: columnId, owner: nil) as? NSTableCellView,
34+
guard let column = tableColumn?.identifier,
2735
let result = searchResults?.results[row] else {return nil}
2836

29-
switch columnId {
37+
let builder = TableCellBuilder()
38+
let track = result.location.track
39+
40+
switch column {
41+
42+
case .cid_index:
3043

31-
case .cid_searchResultTrackColumn:
32-
cell.text = result.location.track.displayName
44+
// if track == playQueueDelegate.currentTrack {
45+
// builder.withImage(image: .imgPlayFilled, inColor: systemColorScheme.activeControlColor)
46+
//
47+
// } else {
3348

34-
case .cid_searchResultLocationColumn:
35-
cell.text = result.location.description
49+
builder.withText(text: "\(row + 1)",
50+
inFont: systemFontScheme.normalFont, andColor: systemColorScheme.tertiaryTextColor,
51+
selectedTextColor: systemColorScheme.tertiarySelectedTextColor,
52+
bottomYOffset: systemFontScheme.tableYOffset)
53+
// }
3654

37-
case .cid_searchResultMatchedFieldColumn:
38-
cell.text = result.match.fieldKey
55+
case .cid_trackName:
56+
57+
let titleAndArtist = track.titleAndArtist
58+
59+
if let artist = titleAndArtist.artist {
60+
61+
builder.withAttributedText(strings: [(text: artist + " ", font: systemFontScheme.normalFont, color: systemColorScheme.secondaryTextColor),
62+
(text: titleAndArtist.title, font: systemFontScheme.normalFont, color: systemColorScheme.primaryTextColor)],
63+
selectedTextColors: [systemColorScheme.secondarySelectedTextColor, systemColorScheme.primarySelectedTextColor],
64+
bottomYOffset: systemFontScheme.tableYOffset)
65+
66+
} else {
67+
68+
builder.withText(text: titleAndArtist.title, inFont: systemFontScheme.normalFont, andColor: systemColorScheme.primaryTextColor,
69+
selectedTextColor: systemColorScheme.primarySelectedTextColor, bottomYOffset: systemFontScheme.tableYOffset)
70+
}
3971

4072
default:
73+
4174
return nil
4275
}
4376

44-
return cell
45-
}
46-
47-
// Adjust row height based on if the text wraps over to the next line
48-
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
49-
26
77+
return builder.buildCell(forTableView: tableView, forColumnWithId: column, inRow: row)
5078
}
5179
}
5280

0 commit comments

Comments
 (0)