Skip to content

Instantly share code, notes, and snippets.

@rudrankriyam
Created September 13, 2021 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudrankriyam/4ec5b06e81b22e2a6a1c4080eb0afcf1 to your computer and use it in GitHub Desktop.
Save rudrankriyam/4ec5b06e81b22e2a6a1c4080eb0afcf1 to your computer and use it in GitHub Desktop.
ShazamMusicCard
import SwiftUI
struct ShazamMusicCard: View {
var item: SHMediaItem
var body: some View {
HStack {
ArtworkImage(url: url) { image in
image
.scaledToFit()
.transition(.opacity.combined(with: .scale))
}
.cornerRadius(12.0)
.frame(width: 100.0, height: 100.0)
VStack(alignment: .leading, spacing: 4.0) {
Text(name)
.fontWeight(.bold)
.font(.callout)
Text(artistName)
.fontWeight(.light)
.font(.caption)
}
.foregroundColor(.white)
.frame(maxWidth: .infinity, alignment: .leading)
.multilineTextAlignment(.leading)
}
}
private var name: String {
item.title ?? ""
}
private var artistName: String {
item.artist ?? ""
}
private var url: URL? {
item.artworkURL
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment