oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1import SwiftUI
2
3struct NeedsTaskRow: View {
4 let session: EquipoSession
5 let task: ThinTask
6 var open: () -> Void
7 @State private var model: TaskDetailModel
8 init(session: EquipoSession, task: ThinTask, open: @escaping () -> Void) {
9 self.session = session; self.task = task; self.open = open
10 _model = State(initialValue: TaskDetailModel(session: session, taskID: task.id))
11 }
12 var body: some View {
13 @Bindable var model = model
14 let action = model.needsAction
15 VStack(alignment: .leading, spacing: 8) {
16 if action.isAside, let card = action.card {
17 AsideStub(card: card, title: Feed.asideTitle(card, task: task), session: session)
18 } else if action.kind == .question, let card = action.card {
19 LiveQuestionCard(card: card, task: task, session: session, openTask: open)
20 } else {
21 Panel(padding: 14, spacing: 10) {
22 HStack(alignment: .top) {
23 TaskRowButton(task: task, needsYou: true, showsNeedsBadge: false, action: open)
24 if action.canSetAside {
25 SetAsideButton(busy: model.busy) { Task { await model.setNeedsAside() } }
26 }
27 }
28 if let pause = TaskReport(task, needsYou: true, mine: session.isMine(task)).pause {
29 PauseLead(pause: pause)
30 }
31 RosterButton(title: action.title, primary: true, expanded: true) {
32 if action.kind == .open { open() }
33 else { Task { await model.performNeedsAction(action) } }
34 }.disabled(model.busy).accessibilityIdentifier("needs-action-" + task.id)
35 if let note = action.pause?.note, action.kind == .runNow {
36 Text(note).font(Typo.secondary).foregroundStyle(Palette.secondary)
37 }
38 if let failure = model.failure ?? model.readFailure {
39 Text(failure).font(Typo.secondary).foregroundStyle(Palette.negative).fixedSize(horizontal: false, vertical: true)
40 }
41 if model.busy { ProgressView(EquipoStrings.text("action.sending")) }
42 }
43 }
44 }
45 .task(id: model.needsReadKey) { await model.loadNeedsRow() }
46 .sheet(item: $model.confirmation) { TaskConfirmationSheet(model: model, confirmation: $0) }
47 }
48}
49
50extension NeedsRowAction {
51 var title: String {
52 switch kind {
53 case .open: EquipoStrings.text("work.open")
54 case .question: EquipoStrings.text("chat.card.answer")
55 case .merge: EquipoStrings.text("chat.card.merge")
56 case .retry: EquipoStrings.text("work.pause.try_again")
57 case .resume: EquipoStrings.text("work.hold.resume")
58 case .runNow: pause?.runNow?.label ?? EquipoStrings.text("chat.card.run_now")
59 }
60 }
61}
62