Add artist pages
This commit is contained in:
1 parent
7ce0827c9a
commit
20a0048749
4 files changed
+395
-18
No files matched your search
@@ -227,12 +227,7 @@ struct AlbumDetailView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
if !artistNames(for: album.artists).isEmpty {
|
||||
Text(artistNames(for: album.artists))
|
||||
.font(.title3)
|
||||
.foregroundStyle(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
artistLinks(for: album.artists)
|
||||
|
||||
Text(albumMetadata(for: album))
|
||||
.font(.subheadline.weight(.semibold))
|
||||
@@ -291,12 +286,30 @@ struct AlbumDetailView: View {
|
||||
return [genre, songCount].compactMap { $0 }.joined(separator: " · ")
|
||||
}
|
||||
|
||||
private func artistNames(for artists: [APIReference<Artist>]) -> String {
|
||||
artists.compactMap { reference in
|
||||
@ViewBuilder
|
||||
private func artistLinks(for references: [APIReference<Artist>]) -> some View {
|
||||
let artists = references.compactMap { reference -> Artist? in
|
||||
guard case .value(let artist) = reference else { return nil }
|
||||
return artist.name
|
||||
return artist
|
||||
}
|
||||
|
||||
if !artists.isEmpty {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(artists) { artist in
|
||||
NavigationLink(artist.name) {
|
||||
ArtistDetailView(artistID: artist.id)
|
||||
}
|
||||
.font(.title3)
|
||||
.foregroundStyle(.secondary)
|
||||
if artist.id != artists.last?.id {
|
||||
Text(",")
|
||||
.font(.title3)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.joined(separator: ", ")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user