diff --git a/Persephone.xcodeproj/project.pbxproj b/Persephone.xcodeproj/project.pbxproj index 971a61a..36173f5 100644 --- a/Persephone.xcodeproj/project.pbxproj +++ b/Persephone.xcodeproj/project.pbxproj @@ -104,6 +104,7 @@ E4C8B53C22342005009A20F3 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4C8B53B22342005009A20F3 /* PreferencesWindowController.swift */; }; E4C8B53E22349002009A20F3 /* MPDIdle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4C8B53D22349002009A20F3 /* MPDIdle.swift */; }; E4D3BFA622B419C000C56F48 /* QueueViewController+NSOutlineViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4D3BFA522B419C000C56F48 /* QueueViewController+NSOutlineViewDelegate.swift */; }; + E4DA820623D6236200C1EE58 /* NSSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4DA820523D6236200C1EE58 /* NSSize.swift */; }; E4E7A6AD22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4E7A6AC22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift */; }; E4E8CC902204EC7F0024217A /* Delegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4E8CC8F2204EC7F0024217A /* Delegate.swift */; }; E4E8CC922204F4B80024217A /* QueueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4E8CC912204F4B80024217A /* QueueViewController.swift */; }; @@ -297,6 +298,7 @@ E4C8B53B22342005009A20F3 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = ""; }; E4C8B53D22349002009A20F3 /* MPDIdle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPDIdle.swift; sourceTree = ""; }; E4D3BFA522B419C000C56F48 /* QueueViewController+NSOutlineViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "QueueViewController+NSOutlineViewDelegate.swift"; sourceTree = ""; }; + E4DA820523D6236200C1EE58 /* NSSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSSize.swift; sourceTree = ""; }; E4E7A6AC22AAAF98006D566C /* AlbumDetailView+NSTableViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AlbumDetailView+NSTableViewDelegate.swift"; sourceTree = ""; }; E4E8CC8F2204EC7F0024217A /* Delegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Delegate.swift; sourceTree = ""; }; E4E8CC912204F4B80024217A /* QueueViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueViewController.swift; sourceTree = ""; }; @@ -424,6 +426,7 @@ E489E39822B85D0400CA8CBD /* NSPasteboard.swift */, E489E39C22B9CF0000CA8CBD /* NSView.swift */, E43AC1F022C68E6A001E483C /* NSPasteboardItem.swift */, + E4DA820523D6236200C1EE58 /* NSSize.swift */, ); path = Extensions; sourceTree = ""; @@ -940,6 +943,7 @@ E43B67AD229194CD007DCF55 /* AlbumTracksDataSource.swift in Sources */, E41E52FD223BF87300173814 /* MPDClient+Connection.swift in Sources */, E450AD7E222620A10091BED3 /* Album.swift in Sources */, + E4DA820623D6236200C1EE58 /* NSSize.swift in Sources */, E408D3B6220DD8970006D9BE /* Notification.swift in Sources */, E43AC1F822C7065A001E483C /* AlbumCoverButton.swift in Sources */, E45962C62241A78500FC1A1E /* MPDCommand.swift in Sources */, diff --git a/Persephone/Components/Browser/Album Browser/AlbumViewItem.swift b/Persephone/Components/Browser/Album Browser/AlbumViewItem.swift index 4d1b357..c1cf92d 100644 --- a/Persephone/Components/Browser/Album Browser/AlbumViewItem.swift +++ b/Persephone/Components/Browser/Album Browser/AlbumViewItem.swift @@ -64,7 +64,7 @@ class AlbumViewItem: NSCollectionViewItem { with: .provider(provider), placeholder: NSImage.defaultCoverArt, options: [ - .processor(DownsamplingImageProcessor(size: NSSize(width: 180, height: 180))), + .processor(DownsamplingImageProcessor(size: .albumListCoverSize)), .scaleFactor(2), ] ) diff --git a/Persephone/Components/Browser/Album Detail/AlbumDetailView.swift b/Persephone/Components/Browser/Album Detail/AlbumDetailView.swift index 1fb3e73..883999b 100644 --- a/Persephone/Components/Browser/Album Detail/AlbumDetailView.swift +++ b/Persephone/Components/Browser/Album Detail/AlbumDetailView.swift @@ -141,7 +141,7 @@ class AlbumDetailView: NSViewController { with: .provider(provider), placeholder: NSImage.defaultCoverArt, options: [ - .processor(DownsamplingImageProcessor(size: NSSize(width: 500, height: 500))), + .processor(DownsamplingImageProcessor(size: .albumDetailCoverSize)), .scaleFactor(2), ] ) diff --git a/Persephone/Components/Queue/CurrentCoverArtView.swift b/Persephone/Components/Queue/CurrentCoverArtView.swift index 2509830..d12af19 100644 --- a/Persephone/Components/Queue/CurrentCoverArtView.swift +++ b/Persephone/Components/Queue/CurrentCoverArtView.swift @@ -24,11 +24,11 @@ class CurrentCoverArtView: NSImageView { let imageURL = URL(fileURLWithPath: imagePath) let provider = LocalFileImageDataProvider(fileURL: imageURL) - self.kf.setImage( + kf.setImage( with: .provider(provider), placeholder: NSImage.defaultCoverArt, options: [ - .processor(DownsamplingImageProcessor(size: NSSize(width: 500, height: 500))), + .processor(DownsamplingImageProcessor(size: .currentlyPlayingCoverSize)), .scaleFactor(2), ] ) @@ -39,10 +39,11 @@ extension CurrentCoverArtView: StoreSubscriber { typealias StoreSubscriberStateType = Song? func newState(state: Song?) { - if let song = state { - setAlbumImage(song.album) - } else { + guard let song = state else { image = .defaultCoverArt + return } + + setAlbumImage(song.album) } } diff --git a/Persephone/Components/Shared/Extensions/NSSize.swift b/Persephone/Components/Shared/Extensions/NSSize.swift new file mode 100644 index 0000000..8ee5f02 --- /dev/null +++ b/Persephone/Components/Shared/Extensions/NSSize.swift @@ -0,0 +1,16 @@ +// +// NSSize.swift +// Persephone +// +// Created by Daniel Barber on 1/20/20. +// Copyright © 2020 Dan Barber. All rights reserved. +// + +import AppKit + +extension NSSize { + static let albumListCoverSize = NSSize(width: 180, height: 180) + static let albumDetailCoverSize = NSSize(width: 500, height: 500) + static let currentlyPlayingCoverSize = albumDetailCoverSize + static let notificationCoverSize = albumListCoverSize +} diff --git a/Persephone/Components/Shared/UserNotificationsController.swift b/Persephone/Components/Shared/UserNotificationsController.swift index 65fd286..986cb9e 100644 --- a/Persephone/Components/Shared/UserNotificationsController.swift +++ b/Persephone/Components/Shared/UserNotificationsController.swift @@ -29,7 +29,7 @@ class UserNotificationsController { _ = KingfisherManager.shared.retrieveImage( with: .provider(provider), options: [ - .processor(DownsamplingImageProcessor(size: NSSize(width: 180, height: 180))), + .processor(DownsamplingImageProcessor(size: .notificationCoverSize)), .scaleFactor(2), ] ) { result in