1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Show track artist on second line in album details

This commit is contained in:
Wim Looman 2020-06-19 22:25:38 +02:00 committed by Daniel Barber
parent c1181fa283
commit 1fd8e23f64
4 changed files with 54 additions and 19 deletions

View File

@ -0,0 +1,26 @@
//
// AlbumDetailSongTitleView.swift
// Persephone
//
// Created by Nemo157 on 20200619...
// Copyright © 2020 Dan Barber. All rights reserved.
//
import AppKit
class AlbumDetailSongTitleView: NSTableCellView {
@IBOutlet var songTitle: NSTextField!
@IBOutlet var songArtist: NSTextField!
var collapseArtist: NSLayoutConstraint!
func setSong(_ song: Song) {
if collapseArtist == nil {
collapseArtist = songArtist?.heightAnchor.constraint(equalToConstant: 0.0)
}
songTitle?.stringValue = song.title
songArtist?.stringValue = song.artist
collapseArtist.isActive = song.artist == song.albumArtist
}
}

View File

@ -81,16 +81,9 @@ extension AlbumDetailView: NSTableViewDelegate {
let cellView = tableView.makeView( let cellView = tableView.makeView(
withIdentifier: .songTitle, withIdentifier: .songTitle,
owner: self owner: self
) as! NSTableCellView ) as! AlbumDetailSongTitleView
if song.artist != song.albumArtist { cellView.setSong(song)
let string = NSMutableAttributedString()
string.append(NSAttributedString(string: song.title))
string.append(NSAttributedString(string: " " + song.artist, attributes: [.foregroundColor: NSColor.secondaryLabelColor]))
cellView.textField?.attributedStringValue = string
} else {
cellView.textField?.stringValue = song.title
}
return cellView return cellView
} }

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@ -59,7 +59,7 @@
<rect key="frame" x="0.0" y="0.0" width="444" height="426"/> <rect key="frame" x="0.0" y="0.0" width="444" height="426"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="ehr-qh-87Q" customClass="AlbumDetailSongListView" customModule="Persephone" customModuleProvider="target"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" usesAutomaticRowHeights="YES" viewBased="YES" id="ehr-qh-87Q" customClass="AlbumDetailSongListView" customModule="Persephone" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="444" height="426"/> <rect key="frame" x="0.0" y="0.0" width="444" height="426"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
@ -140,26 +140,38 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews> <prototypeCellViews>
<tableCellView identifier="songTitleCell" id="41U-5i-Oot"> <tableCellView identifier="songTitleCell" translatesAutoresizingMaskIntoConstraints="NO" id="41U-5i-Oot" customClass="AlbumDetailSongTitleView" customModule="Persephone" customModuleProvider="target">
<rect key="frame" x="44" y="1" width="353" height="17"/> <rect key="frame" x="0.0" y="0.0" width="353" height="31"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="R8t-bV-9LI"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="R8t-bV-9LI">
<rect key="frame" x="0.0" y="1" width="353" height="16"/> <rect key="frame" x="0.0" y="15" width="353" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="My Song Title" id="Sdi-jJ-EOM"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="My Song Title" id="Sdi-jJ-EOM">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tQ2-xw-nh6">
<rect key="frame" x="0.0" y="0.0" width="353" height="15"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="Song Artist" id="1XN-kG-CWb">
<font key="font" metaFont="system" size="12"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="R8t-bV-9LI" firstAttribute="centerX" secondItem="41U-5i-Oot" secondAttribute="centerX" id="0Hz-cI-Y32"/> <constraint firstItem="R8t-bV-9LI" firstAttribute="centerX" secondItem="41U-5i-Oot" secondAttribute="centerX" id="0Hz-cI-Y32"/>
<constraint firstItem="R8t-bV-9LI" firstAttribute="centerY" secondItem="41U-5i-Oot" secondAttribute="centerY" id="7iv-Qw-o7d"/> <constraint firstItem="tQ2-xw-nh6" firstAttribute="top" secondItem="R8t-bV-9LI" secondAttribute="bottom" id="2zH-CJ-KKQ"/>
<constraint firstItem="R8t-bV-9LI" firstAttribute="top" secondItem="41U-5i-Oot" secondAttribute="top" id="PZP-Xp-mjF"/>
<constraint firstItem="R8t-bV-9LI" firstAttribute="leading" secondItem="41U-5i-Oot" secondAttribute="leading" constant="2" id="UzY-kH-q4q"/> <constraint firstItem="R8t-bV-9LI" firstAttribute="leading" secondItem="41U-5i-Oot" secondAttribute="leading" constant="2" id="UzY-kH-q4q"/>
<constraint firstAttribute="bottom" secondItem="tQ2-xw-nh6" secondAttribute="bottom" id="VOZ-SI-v9C"/>
<constraint firstItem="tQ2-xw-nh6" firstAttribute="leading" secondItem="41U-5i-Oot" secondAttribute="leading" constant="2" id="hZr-M7-4Ro"/>
<constraint firstItem="tQ2-xw-nh6" firstAttribute="centerX" secondItem="41U-5i-Oot" secondAttribute="centerX" id="whd-Tb-KpE"/>
</constraints> </constraints>
<connections> <connections>
<outlet property="textField" destination="R8t-bV-9LI" id="b79-el-ZAY"/> <outlet property="songArtist" destination="tQ2-xw-nh6" id="5pJ-77-key"/>
<outlet property="songTitle" destination="R8t-bV-9LI" id="9rC-ff-9B9"/>
</connections> </connections>
</tableCellView> </tableCellView>
</prototypeCellViews> </prototypeCellViews>

