177 lines
6.7 KiB
Swift
177 lines
6.7 KiB
Swift
//
|
|
// ArchivePaneView.swift
|
|
// Museion
|
|
//
|
|
// #193: the #108 Archive pane, moved from WorkspaceView.swift
|
|
// (file-length ceiling), code unchanged (private → internal:
|
|
// WorkspaceView instantiates it cross-file now).
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// #108: the Archive pane — archive/ as a rail destination (prototype
|
|
/// verdict: a destination, not a library disclosure). List-only: clicking a
|
|
/// piece selects it and hops to Posts, where the editor column lives.
|
|
struct ArchivePaneView: View {
|
|
var model: PostsModel
|
|
/// Fired after a row select — the pane can't reach WorkspaceView's
|
|
/// selection itself.
|
|
let onOpenPiece: () -> Void
|
|
@State private var renamingPost: Post?
|
|
/// #108: collapsed project sections — per-view state, not persisted
|
|
/// (mirrors the library column).
|
|
@State private var collapsed: Set<String> = []
|
|
|
|
private var archivedByProject: [String: [Post]] {
|
|
Dictionary(grouping: model.posts.filter(\.isArchived), by: \.project)
|
|
}
|
|
|
|
/// #108: the prototype's toggle — click the project name (or chevron).
|
|
private func toggle(_ project: String) {
|
|
if collapsed.contains(project) {
|
|
collapsed.remove(project)
|
|
} else {
|
|
collapsed.insert(project)
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
// No New button — things arrive here by being moved, not created.
|
|
// r8 (argon#9, mercury#18/19): the hairline is bounded to the SAME
|
|
// fixed 720pt column the rows live in — one framed block.
|
|
PaneHeader(title: "Archive", hairlineMaxWidth: 720)
|
|
if archivedByProject.isEmpty {
|
|
emptyState
|
|
} else {
|
|
ScrollView {
|
|
LazyVStack(alignment: .leading, spacing: 4) {
|
|
// #108 audit: Finder order, matching the library's sort.
|
|
ForEach(archivedByProject.keys.sorted { $0.localizedStandardCompare($1) == .orderedAscending }, id: \.self) { project in
|
|
let pieces = archivedByProject[project] ?? []
|
|
// Same section-head shape as the library (#108
|
|
// variant B), plus the project-level way out.
|
|
// r7 (mercury#55, argon#41 — FINAL, supersedes the
|
|
// r6 D24 ladder): the content column is a FIXED
|
|
// 720pt frame (width, not maxWidth — the r6
|
|
// content-hugging bound let the pill define the
|
|
// right edge), left-anchored. TWO axes only, the
|
|
// library's r7 ladder: the head row leads at x14
|
|
// (chevron in a 14pt slot) with its label at x28 —
|
|
// the ONE indent, shared with the entry rows'
|
|
// inner text via the shared LibraryPostRow (cards
|
|
// lead at x14); the 'Unarchive Group' pill rides
|
|
// the header row's trailing edge INSIDE the frame
|
|
// (14 → 706), and the row hairlines are bounded by
|
|
// the same frame. Nothing spans past it.
|
|
HStack(alignment: .firstTextBaseline, spacing: 0) {
|
|
Image(systemName: "chevron.down")
|
|
.font(.system(size: 10, weight: .semibold))
|
|
.frame(width: 14, alignment: .leading)
|
|
.rotationEffect(.degrees(collapsed.contains(project) ? -90 : 0))
|
|
.foregroundStyle(DesignTokens.muted)
|
|
.onTapGesture {
|
|
withAnimation { toggle(project) }
|
|
}
|
|
.accessibilityLabel("Toggle \(project)")
|
|
.accessibilityHint(collapsed.contains(project) ? "Collapsed" : "Expanded")
|
|
Text(project)
|
|
.font(.system(size: 11, weight: .medium, design: DesignTokens.mono))
|
|
.kerning(0.6)
|
|
.textCase(.uppercase) // #108: display-only — the folder name keeps its case
|
|
.foregroundStyle(DesignTokens.muted) // r6: full ink — contrast final
|
|
.lineLimit(1)
|
|
.truncationMode(.tail)
|
|
.onTapGesture {
|
|
withAnimation { toggle(project) }
|
|
}
|
|
Text("· \(pieces.count)")
|
|
.font(.system(size: 11, design: DesignTokens.mono))
|
|
.foregroundStyle(DesignTokens.muted)
|
|
.padding(.leading, 8)
|
|
Spacer(minLength: 8)
|
|
// The 'New Post · Fork · Compact' language — a
|
|
// bordered mono-11 secondary pill at the
|
|
// trailing edge INSIDE the fixed 720pt frame.
|
|
// r7 (mercury#55, argon#41): relabeled
|
|
// 'Unarchive Group' — it moves the whole
|
|
// project, not one piece.
|
|
Button("Unarchive Group") {
|
|
model.unarchiveProject(project)
|
|
}
|
|
.buttonStyle(BorderedSecondaryButtonStyle(minHeight: 24))
|
|
.help("Move the whole project back to projects/")
|
|
.accessibilityLabel("Unarchive \(project)")
|
|
}
|
|
.padding(.top, 12)
|
|
.padding(.horizontal, 14)
|
|
.padding(.bottom, 2)
|
|
if !collapsed.contains(project) {
|
|
ForEach(pieces) { post in
|
|
// r7: the shared LibraryPostRow ladder —
|
|
// card leads at x14 (PRIMARY), title text
|
|
// at x28 (the one indent). The hairline is
|
|
// BOUNDED to the fixed frame: x14 → 706.
|
|
LibraryPostRow(post: post, selected: post.id == model.selectedPostID) {
|
|
model.select(post.id)
|
|
onOpenPiece()
|
|
}
|
|
.overlay(alignment: .bottom) {
|
|
Rectangle()
|
|
.fill(DesignTokens.border)
|
|
.frame(height: 1)
|
|
.padding(.horizontal, 14)
|
|
}
|
|
.contextMenu {
|
|
Button("Move Back to \(post.project)") {
|
|
model.restorePost(post)
|
|
}
|
|
Button("Rename…") { renamingPost = post }
|
|
// #114 (S4): works archived too — the piece
|
|
// stays where it is, only type + body flip.
|
|
if post.type == .outline {
|
|
Button("Convert to Post…") {
|
|
model.stageConversion(post)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// r7 (mercury#55, argon#41): the FIXED 720pt reading
|
|
// column — width, not maxWidth (the r6 content-hugging
|
|
// bound let the pill define the right edge); rows,
|
|
// hairlines, and the pill all live inside it.
|
|
// ponytail: fixed width clips on panes narrower than
|
|
// 720 — a width-floored variant if a small-window
|
|
// Archive ever matters.
|
|
.frame(width: 720, alignment: .leading)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(.bottom, 12)
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background(DesignTokens.background)
|
|
.sheet(item: $renamingPost) { post in
|
|
RenamePostSheet(post: post) { title in
|
|
model.rename(post, to: title)
|
|
}
|
|
}
|
|
}
|
|
|
|
private var emptyState: some View {
|
|
VStack(spacing: 8) {
|
|
Text("Nothing archived")
|
|
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
|
|
Text("Finished projects and pieces fold away here. Move things here from their context menu; they stay openable and editable.")
|
|
.font(.callout)
|
|
.foregroundStyle(DesignTokens.muted)
|
|
.multilineTextAlignment(.center)
|
|
}
|
|
.padding(38)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
}
|
|
}
|