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
28 lines
791 B
Swift
28 lines
791 B
Swift
//
|
|
// AlbumDataSource.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2019/2/20.
|
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
class AlbumDataSource: NSObject, NSCollectionViewDataSource {
|
|
var albums: [MPDClient.Album] = []
|
|
|
|
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
return albums.count
|
|
}
|
|
|
|
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
|
|
let item = collectionView.makeItem(withIdentifier: .albumItem, for: indexPath)
|
|
guard let albumItem = item as? AlbumItem else { return item }
|
|
|
|
albumItem.view.wantsLayer = true
|
|
albumItem.setAlbum(albums[indexPath.item])
|
|
|
|
return albumItem
|
|
}
|
|
}
|