// Ported from the r7 mockups (Components.swift). import SwiftUI struct Hairline: View { var body: some View { Rectangle().fill(Palette.border).frame(height: 1) } } struct StepMark: View { let state: String let needsYou: Bool var body: some View { ZStack { switch state { case "done": Image(systemName: "checkmark.circle.fill").resizable().foregroundStyle(Palette.positive) case "failed": Image(systemName: "exclamationmark.circle.fill").resizable().foregroundStyle(Palette.negative) case "waiting": Image(systemName: needsYou ? "hand.raised.circle.fill" : "pause.circle.fill").resizable() .foregroundStyle(Palette.warning) case "running": Circle().strokeBorder(Palette.positive, lineWidth: 2) Circle().fill(Palette.positive).padding(6) default: Circle().strokeBorder(Palette.controlBorder, style: StrokeStyle(lineWidth: 1.5, dash: [3, 3])) } }.frame(width: 22, height: 22) } } /// The task's steps as a connected timeline, in plan order: who ran, how /// it went, and the step's own headline. struct StepsView: View { let task: ThinTask var client: EquipoClient? var body: some View { let steps = task.steps ?? [] VStack(alignment: .leading, spacing: 0) { ForEach(Array(steps.enumerated()), id: \.element.id) { index, step in let last = index == steps.count - 1 HStack(alignment: .top, spacing: 12) { VStack(spacing: 4) { StepMark(state: step.state, needsYou: false).accessibilityHidden(true) if !last { Capsule().fill(step.state == "done" ? Palette.positive.opacity(0.55) : Palette.border) .frame(width: 2).frame(maxHeight: .infinity) } }.padding(.bottom, last ? 0 : 4) VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) { HStack(alignment: .firstTextBaseline) { SpecialistLabel(category: step.who, tone: step.state == "queued" ? Palette.secondary : Palette.text) Spacer(minLength: 8) Text(Self.label(step.state)).font(Typo.caption) .foregroundStyle(step.state == "failed" ? Palette.negative : step.state == "done" ? Palette.positive : Palette.secondary) } let line = step.headline.isEmpty ? step.summary : step.headline if !line.isEmpty { Text(line).font(Typo.secondary) .foregroundStyle(step.state == "queued" ? Palette.secondary : Palette.text) .fixedSize(horizontal: false, vertical: true) } if let finished = step.finishedAt { Text(finished.formatted(date: .abbreviated, time: .shortened)).font(Typo.caption).foregroundStyle(Palette.faint) } }.accessibilityElement(children: .combine) if step.state == "failed", let client { StepLogView(stepID: step.id, client: client) } }.padding(.bottom, last ? 0 : 20) }.fixedSize(horizontal: false, vertical: true) .accessibilityElement(children: .contain) } } } static func label(_ state: String) -> String { switch state { case "done": return String(localized: "step.done", bundle: .module) case "running": return String(localized: "step.running", bundle: .module) case "failed": return String(localized: "step.failed", bundle: .module) case "cancelled": return String(localized: "step.cancelled", bundle: .module) default: return String(localized: "step.queued", bundle: .module) } } } /// The app's own mark (estilo's Equipo icon, the chat bubble with two /// sparkles), as the web shows it. struct AppGlyph: View { var size: CGFloat = 38 var body: some View { Image("AppMark", bundle: .module).resizable().interpolation(.high) .frame(width: size, height: size) .accessibilityHidden(true) } } struct StatTile: View { let label: String let value: String var body: some View { VStack(alignment: .leading, spacing: 4) { Text(value).font(Typo.stat).monospacedDigit().foregroundStyle(Palette.text) Text(label).font(Typo.caption).foregroundStyle(Palette.secondary) } .frame(maxWidth: .infinity, alignment: .leading) .padding(Metric.cardPadding - 2) .background(Palette.surface, in: RoundedRectangle(cornerRadius: Metric.card, style: .continuous)) .overlay(RoundedRectangle(cornerRadius: Metric.card, style: .continuous).strokeBorder(Palette.border, lineWidth: 1)) .accessibilityElement(children: .combine) } }