// A GROUP OR A PLACE (mail.html "A machine group"; the side page's Drafts, Sent, Archived and Bin; the whole Inbox; and// Mail's own list under its chips, owner 26 Nov 2026):// Back to Inbox, its title and its counted line; why its mail is here, linked to the rules; its rows, newest first,// with the same swipes and long press as the home; and at the foot the two buttons that carry their counts, "Mark 17// read" and "Archive 214", Archive in one tap with the exact count (owner, 25 Nov 2026). The after-state stands on the// page until he leaves it. `mail.list {place, account?, after?}`.#if os(iOS)importCottonKitimportSwiftUIstructPostListScreen: View {let model: PostModellet place: Stringvar body: someView { VStack(spacing: 0) {PostBar(back: PostWords.line("home.title"), onBack: { model.pop() }).padding(.horizontal, PostInk.side)PostListBody(model: model, place: place, titled: true) { EmptyView() } } .background(PostInk.ground) .accessibilityIdentifier("post-list-\(place)") }}/// A place's list, newest first, paged as the last row comes into view, with the bulk buttons at its foot: the whole/// of a group's or a place's screen, and Mail's own list under its chips (`header` stands above it in the scroll).structPostListBody<Header: View>: View {let model: PostModellet place: String/// The place's own title above its line (a pushed place); Mail draws its own.var titled: Bool/// When Mail has nothing to list at all (no account yet), its own empty line instead of the place's.var empty: String? = nilvar first: PostFirstSync? = nil @ViewBuilder var header: () -> Header @State privatevar list: PostRead<PostList>? @State privatevar more: [PostRow] = [] @State privatevar next: String? @State privatevar after: PostAfter? @Environment(\.dynamicTypeSize) privatevar typevar body: someView { VStack(spacing: 0) {ScrollView {LazyVStack(alignment: .leading, spacing: 0) { header()if titled { PostTitle(text: list?.answer?.title ?? "") }iflet line = list?.answer?.line { PostLead(text: line) }iflet bin = list?.answer?.bin { PostNote(text: bin.line) }PostAfterView(model: model, after: $after).padding(.top, 8)switch list {case .read(let list)?:let rows = list.rows + moreif rows.isEmpty, let line = empty ?? list.empty {PostEmpty(line: line, franked: place == "inbox", first: first ?? list.firstSync) }ForEach(Array(rows.enumerated()), id: \.element.id) { index, row inPostMailRow(model: model, row: row, last: index == rows.count - 1, after: $after) .onAppear { if index == rows.count - 1 { Task { await page() } } } }iflet why = list.why { HStack(alignment: .firstTextBaseline, spacing: 4) {Text(why.line).font(PostType.small).foregroundStyle(PostInk.quiet).fixedSize(horizontal: false, vertical: true) } .padding(.top, 14)PostWordButton(label: why.rules, id: "post-list-rules") { model.tab = .you; model.paths[.you] = [.rules] } }case .refused(let line)?: PostRefused(line: line)casenil: EmptyView() } } .padding(.horizontal, PostInk.side) .padding(.bottom, 24) } .refreshable { model.changed() }iflet bulk = list?.answer?.bulk, !bulk.isEmpty {// Side by side, or one over the other when the words would not fit.AnyLayout(type.isAccessibilitySize ? AnyLayout(VStackLayout(spacing: 10)) : AnyLayout(HStackLayout(spacing: 10))) {ForEach(bulk) { act inPostButton(label: act.label, weight: act.act == "archive" ? .go : .quiet, id: "post-bulk-\(act.act)") {Task { await run(act) } } .disabled(act.count == 0) .opacity(act.count == 0 ? 0.45 : 1) } } .padding(.horizontal, PostInk.side) .padding(.vertical, 12) } } .task(id: "\(model.generation)/\(model.account ?? "")/\(place)") {var request: [String: JSONValue] = ["place": .string(place)] request.merge(model.accountRequest) { a, _ in a }let read = await model.read("mail.list", request, as: PostList.self) list = read more = [] next = read.answer?.after } .onChange(of: place) { _, _ in after = nil } }/// The next page, as the last row comes into view.privatefunc page() async {guardlet cursor = next else { return } next = nilvar request: [String: JSONValue] = ["place": .string(place), "after": .string(cursor)] request.merge(model.accountRequest) { a, _ in a }ifcase .read(let page) = await model.read("mail.list", request, as: PostList.self) { more += page.rows next = page.after } }/// A group's bulk act: Archive every mail of the group in the Inbox now, in one tap; Mark read the unread shown.privatefunc run(_ act: PostList.Bulk) async {let done: PostRead<PostAfter>switch act.act {case"archive": done = await model.archive(scope: "group", key: place.hasPrefix("group:") ? String(place.dropFirst(6)) : place)default:let unread = ((list?.answer?.rows ?? []) + more).filter(\.unread).compactMap(\.email) done = await model.act(act.act, emails: unread) }switch done {case .read(let answer): after = answercase .refused(let line): after = PostAfter(after: "refused", line: line) } }}extensionPostAfter {/// A refusal said where the after-state stands, with nothing to undo.init(after: String, line: String) {self.after = afterself.line = line }}#endif