mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
No commits in common. "23e5860ce89a8ad64797da9a39f1d8305a2ae1bd" and "d9caf538eea02dd96ec4723c2ad1b753e52d93ed" have entirely different histories.
23e5860ce8
...
d9caf538ee
@ -293,7 +293,6 @@
|
||||
E4B11BBE2275EDAA0075461B /* PlayerActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4B11BBD2275EDAA0075461B /* PlayerActions.swift */; };
|
||||
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 */; };
|
||||
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 */; };
|
||||
@ -653,7 +652,6 @@
|
||||
E4B11BBD2275EDAA0075461B /* PlayerActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerActions.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@ -961,7 +959,6 @@
|
||||
E4B3B3622432DA4B007E25D2 /* AlbumSongCell.swift */,
|
||||
E4B3B3652432DEDB007E25D2 /* AlbumSongListViewController.swift */,
|
||||
E412222F2432B0A300473C1D /* AlbumTracksDataSource.swift */,
|
||||
E4B28EDE2436D548003B28AE /* AlbumDetailFooterView.swift */,
|
||||
);
|
||||
path = "Album Detail";
|
||||
sourceTree = "<group>";
|
||||
@ -1939,7 +1936,6 @@
|
||||
E4805A292426D73600362CF3 /* player.c in Sources */,
|
||||
E480514724255E7700362CF3 /* ServerReducer.swift in Sources */,
|
||||
E480514E24255E7D00362CF3 /* UIActions.swift in Sources */,
|
||||
E4B28EE02436D56E003B28AE /* AlbumDetailFooterView.swift in Sources */,
|
||||
E480513C24255E7200362CF3 /* AppState.swift in Sources */,
|
||||
E480514024255E7200362CF3 /* ServerState.swift in Sources */,
|
||||
E480514224255E7700362CF3 /* AlbumListReducer.swift in Sources */,
|
||||
|
||||
@ -35,21 +35,19 @@ extension MPDClient {
|
||||
|
||||
self.delegate?.willDisconnect(mpdClient: self)
|
||||
|
||||
mpd_connection_free(self.connection)
|
||||
self.isConnected = false
|
||||
mpd_connection_free(self.connection)
|
||||
self.isConnected = false
|
||||
}
|
||||
|
||||
func connect(host: String, port: Int) {
|
||||
if !isConnected {
|
||||
let commandOperation = BlockOperation() { [unowned self] in
|
||||
self.sendCommand(command: .connect, userData: ["host": host, "port": port])
|
||||
let commandOperation = BlockOperation() { [unowned self] in
|
||||
self.sendCommand(command: .connect, userData: ["host": host, "port": port])
|
||||
|
||||
if self.isConnected {
|
||||
self.idle()
|
||||
}
|
||||
if self.isConnected {
|
||||
self.idle()
|
||||
}
|
||||
commandQueue.addOperation(commandOperation)
|
||||
}
|
||||
commandQueue.addOperation(commandOperation)
|
||||
}
|
||||
|
||||
func disconnect() {
|
||||
|
||||
@ -25,8 +25,4 @@ struct Time {
|
||||
|
||||
return formatter.string(from: TimeInterval(timeInSeconds))!
|
||||
}
|
||||
|
||||
var hours: Int { timeInSeconds / 3600 }
|
||||
|
||||
var minutes: Int { timeInSeconds % 3600 / 60 }
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import ReSwift
|
||||
struct App {
|
||||
static let store = Store<AppState>(reducer: appReducer, state: nil)
|
||||
static let trackTimer = TrackTimer()
|
||||
//static let userNotificationsController = UserNotificationsController()
|
||||
static let mpdServerDelegate = MPDServerDelegate()
|
||||
static let mpdServerController = MPDServerController(delegate: mpdServerDelegate)
|
||||
static var mpdClient: MPDClient!
|
||||
|
||||
@ -88,7 +88,6 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<inset key="separatorInset" minX="20" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
<view key="tableHeaderView" contentMode="scaleToFill" id="4dR-vb-lQN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="523"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
@ -162,24 +161,6 @@
|
||||
<constraint firstAttribute="trailing" secondItem="LH5-iT-vfZ" secondAttribute="trailing" constant="20" id="zBC-6u-CKb"/>
|
||||
</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="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">
|
||||
<rect key="frame" x="20" y="11.5" width="374" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<constraints>
|
||||
<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>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="albumDiscCell" id="Cgr-Ay-PN6" customClass="AlbumDiscCell" customModule="Persephone" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="551" width="414" height="43.5"/>
|
||||
@ -260,7 +241,6 @@
|
||||
<outlet property="albumTitle" destination="EZF-hY-Nqr" id="MNF-am-Xam"/>
|
||||
<outlet property="albumTracksView" destination="bb3-Ec-blb" id="dR9-t7-87f"/>
|
||||
<outlet property="playAlbumButton" destination="5gg-Nm-qeI" id="Muh-gW-Ezy"/>
|
||||
<outlet property="songListMetadata" destination="CEd-uu-R5o" id="Tsz-GR-LX9"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="WIp-Eo-GAy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
@ -288,7 +268,6 @@
|
||||
<!--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/>
|
||||
@ -301,6 +280,7 @@
|
||||
<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>
|
||||
|
||||
@ -40,6 +40,9 @@ class AlbumViewController: UICollectionViewController {
|
||||
}
|
||||
|
||||
@objc func willDisconnect() {
|
||||
DispatchQueue.main.async {
|
||||
App.store.dispatch(UpdateAlbumListAction(albums: []))
|
||||
}
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
//
|
||||
// AlbumDetailFooterView.swift
|
||||
// Persephone
|
||||
//
|
||||
// Created by Daniel Barber on 2020-4-2.
|
||||
// Copyright © 2020 Dan Barber. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class AlbumDetailFooterView: UIView {
|
||||
override func didMoveToSuperview() {
|
||||
super.didMoveToSuperview()
|
||||
|
||||
let separator = CALayer()
|
||||
separator.frame = CGRect(
|
||||
x: 20,
|
||||
y: -0.5,
|
||||
width: UIScreen.main.bounds.width - 20,
|
||||
height: 0.5
|
||||
)
|
||||
separator.backgroundColor = UIColor.separator.cgColor
|
||||
layer.addSublayer(separator)
|
||||
}
|
||||
}
|
||||
@ -66,16 +66,9 @@ class AlbumSongListViewController: UITableViewController {
|
||||
guard let self = self else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
var totalDurationInSeconds = 0
|
||||
|
||||
self.dataSource.setAlbumSongs(
|
||||
mpdSongs.map {
|
||||
totalDurationInSeconds += $0.duration
|
||||
return Song(mpdSong: $0)
|
||||
}
|
||||
mpdSongs.map { Song(mpdSong: $0) }
|
||||
)
|
||||
|
||||
let totalDuration = Time(timeInSeconds: totalDurationInSeconds)
|
||||
|
||||
self.albumTracksView.reloadData()
|
||||
|
||||
@ -83,16 +76,6 @@ class AlbumSongListViewController: UITableViewController {
|
||||
else { return }
|
||||
|
||||
self.getBigCoverArt(song: Song(mpdSong: mpdSong), album: album)
|
||||
|
||||
var metadata = "\(mpdSongs.count) song"
|
||||
metadata += mpdSongs.count > 1 ? "s," : ","
|
||||
if totalDuration.hours > 0 {
|
||||
metadata += " \(totalDuration.hours) hour"
|
||||
metadata += totalDuration.hours > 1 ? "s" : ""
|
||||
}
|
||||
metadata += " \(totalDuration.minutes) minute"
|
||||
metadata += totalDuration.minutes > 1 ? "s" : ""
|
||||
self.songListMetadata.text = metadata
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,8 +116,6 @@ class AlbumSongListViewController: UITableViewController {
|
||||
App.mpdClient.addAlbumToQueue(album: album.mpdAlbum, at: queueLength)
|
||||
}
|
||||
|
||||
@IBOutlet var songListMetadata: UILabel!
|
||||
|
||||
@IBOutlet var addAlbumToQueueButton: UIButton!
|
||||
@IBOutlet var playAlbumButton: UIButton!
|
||||
@IBOutlet var albumTitle: UILabel!
|
||||
|
||||
@ -29,13 +29,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
App.mpdServerController.disconnect()
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
App.mpdServerController.connect()
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user