Add artist pages
This commit is contained in:
1 parent
7ce0827c9a
commit
20a0048749
4 files changed
+395
-18
No files matched your search
@@ -3,18 +3,47 @@ import SwiftUI
|
||||
struct TrackRowView: View {
|
||||
let track: Track
|
||||
let index: Int
|
||||
var onPlay: (() -> Void)? = nil
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 14) {
|
||||
Text("\(index + 1)")
|
||||
.font(.body.monospacedDigit())
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(width: 28, alignment: .trailing)
|
||||
if let onPlay {
|
||||
Button(action: onPlay) {
|
||||
Image(systemName: "play.fill")
|
||||
.font(.caption.weight(.semibold))
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(width: 28, height: 44)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel("Play \(track.name)")
|
||||
} else {
|
||||
Text("\(index + 1)")
|
||||
.font(.body.monospacedDigit())
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(width: 28, alignment: .trailing)
|
||||
}
|
||||
|
||||
Text(track.name)
|
||||
.font(.body)
|
||||
.foregroundStyle(.primary)
|
||||
.lineLimit(1)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(track.name)
|
||||
.font(.body)
|
||||
.foregroundStyle(.primary)
|
||||
.lineLimit(1)
|
||||
if !artists.isEmpty {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(artists) { artist in
|
||||
NavigationLink(artist.name) {
|
||||
ArtistDetailView(artistID: artist.id)
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
if artist.id != artists.last?.id {
|
||||
Text(",").font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(minLength: 8)
|
||||
|
||||
@@ -28,6 +57,13 @@ struct TrackRowView: View {
|
||||
.contentShape(Rectangle())
|
||||
.accessibilityElement(children: .combine)
|
||||
}
|
||||
|
||||
private var artists: [Artist] {
|
||||
track.artists.compactMap { reference in
|
||||
guard case .value(let artist) = reference else { return nil }
|
||||
return artist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TrackRowView_Previews: PreviewProvider {
|
||||
|
||||
Reference in new issue
Block a user