//
//  ForecastRow.swift
//  WeatherApp
//
//  Created by Azamat Tajiyev on 20.05.2025.
//

import SwiftUI

struct ForecastRow: View {
    let forecast: WeatherForecast

    var body: some View {
        VStack(alignment: .leading, spacing: 16) {
            HStack {
                VStack(alignment: .leading) {
                    Text(getWeekdayName(from: forecast.date))
                        .font(.headline)
                        .fontWeight(.semibold)
                    Text(forecast.conditionText)
                        .font(.caption)
                }

                Spacer()

                Text("\(forecast.avgTempC, specifier: "%.1f")°")
                    .font(.headline)
                    .fontWeight(.bold)

                AsyncImage(url: URL(string: forecast.conditionIconURL)) { image in
                    image.resizable()
                } placeholder: {
                    ProgressView()
                }
                .frame(width: 40, height: 40)
            }

            HStack {
                Text("💨 \(forecast.maxWindKph, specifier: "%.1f") km/h")
                    .font(.subheadline)
                    .fontWeight(.semibold)
                Text("💧 \(forecast.avgHumidity, specifier: "%.0f")%")
                    .font(.subheadline)
                    .fontWeight(.semibold)
            }
        }
        .padding(.vertical, 8)
    }
}