View File

@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
38BAC36B249CB1A7004BAEA4 /* AlbumDetailSongTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38BAC36A249CB1A6004BAEA4 /* AlbumDetailSongTitleView.swift */; };
E407861C2110CE6E006887B1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E407861B2110CE6E006887B1 /* AppDelegate.swift */; }; E407861C2110CE6E006887B1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E407861B2110CE6E006887B1 /* AppDelegate.swift */; };
E40786202110CE70006887B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E407861F2110CE70006887B1 /* Assets.xcassets */; }; E40786202110CE70006887B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E407861F2110CE70006887B1 /* Assets.xcassets */; };
E40786232110CE70006887B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E40786212110CE70006887B1 /* Main.storyboard */; }; E40786232110CE70006887B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E40786212110CE70006887B1 /* Main.storyboard */; };
@ -368,6 +369,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
38BAC36A249CB1A6004BAEA4 /* AlbumDetailSongTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumDetailSongTitleView.swift; sourceTree = "<group>"; };
E40786182110CE6E006887B1 /* Persephone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Persephone.app; sourceTree = BUILT_PRODUCTS_DIR; }; E40786182110CE6E006887B1 /* Persephone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Persephone.app; sourceTree = BUILT_PRODUCTS_DIR; };
E407861B2110CE6E006887B1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; E407861B2110CE6E006887B1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
E407861F2110CE70006887B1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; E407861F2110CE70006887B1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -933,6 +935,7 @@
E43B67A822909793007DCF55 /* AlbumDetailView.swift */, E43B67A822909793007DCF55 /* AlbumDetailView.swift */,
E4E7A6AC22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift */, E4E7A6AC22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift */,
E43B67AC229194CD007DCF55 /* AlbumTracksDataSource.swift */, E43B67AC229194CD007DCF55 /* AlbumTracksDataSource.swift */,
38BAC36A249CB1A6004BAEA4 /* AlbumDetailSongTitleView.swift */,
); );
path = "Album Detail"; path = "Album Detail";
sourceTree = "<group>"; sourceTree = "<group>";
@ -1714,6 +1717,7 @@
E480510F2423BD7100362CF3 /* MachTime.swift in Sources */, E480510F2423BD7100362CF3 /* MachTime.swift in Sources */,
E47E2FD5222071FD00F747E6 /* AlbumViewItem.swift in Sources */, E47E2FD5222071FD00F747E6 /* AlbumViewItem.swift in Sources */,
E4805A142426D73600362CF3 /* response.c in Sources */, E4805A142426D73600362CF3 /* response.c in Sources */,
38BAC36B249CB1A7004BAEA4 /* AlbumDetailSongTitleView.swift in Sources */,
E4F2EFF024076B0900198159 /* ServerActions.swift in Sources */, E4F2EFF024076B0900198159 /* ServerActions.swift in Sources */,
E408D3BE220E03EE0006D9BE /* RawRepresentable.swift in Sources */, E408D3BE220E03EE0006D9BE /* RawRepresentable.swift in Sources */,
E4B11B66226A4F830075461B /* PlayerState.swift in Sources */, E4B11B66226A4F830075461B /* PlayerState.swift in Sources */,