//
//  SongRowView.swift
//  Suno
//
//  Created by Martin Camacho on 3/15/24.
//

import Foundation
import SwiftUI


struct SongRowView: View {
    var item: Clip
    var isSelected: Bool

    
    var body: some View {
        HStack {
            // Image loading and display logic
            if let urlString = item.imageUrl, let imageUrl = URL(string: urlString) {
                AsyncImage(url: imageUrl) { image in
                    image.resizable()
                } placeholder: {
                    ProgressView() // Show a progress indicator while loading
                }
                .frame(width: 60, height: 60)
                .aspectRatio(contentMode: .fill)
                .clipped()
                .cornerRadius(10)
            }
            
            // Text display
            VStack(alignment: .leading)  {
                Text(item.title ?? "Untitled")
                    .foregroundStyle(isSelected ? Color.orange : Color.white)
                Text(item.metadata.tags ?? "no style")
                    .foregroundStyle(Color.gray)
            }
            
            Spacer()
        }
        
    }
}
