import SwiftUI
import SFSafeSymbols

struct CareerStationView: View {

    @Environment(\.colorScheme)
    var colorScheme: ColorScheme
    
    let info: CareerStation

    let borderSpacing: CGFloat

    let borderWidth: CGFloat

    let accent: Color

    var body: some View {
        LeftBorderView(color: accent, spacing: borderSpacing, borderWidth: borderWidth) {
            VStack(alignment: .leading) {
                HStack {
                    RightImageLabel(info.time, systemSymbol: .calendar)
                    Spacer()
                    RightImageLabel(info.location, systemSymbol: .house)
                }
                .font(.caption)
                .foregroundColor(colorScheme.secondaryColor)
                Text(info.title)
                    .font(.headline)
                    .fontWeight(.regular)
                if let subtitle = info.subtitle {
                    Text(subtitle)
                        .font(.subheadline)
                        .foregroundColor(accent)
                }
                if let text = info.text {
                    Text(text)
                        .font(.caption)
                        .foregroundColor(colorScheme.secondaryColor)
                }
            }
        }
    }
}

struct CareerStationView_Previews: PreviewProvider {
    static var previews: some View {
        CareerStationView(
            info: .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."),
            borderSpacing: 5,
            borderWidth: 3,
            accent: .orange)
            .previewLayout(.fixed(width: 300, height: 100))
    }
}
