TrackRow.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import SwiftUI
  2. /// Compact track row for track lists.
  3. struct TrackRow: View {
  4. let track: Track
  5. var body: some View {
  6. HStack(spacing: 8) {
  7. // Album art placeholder / format badge
  8. ZStack {
  9. RoundedRectangle(cornerRadius: 4)
  10. .fill(trackColor.opacity(0.15))
  11. .frame(width: 32, height: 32)
  12. Image(systemName: "music.note")
  13. .font(.caption)
  14. .foregroundStyle(trackColor)
  15. }
  16. VStack(alignment: .leading, spacing: 1) {
  17. HStack(spacing: 4) {
  18. Text(track.title)
  19. .lineLimit(1)
  20. .font(.body)
  21. if track.isCloud {
  22. Image(systemName: "cloud.fill")
  23. .font(.system(size: 8))
  24. .foregroundStyle(.secondary)
  25. }
  26. }
  27. if !track.artist.isEmpty {
  28. Text(track.artist)
  29. .lineLimit(1)
  30. .font(.caption)
  31. .foregroundStyle(.secondary)
  32. }
  33. }
  34. }
  35. }
  36. private var trackColor: Color {
  37. if let hex = track.color {
  38. return Color(hex: hex) ?? .accentColor
  39. }
  40. return .accentColor
  41. }
  42. }