//
//  MeterInfoCardView.swift
//  USB Meter
//

import SwiftUI

struct MeterInfoCardView<Content: View>: View {
    let title: String
    let infoMessage: String?
    let tint: Color
    @ViewBuilder var content: Content

    init(
        title: String,
        infoMessage: String? = nil,
        tint: Color,
        @ViewBuilder content: () -> Content
    ) {
        self.title = title
        self.infoMessage = infoMessage
        self.tint = tint
        self.content = content()
    }

    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            HStack(spacing: 8) {
                Text(title)
                    .font(.headline)
                if let infoMessage {
                    ContextInfoButton(title: title, message: infoMessage)
                }
            }
            content
        }
        .frame(maxWidth: .infinity, alignment: .leading)
        .padding(18)
        .meterCard(tint: tint, fillOpacity: 0.18, strokeOpacity: 0.24)
    }
}
