field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

TeraRevisionDetailView.swift (3121B)


      1 import SwiftUI
      2 
      3 struct TeraRevisionDetailView: View {
      4   @ObservedObject var store: TeraRevisionDetailStore
      5   let operationID: String
      6 
      7   var body: some View {
      8     List {
      9       if store.isWorking {
     10         ProgressView("Loading current revision…")
     11       }
     12       if let message = store.message {
     13         Text(message)
     14       }
     15       if let status = store.status {
     16         Section("Revision") {
     17           Text(status.honestSummary).accessibilityIdentifier("tera.revision.summary")
     18           Text("Each relay acts independently. Stopping local work cannot undo accepted or uncertain effects. Retraction is a deletion request, not proof of erasure.")
     19             .font(.footnote)
     20           if let original = status.original {
     21             LabeledContent("Original event", value: original.sourceEventID)
     22               .textSelection(.enabled)
     23             if let address = original.sourceAddress {
     24               LabeledContent("Original address", value: address).textSelection(.enabled)
     25             }
     26           }
     27         }
     28         branch("Replacement", draft: status.replacement, progress: status.replacementProgress)
     29         if let child = status.retraction, let progress = status.retractionProgress {
     30           branch("Retraction request", draft: child, progress: progress)
     31         } else if status.policy == .replaceThenRetract {
     32           Section("Retraction request") {
     33             Text("No retraction child is saved yet. Eligible saved relay evidence is required before it can proceed.")
     34           }
     35         }
     36         Section("Local actions") {
     37           if status.canResume {
     38             Button("Resume saved revision") { Task { await store.resume() } }
     39               .accessibilityIdentifier("tera.revision.resume")
     40           }
     41           if status.canCancel {
     42             Button("Stop pending revision work", role: .destructive) { Task { await store.cancel() } }
     43               .accessibilityIdentifier("tera.revision.stop")
     44           }
     45           if !status.canResume {
     46             Text("No delivery can resume now. Refresh to check current permissions. Work that needs attention or has been stopped is not retried automatically.")
     47               .font(.footnote)
     48           }
     49         }
     50       }
     51       Button("Refresh current details") { Task { await store.load(operationID) } }
     52     }
     53     .disabled(store.isWorking)
     54     .navigationTitle("Revision details")
     55     .task(id: operationID) { await store.load(operationID) }
     56     .onDisappear { store.stop() }
     57     .accessibilityIdentifier("tera.revision.details")
     58   }
     59 
     60   private func branch(_ title: String, draft: TeraDraftStatus, progress: TeraRevisionBranchStatus) -> some View {
     61     Section(title) {
     62       LabeledContent("Saved operation", value: draft.id).textSelection(.enabled)
     63       Text(draft.state.summary(settlement: draft.settlement))
     64       if progress.stopped {
     65         Text("Further local work is stopped; retained relay evidence remains visible.")
     66       }
     67       if let details = progress.targets {
     68         TeraPublicationTargetsView(details: details)
     69       } else {
     70         Text("No frozen relay delivery record is available yet.").font(.footnote)
     71       }
     72     }
     73   }
     74 }