// `/rejected`, drawn once for both hosts.//// One screen, no platform branch: the phone pushes it from the join sheet's// merge report and from Settings › Devices, and the Mac's settings column// renders this same view over its own served file. `ScreenPlatformSweepTests`// holds that.//// The reason on each row is the CORE's sentence and is drawn exactly as given.// Nothing here writes prose about somebody's failed write.importCottonKitimportSwiftUIpublicstructRejectedScreen: View { @Bindable privatevar model: RejectedModel @Environment(\.cottonHaptics) privatevar hapticspublicinit(model: RejectedModel) {self.model = model }publicvar body: someView {PaperScreen(title: ShellLines.line("devices", "writes_that_did_not")) {// A settings page is a form, and a form has a measure — see// `Platform/SettingsFormWidth.swift`. VStack(alignment: .leading, spacing: 0) {iflet refusal = model.refusal, model.rows.isEmpty {ObjectEmpty( sheet: .cream, line1: ShellLines.line("devices", "this_list_could_not"), line2: refusal, actionLabel: CottonStrings.tryAgain, action: { Task { await model.load() } } ) .accessibilityIdentifier("rejected-unreadable") } elseif model.isFirstRead {SkeletonText(lines: 3, lastLineWidth: 0.5, lineWidth: 0.8, lineHeight: 16) .accessibilityIdentifier("rejected-skeleton") } elseif model.rows.isEmpty {ObjectEmpty( sheet: .cream, line1: ShellLines.line("devices", "everything_synced"), line2: ShellLines.line("devices", "no_write_has_been") ) .accessibilityIdentifier("rejected-empty") } else { list } } .settingsFormWidth() } .refreshable { await model.load() } .task { await model.load() } } @ViewBuilder privatevar list: someView {if !model.rows.isEmpty { parked } } @ViewBuilder privatevar parked: someView {PaperSection(title: ShellLines.line("devices", "parked_here"), count: String(model.rows.count)) VStack(spacing: 12) {ForEach(model.rows) { row inRejectedRow(row: row) } } .accessibilityIdentifier("rejected-rows")// The verb. Below the list, because it acts on all of it. VStack(alignment: .leading, spacing: 6) {PaperTypedButton(ShellLines.line("devices", "retry_all")) { haptics.warning()Task { await model.retryAll() } } .disabled(model.isBusy) .accessibilityIdentifier("rejected-retry-all")if !model.everyRowCanBeRetried {// Said before the tap rather than discovered after it: a write// this device SENT was turned away by the server, and no retry// on this side can change that verdict.Text(RejectedScreen.retryLimit(retryable: model.retryableCount, total: model.rows.count)) .paperMeta(12) .accessibilityIdentifier("rejected-retry-limit") } } .padding(.top, 16) }/// What `Retry all` can actually move, when it is not all of it.staticfunc retryLimit(retryable: Int, total: Int) -> String {let stuck = total - retryablereturnShellLines.line("devices", stuck == 1 ? "rejected.retry_limit.one" : "rejected.retry_limit.many", ["n": "\(stuck)"]) }}/// One parked write.privatestructRejectedRow: View {let row: RejectedModel.Rowvar body: someView { VStack(alignment: .leading, spacing: 4) {Text(row.table).paperBody(15)Text(row.reason).paperRed(13)Text("\(row.direction) · \(row.stuckSince)").paperMeta(12) } .frame(maxWidth: .infinity, alignment: .leading) .accessibilityIdentifier("rejected-row") }}