From 1fd8e23f6481e570f2467f4593c52968c7ce8639 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Fri, 19 Jun 2020 22:25:38 +0200 Subject: [PATCH] Show track artist on second line in album details --- .../AlbumDetailSongTitleView.swift | 26 ++++++++++++++++ .../AlbumDetailView+NSTableViewDelegate.swift | 13 ++------ .../Browser/Album Detail/AlbumDetailView.xib | 30 +++++++++++++------ Persephone.xcodeproj/project.pbxproj | 4 +++ 4 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 Mac/Components/Browser/Album Detail/AlbumDetailSongTitleView.swift diff --git a/Mac/Components/Browser/Album Detail/AlbumDetailSongTitleView.swift b/Mac/Components/Browser/Album Detail/AlbumDetailSongTitleView.swift new file mode 100644 index 0000000..7ae3348 --- /dev/null +++ b/Mac/Components/Browser/Album Detail/AlbumDetailSongTitleView.swift @@ -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 + } +} + diff --git a/Mac/Components/Browser/Album Detail/AlbumDetailView+NSTableViewDelegate.swift b/Mac/Components/Browser/Album Detail/AlbumDetailView+NSTableViewDelegate.swift index 99d0b96..0a526c9 100644 --- a/Mac/Components/Browser/Album Detail/AlbumDetailView+NSTableViewDelegate.swift +++ b/Mac/Components/Browser/Album Detail/AlbumDetailView+NSTableViewDelegate.swift @@ -81,16 +81,9 @@ extension AlbumDetailView: NSTableViewDelegate { let cellView = tableView.makeView( withIdentifier: .songTitle, owner: self - ) as! NSTableCellView - - if song.artist != song.albumArtist { - 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 - } + ) as! AlbumDetailSongTitleView + + cellView.setSong(song) return cellView } diff --git a/Mac/Components/Browser/Album Detail/AlbumDetailView.xib b/Mac/Components/Browser/Album Detail/AlbumDetailView.xib index 703d0ba..c9aa311 100644 --- a/Mac/Components/Browser/Album Detail/AlbumDetailView.xib +++ b/Mac/Components/Browser/Album Detail/AlbumDetailView.xib @@ -1,8 +1,8 @@ - + - + @@ -59,7 +59,7 @@ - + @@ -140,26 +140,38 @@ - - - + + - + + + + + + + + + - + + + + + - + + diff --git a/Persephone.xcodeproj/project.pbxproj b/Persephone.xcodeproj/project.pbxproj index 05ca520..77f766d 100644 --- a/Persephone.xcodeproj/project.pbxproj +++ b/Persephone.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* 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 */; }; E40786202110CE70006887B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E407861F2110CE70006887B1 /* Assets.xcassets */; }; E40786232110CE70006887B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E40786212110CE70006887B1 /* Main.storyboard */; }; @@ -368,6 +369,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 38BAC36A249CB1A6004BAEA4 /* AlbumDetailSongTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumDetailSongTitleView.swift; sourceTree = ""; }; 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 = ""; }; E407861F2110CE70006887B1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -933,6 +935,7 @@ E43B67A822909793007DCF55 /* AlbumDetailView.swift */, E4E7A6AC22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift */, E43B67AC229194CD007DCF55 /* AlbumTracksDataSource.swift */, + 38BAC36A249CB1A6004BAEA4 /* AlbumDetailSongTitleView.swift */, ); path = "Album Detail"; sourceTree = ""; @@ -1714,6 +1717,7 @@ E480510F2423BD7100362CF3 /* MachTime.swift in Sources */, E47E2FD5222071FD00F747E6 /* AlbumViewItem.swift in Sources */, E4805A142426D73600362CF3 /* response.c in Sources */, + 38BAC36B249CB1A7004BAEA4 /* AlbumDetailSongTitleView.swift in Sources */, E4F2EFF024076B0900198159 /* ServerActions.swift in Sources */, E408D3BE220E03EE0006D9BE /* RawRepresentable.swift in Sources */, E4B11B66226A4F830075461B /* PlayerState.swift in Sources */,