mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
This works by clearing the queue, adding all the tracks from the album to the queue and playing the first track. Fix bug where resize might leave a play button visible Had to refactor the QueueView somewhat as there was a bug that only surfaced on clearing and refilling the playlist. The bug was due to the way NSOutlineView reuses subviews. Add screenshot with album play button Move queue datasource and refactor view controller Move album datasource out of the view controller
57 lines
1.4 KiB
Swift
57 lines
1.4 KiB
Swift
//
|
|
// AlbumItem.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2019/2/08.
|
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
class AlbumItem: NSCollectionViewItem {
|
|
var observer: NSKeyValueObservation?
|
|
var album: MPDClient.Album?
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
albumCoverView.wantsLayer = true
|
|
albumCoverView.layer?.cornerRadius = 3
|
|
albumCoverView.layer?.borderWidth = 1
|
|
setAppearance()
|
|
|
|
if #available(OSX 10.14, *) {
|
|
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
|
|
self.setAppearance()
|
|
}
|
|
}
|
|
}
|
|
|
|
func setAlbum(_ album: MPDClient.Album) {
|
|
self.album = album
|
|
albumTitle.stringValue = album.title
|
|
albumArtist.stringValue = album.artist
|
|
}
|
|
|
|
func setAppearance() {
|
|
if #available(OSX 10.14, *) {
|
|
let darkMode = NSApp.effectiveAppearance.bestMatch(from:
|
|
[.darkAqua, .aqua]) == .darkAqua
|
|
|
|
albumCoverView.layer?.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
|
|
} else {
|
|
albumCoverView.layer?.borderColor = .albumBorderColorLight
|
|
}
|
|
}
|
|
|
|
@IBAction func playAlbum(_ sender: Any) {
|
|
guard let album = album else { return }
|
|
|
|
AppDelegate.mpdClient.playAlbum(album)
|
|
}
|
|
|
|
@IBOutlet var albumCoverView: NSImageView!
|
|
@IBOutlet var albumTitle: NSTextField!
|
|
@IBOutlet var albumArtist: NSTextField!
|
|
}
|