mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Add song list footer with song count and total duration
This commit is contained in:
parent
71f2545972
commit
dc7c372a73
@ -294,6 +294,7 @@
|
||||
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 */; };
|
||||
@ -654,6 +655,7 @@
|
||||
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,6 +963,7 @@
|
||||
E4B3B3622432DA4B007E25D2 /* AlbumSongCell.swift */,
|
||||
E4B3B3652432DEDB007E25D2 /* AlbumSongListViewController.swift */,
|
||||
E412222F2432B0A300473C1D /* AlbumTracksDataSource.swift */,
|
||||
E4B28EDE2436D548003B28AE /* AlbumDetailFooterView.swift */,
|
||||
);
|
||||
path = "Album Detail";
|
||||
sourceTree = "<group>";
|
||||
@ -1940,6 +1943,7 @@
|
||||
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 */,
|
||||
|
||||
@ -25,4 +25,8 @@ struct Time {
|
||||
|
||||
return formatter.string(from: TimeInterval(timeInSeconds))!
|
||||
}
|
||||
|
||||
var hours: Int { timeInSeconds / 3600 }
|
||||
|
||||
var minutes: Int { timeInSeconds % 3600 / 60 }
|
||||
}
|
||||
|
||||
@ -88,6 +88,7 @@
|
||||
<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"/>
|
||||
@ -161,6 +162,24 @@
|
||||
<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"/>
|
||||
@ -241,6 +260,7 @@
|
||||
<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"/>
|
||||
@ -268,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/>
|
||||
@ -280,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>
|
||||
|
||||
@ -6,4 +6,20 @@
|
||||
// Copyright © 2020 Dan Barber. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
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,9 +66,16 @@ class AlbumSongListViewController: UITableViewController {
|
||||
guard let self = self else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
var totalDurationInSeconds = 0
|
||||
|
||||
self.dataSource.setAlbumSongs(
|
||||
mpdSongs.map { Song(mpdSong: $0) }
|
||||
mpdSongs.map {
|
||||
totalDurationInSeconds += $0.duration
|
||||
return Song(mpdSong: $0)
|
||||
}
|
||||
)
|
||||
|
||||
let totalDuration = Time(timeInSeconds: totalDurationInSeconds)
|
||||
|
||||
self.albumTracksView.reloadData()
|
||||
|
||||
@ -76,6 +83,16 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,6 +133,8 @@ 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!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user