Reviewer fan-out (ponytail/security/general) synthesis: - one failure surface in focus (chip carries it; toolbar stays recessed) - draft '⌘S saves' cue in focus (drafts have no autosave) - mentor reveal honors the #17 width verdict - hidden overlay panels leave the accessibility tree - NSColor(DesignTokens.background) bridge replaces the twin constant - HoverZone width plumbing deleted, zoneWidth hoisted as the knob - single >=1100 threshold read in WorkspaceView
212 lines
6.2 KiB
Swift
212 lines
6.2 KiB
Swift
//
|
||
// WorkspaceView.swift
|
||
// Museion
|
||
//
|
||
// #17 (S1.1): the workspace shell — nav rail + panes, built from the design
|
||
// contract's grid geometry (ref/Web-Prototype/museion-workspace.html):
|
||
// rail 56 | library 232 | editor min 420 | mentor 356.
|
||
//
|
||
|
||
import SwiftUI
|
||
|
||
/// The post-gate main surface. Posts shows the full four-column workspace;
|
||
/// Sessions/Learnings/Settings fill the space after the rail until their
|
||
/// tickets land (#28/#26; Settings is real here).
|
||
struct WorkspaceView: View {
|
||
@Environment(AppGateState.self) private var gate
|
||
@State private var selection: Pane = .posts
|
||
|
||
enum Pane: Hashable {
|
||
case posts
|
||
case sessions
|
||
case learnings
|
||
case settings
|
||
}
|
||
|
||
var body: some View {
|
||
GeometryReader { geo in
|
||
Group {
|
||
if gate.isFocused {
|
||
// #21: the rail recedes; the pane takes the full width. The
|
||
// measure stays centered — revealed panes float, never push.
|
||
paneContent(geo)
|
||
} else {
|
||
HStack(spacing: 0) {
|
||
navRail
|
||
paneBorder
|
||
paneContent(geo)
|
||
}
|
||
}
|
||
}
|
||
// #21: left-edge hover slides rail+library back in as an overlay.
|
||
// Library only while the window width allows it (#17 verdict stands:
|
||
// a collapsed pane is not summoned by focus).
|
||
.overlay {
|
||
if gate.isFocused {
|
||
// #17 verdict: the library reveal honors the width collapse.
|
||
let showsLibrary = geo.size.width >= 1100
|
||
FocusOverlayPanel(edge: .leading, panelWidth: leftRevealWidth(showsLibrary)) {
|
||
HStack(spacing: 0) {
|
||
navRail
|
||
paneBorder
|
||
if showsLibrary {
|
||
PostsLibraryColumn(home: gate.museionHome, model: gate.posts)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.background(DesignTokens.background)
|
||
}
|
||
// Collapsed floor: rail 56 + editor placeholder (export ≤920 layout).
|
||
.frame(minWidth: 480, minHeight: 320)
|
||
}
|
||
|
||
@ViewBuilder
|
||
private func paneContent(_ geo: GeometryProxy) -> some View {
|
||
@Bindable var gate = gate
|
||
switch selection {
|
||
case .posts:
|
||
// #14: mentor column hands in the app-scoped model + gate's winner.
|
||
// Column collapse mirrors the export's media queries (library ≤1100,
|
||
// mentor ≤920) as macOS pane collapse per the PRD.
|
||
PostsPaneView(
|
||
home: gate.museionHome,
|
||
mentor: gate.mentor,
|
||
mentorBinaryPath: gate.gateModel.currentBinaryPath,
|
||
model: gate.posts,
|
||
availableWidth: geo.size.width - DesignTokens.railWidth,
|
||
)
|
||
case .sessions:
|
||
PlaceholderPane(title: "Sessions", detail: "Session lifecycle arrives with S2.3 (#28).")
|
||
case .learnings:
|
||
PlaceholderPane(title: "Learnings", detail: "Promote, consult, and decay arrive with S4 (#26, #27).")
|
||
case .settings:
|
||
SettingsPaneView(home: $gate.museionHome)
|
||
}
|
||
}
|
||
|
||
/// The left reveal panel's width: rail + border (+ library when the
|
||
/// unfocused width verdict grants it).
|
||
private func leftRevealWidth(_ showsLibrary: Bool) -> CGFloat {
|
||
DesignTokens.railWidth + 1 + (showsLibrary ? DesignTokens.libraryWidth : 0)
|
||
}
|
||
|
||
/// 1px contract border between rail and pane (`.rail { border-right }`).
|
||
private var paneBorder: some View {
|
||
Rectangle()
|
||
.fill(DesignTokens.border)
|
||
.frame(width: 1)
|
||
}
|
||
|
||
// MARK: Nav rail
|
||
|
||
private var navRail: some View {
|
||
VStack(spacing: 8) {
|
||
RailButton(pane: .posts, selection: $selection, label: "Posts", systemImage: "doc.text")
|
||
RailButton(pane: .sessions, selection: $selection, label: "Sessions", systemImage: "bubble.left")
|
||
RailButton(pane: .learnings, selection: $selection, label: "Learnings", systemImage: "cube")
|
||
Spacer()
|
||
RailButton(pane: .settings, selection: $selection, label: "Settings", systemImage: "gearshape")
|
||
}
|
||
.padding(.horizontal, 4)
|
||
.padding(.vertical, 8)
|
||
.frame(width: DesignTokens.railWidth)
|
||
.frame(maxHeight: .infinity)
|
||
}
|
||
}
|
||
|
||
/// Rail button per the export: 44×44 muted icon, hover wash, and the current
|
||
/// pane raised as a surface card with a 2px selection bar on the rail's edge.
|
||
private struct RailButton: View {
|
||
let pane: WorkspaceView.Pane
|
||
@Binding var selection: WorkspaceView.Pane
|
||
let label: String
|
||
let systemImage: String
|
||
@State private var hover = false
|
||
|
||
var body: some View {
|
||
let selected = selection == pane
|
||
Button {
|
||
selection = pane
|
||
} label: {
|
||
Image(systemName: systemImage)
|
||
.frame(width: 44, height: 44)
|
||
}
|
||
.buttonStyle(.plain)
|
||
.foregroundStyle(selected ? DesignTokens.foreground : DesignTokens.muted)
|
||
.background {
|
||
if selected || hover {
|
||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
|
||
.overlay(
|
||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||
.strokeBorder(selected ? DesignTokens.border : .clear),
|
||
)
|
||
}
|
||
}
|
||
.overlay(alignment: .leading) {
|
||
// Selection bar (`.rail-btn[aria-current]::before`); offset to sit
|
||
// on the rail's leading edge like the export's negative inset.
|
||
if selected {
|
||
Rectangle()
|
||
.fill(DesignTokens.foreground)
|
||
.frame(width: 2, height: 22)
|
||
.offset(x: -6)
|
||
}
|
||
}
|
||
.onHover { hover = $0 }
|
||
.help(label)
|
||
.accessibilityLabel(label)
|
||
}
|
||
}
|
||
|
||
/// Pane-head row per the export (52pt, serif 15 semibold title, bottom border).
|
||
/// Trailing slot carries #18's New Post button (export `.pane-head .icon-btn`).
|
||
struct PaneHeader<Trailing: View>: View {
|
||
let title: String
|
||
@ViewBuilder var trailing: () -> Trailing
|
||
|
||
init(title: String, @ViewBuilder trailing: @escaping () -> Trailing = { EmptyView() }) {
|
||
self.title = title
|
||
self.trailing = trailing
|
||
}
|
||
|
||
var body: some View {
|
||
VStack(spacing: 0) {
|
||
HStack {
|
||
Text(title)
|
||
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
|
||
Spacer()
|
||
trailing()
|
||
}
|
||
.padding(.horizontal, 14)
|
||
.frame(minHeight: 52)
|
||
Rectangle()
|
||
.fill(DesignTokens.border)
|
||
.frame(height: 1)
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Navigation-target placeholder (#17 AC: panes exist as targets; real content
|
||
/// arrives with their tickets — honest copy, no fake controls).
|
||
struct PlaceholderPane: View {
|
||
let title: String
|
||
let detail: String
|
||
|
||
var body: some View {
|
||
VStack(spacing: 10) {
|
||
Image(systemName: "hourglass")
|
||
.font(.largeTitle)
|
||
.foregroundStyle(DesignTokens.muted)
|
||
Text(title)
|
||
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
|
||
Text(detail)
|
||
.font(.callout)
|
||
.foregroundStyle(DesignTokens.muted)
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
}
|
||
}
|