import SwiftUI

struct TitledCareerSection: View {

    let style: CVStyle.Section

    let accent: Color

    let content: Titled<CareerStation>

    var body: some View {
        TitledSection(title: content.title, spacing: style.titleSpacing) {
            ForEach(content.items) { item in
                CareerStationView(
                    info: item,
                    borderSpacing: style.borderSpacing,
                    borderWidth: style.borderWidth,
                    accent: accent)
                .padding(.bottom, style.bottomSpacing)
            }
        }
    }
}

struct TitledItemSection_Previews: PreviewProvider {
    static var previews: some View {
        TitledCareerSection(
            style: .init(),
            accent: .orange,
            content: .init(
                title: "Work experience",
                items: [
                    .init(
                        time: "Jul 2020 - Jul 2023",
                        location: "Braunschweig, Germany",
                        title: "German Aerospace Center",
                        subtitle: "Systems engineer",
                        text: "Responsible for aircraft systems and avionics of a high-altitude solar drone, safety, and software."),
                    .init(
                        time: "Jul 2020 - Jul 2023",
                        location: "Braunschweig, Germany",
                        title: "German Aerospace Center",
                        subtitle: "Systems engineer",
                        text: "Responsible for aircraft systems and avionics of a high-altitude solar drone, safety, and software.")
                ])
        )
        .previewLayout(.fixed(width: 350, height: 400))
    }
}
