mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
No commits in common. "c2bc1faa4a7ef95126ba1b0761822e3b3820690d" and "23e5860ce89a8ad64797da9a39f1d8305a2ae1bd" have entirely different histories.
c2bc1faa4a
...
23e5860ce8
@ -1,14 +0,0 @@
|
||||
//
|
||||
// NSColor.swift
|
||||
// Persephone
|
||||
//
|
||||
// Created by Daniel Barber on 2019/2/16.
|
||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||
//
|
||||
|
||||
import CoreGraphics
|
||||
|
||||
extension CGColor {
|
||||
static let albumBorderColorLight = CGColor.black.copy(alpha: 0.15)
|
||||
static let albumBorderColorDark = CGColor.white.copy(alpha: 0.15)
|
||||
}
|
||||
@ -26,7 +26,7 @@
|
||||
E41222172431425400473C1D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41222052431425400473C1D /* SceneDelegate.swift */; };
|
||||
E41222182431425400473C1D /* AlbumItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41222092431425400473C1D /* AlbumItemCell.swift */; };
|
||||
E41222192431425400473C1D /* AlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E412220A2431425400473C1D /* AlbumViewController.swift */; };
|
||||
E412221A2431425400473C1D /* AlbumDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = E412220B2431425400473C1D /* AlbumDataSource.swift */; };
|
||||
E412221A2431425400473C1D /* AlbumViewController+UICollectionViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = E412220B2431425400473C1D /* AlbumViewController+UICollectionViewDataSource.swift */; };
|
||||
E412221B2431425400473C1D /* AlbumViewController+UICollectionViewDelegateFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = E412220C2431425400473C1D /* AlbumViewController+UICollectionViewDelegateFlowLayout.swift */; };
|
||||
E412221C2431431500473C1D /* Persephone_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41221F72431425300473C1D /* Persephone_iOSTests.swift */; };
|
||||
E412221F2431432100473C1D /* Persephone_iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41221FB2431425300473C1D /* Persephone_iOSUITests.swift */; };
|
||||
@ -268,6 +268,7 @@
|
||||
E489E39D22B9CF0000CA8CBD /* NSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E489E39C22B9CF0000CA8CBD /* NSView.swift */; };
|
||||
E489E3A422B9D31800CA8CBD /* DraggedSongView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E489E3A222B9D31800CA8CBD /* DraggedSongView.swift */; };
|
||||
E489E3A522B9D31800CA8CBD /* DraggedSongView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E489E3A322B9D31800CA8CBD /* DraggedSongView.xib */; };
|
||||
E4928E0B2218D62A001D4BEA /* CGColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4928E0A2218D62A001D4BEA /* CGColor.swift */; };
|
||||
E49A5482233E580800EED353 /* PromiseKit in Frameworks */ = {isa = PBXBuildFile; productRef = E49A5481233E580800EED353 /* PromiseKit */; };
|
||||
E49A5485233E5ADC00EED353 /* Differ in Frameworks */ = {isa = PBXBuildFile; productRef = E49A5484233E5ADC00EED353 /* Differ */; };
|
||||
E49A5488233E5B0000EED353 /* ReSwift in Frameworks */ = {isa = PBXBuildFile; productRef = E49A5487233E5B0000EED353 /* ReSwift */; };
|
||||
@ -293,7 +294,6 @@
|
||||
E4B11BC02275EE150075461B /* QueueActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B11BBF2275EE150075461B /* QueueActions.swift */; };
|
||||
E4B11BC22275EE410075461B /* AlbumListActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B11BC12275EE410075461B /* AlbumListActions.swift */; };
|
||||
E4B28EE02436D56E003B28AE /* AlbumDetailFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B28EDE2436D548003B28AE /* AlbumDetailFooterView.swift */; };
|
||||
E4B28EE224379606003B28AE /* CGColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B28EE124379606003B28AE /* CGColor.swift */; };
|
||||
E4B3B3642432DB7A007E25D2 /* AlbumSongCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B3B3622432DA4B007E25D2 /* AlbumSongCell.swift */; };
|
||||
E4B3B3672432DF1B007E25D2 /* AlbumSongListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B3B3652432DEDB007E25D2 /* AlbumSongListViewController.swift */; };
|
||||
E4B3DF6523D66A4400728F6B /* QueueSongCoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B3DF6423D66A4400728F6B /* QueueSongCoverView.swift */; };
|
||||
@ -426,7 +426,7 @@
|
||||
E41222052431425400473C1D /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
E41222092431425400473C1D /* AlbumItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumItemCell.swift; sourceTree = "<group>"; };
|
||||
E412220A2431425400473C1D /* AlbumViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumViewController.swift; sourceTree = "<group>"; };
|
||||
E412220B2431425400473C1D /* AlbumDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumDataSource.swift; sourceTree = "<group>"; };
|
||||
E412220B2431425400473C1D /* AlbumViewController+UICollectionViewDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AlbumViewController+UICollectionViewDataSource.swift"; sourceTree = "<group>"; };
|
||||
E412220C2431425400473C1D /* AlbumViewController+UICollectionViewDelegateFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AlbumViewController+UICollectionViewDelegateFlowLayout.swift"; sourceTree = "<group>"; };
|
||||
E41222272431539800473C1D /* CGSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGSize.swift; sourceTree = "<group>"; };
|
||||
E412222F2432B0A300473C1D /* AlbumTracksDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumTracksDataSource.swift; sourceTree = "<group>"; };
|
||||
@ -654,7 +654,6 @@
|
||||
E4B11BBF2275EE150075461B /* QueueActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueActions.swift; sourceTree = "<group>"; };
|
||||
E4B11BC12275EE410075461B /* AlbumListActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumListActions.swift; sourceTree = "<group>"; };
|
||||
E4B28EDE2436D548003B28AE /* AlbumDetailFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumDetailFooterView.swift; sourceTree = "<group>"; };
|
||||
E4B28EE124379606003B28AE /* CGColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGColor.swift; sourceTree = "<group>"; };
|
||||
E4B3B3622432DA4B007E25D2 /* AlbumSongCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumSongCell.swift; sourceTree = "<group>"; };
|
||||
E4B3B3652432DEDB007E25D2 /* AlbumSongListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumSongListViewController.swift; sourceTree = "<group>"; };
|
||||
E4B3DF6423D66A4400728F6B /* QueueSongCoverView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueSongCoverView.swift; sourceTree = "<group>"; };
|
||||
@ -815,7 +814,6 @@
|
||||
E408D3B7220DE8CC0006D9BE /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E4B28EE124379606003B28AE /* CGColor.swift */,
|
||||
E40FE71A221B904300A4223F /* NSEvent.swift */,
|
||||
E435E3E1221CD4E200184CFC /* NSFont.swift */,
|
||||
E435E3E3221CD75D00184CFC /* NSImage.swift */,
|
||||
@ -871,6 +869,7 @@
|
||||
E411C29D241C123C008B9682 /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E4928E0A2218D62A001D4BEA /* CGColor.swift */,
|
||||
E408D3B5220DD8970006D9BE /* Notification.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
@ -932,7 +931,7 @@
|
||||
children = (
|
||||
E41222092431425400473C1D /* AlbumItemCell.swift */,
|
||||
E412220A2431425400473C1D /* AlbumViewController.swift */,
|
||||
E412220B2431425400473C1D /* AlbumDataSource.swift */,
|
||||
E412220B2431425400473C1D /* AlbumViewController+UICollectionViewDataSource.swift */,
|
||||
E412220C2431425400473C1D /* AlbumViewController+UICollectionViewDelegateFlowLayout.swift */,
|
||||
);
|
||||
path = "Album Browser";
|
||||
@ -949,7 +948,6 @@
|
||||
E41222262431539000473C1D /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E4928E0A2218D62A001D4BEA /* CGColor.swift */,
|
||||
E41222272431539800473C1D /* CGSize.swift */,
|
||||
E4C51F09243428B60093FB31 /* UIFont.swift */,
|
||||
);
|
||||
@ -1756,6 +1754,7 @@
|
||||
E4B11BB62275374B0075461B /* UserNotificationsController.swift in Sources */,
|
||||
E43AC1F622C6AD0B001E483C /* AlbumViewController+NSCollectionViewDelegate.swift in Sources */,
|
||||
E4B11B68226A4FA00075461B /* QueueState.swift in Sources */,
|
||||
E4928E0B2218D62A001D4BEA /* CGColor.swift in Sources */,
|
||||
E4D3BFA622B419C000C56F48 /* QueueViewController+NSOutlineViewDelegate.swift in Sources */,
|
||||
E4405192227644340090CD6F /* MPDServerController.swift in Sources */,
|
||||
E4805A102426D73600362CF3 /* tag.c in Sources */,
|
||||
@ -1887,7 +1886,6 @@
|
||||
E48059FC2426D73600362CF3 /* neighbor.c in Sources */,
|
||||
E4B11B6A226A4FBC0075461B /* AlbumListState.swift in Sources */,
|
||||
E4805A162426D73600362CF3 /* song.c in Sources */,
|
||||
E4B28EE224379606003B28AE /* CGColor.swift in Sources */,
|
||||
E41E5305223BFB0700173814 /* MPDClient+Error.swift in Sources */,
|
||||
E435E3E2221CD4E200184CFC /* NSFont.swift in Sources */,
|
||||
E4805A0C2426D73600362CF3 /* settings.c in Sources */,
|
||||
@ -2001,7 +1999,7 @@
|
||||
E4C51F0A243428B60093FB31 /* UIFont.swift in Sources */,
|
||||
E480511524255BAF00362CF3 /* DraggedSongType.swift in Sources */,
|
||||
E480512B24255BDF00362CF3 /* MPDAlbum.swift in Sources */,
|
||||
E412221A2431425400473C1D /* AlbumDataSource.swift in Sources */,
|
||||
E412221A2431425400473C1D /* AlbumViewController+UICollectionViewDataSource.swift in Sources */,
|
||||
E41222172431425400473C1D /* SceneDelegate.swift in Sources */,
|
||||
E48059DB2426D73600362CF3 /* entity.c in Sources */,
|
||||
E48051522425626300362CF3 /* MPDServerController.swift in Sources */,
|
||||
|
||||
@ -21,10 +21,8 @@ class MPDServerController {
|
||||
func connect() {
|
||||
let mpdServer = App.store.state.preferencesState.mpdServer
|
||||
|
||||
guard let host = mpdServer.hostOrDefault else { return }
|
||||
|
||||
App.mpdClient.connect(
|
||||
host: host,
|
||||
host: mpdServer.hostOrDefault,
|
||||
port: mpdServer.portOrDefault
|
||||
)
|
||||
}
|
||||
|
||||
@ -57,19 +57,18 @@ extension MPDClient {
|
||||
func albums(filter: String) {
|
||||
var albums: [MPDAlbum] = []
|
||||
|
||||
mpd_search_db_songs(connection, false)
|
||||
mpd_search_db_songs(self.connection, false)
|
||||
if filter != "" {
|
||||
mpd_search_add_expression(
|
||||
self.connection,
|
||||
"(any contains '\(filter)')"
|
||||
)
|
||||
}
|
||||
mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1")
|
||||
mpd_search_add_sort_tag(connection, MPD_TAG_ALBUM_ARTIST_SORT, false)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1")
|
||||
|
||||
mpd_search_commit(self.connection)
|
||||
|
||||
while let song = mpd_recv_song(connection) {
|
||||
while let song = mpd_recv_song(self.connection) {
|
||||
let mpdSong = MPDSong(song)
|
||||
|
||||
let mpdAlbum = MPDAlbum(
|
||||
@ -91,10 +90,10 @@ extension MPDClient {
|
||||
|
||||
var firstSong: MPDSong?
|
||||
|
||||
mpd_search_db_songs(connection, true)
|
||||
mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album.title)
|
||||
mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM_ARTIST, album.artist)
|
||||
mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1")
|
||||
mpd_search_db_songs(self.connection, true)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album.title)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM_ARTIST, album.artist)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1")
|
||||
|
||||
mpd_search_commit(self.connection)
|
||||
|
||||
|
||||
@ -7,17 +7,12 @@
|
||||
//
|
||||
|
||||
struct MPDServer {
|
||||
#if os(macOS)
|
||||
let hostDefault: String? = "127.0.0.1"
|
||||
#else
|
||||
let hostDefault: String? = nil
|
||||
#endif
|
||||
|
||||
let hostDefault = "127.0.0.1"
|
||||
let portDefault = 6600
|
||||
|
||||
var host: String?
|
||||
|
||||
var hostOrDefault: String? {
|
||||
var hostOrDefault: String {
|
||||
return host ?? hostDefault
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<view key="tableFooterView" contentMode="scaleToFill" id="sk8-CG-x2M" customClass="AlbumDetailFooterView" customModule="Persephone" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="666" width="414" height="49"/>
|
||||
<rect key="frame" x="0.0" y="666" width="414" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12 Songs" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CEd-uu-R5o">
|
||||
@ -175,9 +175,9 @@
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="CEd-uu-R5o" firstAttribute="top" secondItem="sk8-CG-x2M" secondAttribute="top" constant="11.5" id="1r3-Km-Fl0"/>
|
||||
<constraint firstAttribute="trailing" secondItem="CEd-uu-R5o" secondAttribute="trailing" constant="20" id="JIw-Za-a3F"/>
|
||||
<constraint firstItem="CEd-uu-R5o" firstAttribute="leading" secondItem="sk8-CG-x2M" secondAttribute="leading" constant="20" id="YqV-Mn-MfH"/>
|
||||
<constraint firstItem="CEd-uu-R5o" firstAttribute="centerY" secondItem="sk8-CG-x2M" secondAttribute="centerY" id="xvV-WL-Aiy"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<prototypes>
|
||||
@ -288,6 +288,7 @@
|
||||
<!--Albums-->
|
||||
<scene sceneID="fsq-t8-GDw">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Hvo-yX-dBI" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="9Vi-iO-P5G" sceneMemberID="viewController">
|
||||
<tabBarItem key="tabBarItem" title="Albums" image="square.grid.2x2.fill" catalog="system" id="neh-3P-aiC"/>
|
||||
<toolbarItems/>
|
||||
@ -300,7 +301,6 @@
|
||||
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="ZGc-1O-hMf"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Hvo-yX-dBI" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="905.79710144927549" y="138.61607142857142"/>
|
||||
</scene>
|
||||
|
||||
@ -8,17 +8,16 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class AlbumDataSource: NSObject, UICollectionViewDataSource {
|
||||
var albums: [Album] = []
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
extension AlbumViewController {
|
||||
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return albums.count
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let item = collectionView.dequeueReusableCell(withReuseIdentifier: "AlbumViewCell", for: indexPath)
|
||||
guard let albumViewCell = item as? AlbumItemCell else { return item }
|
||||
|
||||
//albumViewItem.view.wantsLayer = true
|
||||
albumViewCell.setAlbum(albums[indexPath.item])
|
||||
|
||||
return albumViewCell
|
||||
@ -10,7 +10,7 @@ import UIKit
|
||||
import ReSwift
|
||||
|
||||
class AlbumViewController: UICollectionViewController {
|
||||
let dataSource = AlbumDataSource()
|
||||
var albums: [Album] = []
|
||||
|
||||
let itemsPerRow: CGFloat = 2
|
||||
|
||||
@ -23,15 +23,14 @@ class AlbumViewController: UICollectionViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
albumCollectionView.dataSource = dataSource
|
||||
|
||||
App.store.subscribe(self) {
|
||||
$0.select { $0.albumListState }
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(didConnect), name: .didConnect, object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willDisconnect), name: .willDisconnect, object: nil)
|
||||
|
||||
title = "Albums"
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
}
|
||||
@ -40,6 +39,9 @@ class AlbumViewController: UICollectionViewController {
|
||||
App.mpdClient.fetchAllAlbums()
|
||||
}
|
||||
|
||||
@objc func willDisconnect() {
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
guard let detailView = segue.destination as? AlbumSongListViewController,
|
||||
let sender = sender as? AlbumItemCell
|
||||
@ -55,7 +57,7 @@ extension AlbumViewController: StoreSubscriber {
|
||||
typealias StoreSubscriberStateType = AlbumListState
|
||||
|
||||
func newState(state: StoreSubscriberStateType) {
|
||||
dataSource.albums = state.albums
|
||||
albums = state.albums
|
||||
|
||||
albumCollectionView.reloadData()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user