feat(workspace): focus mode — recession, hover reveal, soft caret centering (#87)
Map #21 build child. Toggle via View menu / ⌘⇧F; panes and toolbar recede, overlay hover reveal (left: rail+library, right: mentor), soft caret centering while typing, loud save failure, ⌘S armed in focus. Full suite green; calibration gate #88 judges calm.
This commit is contained in:
1 parent
99aa3d2faf
commit
b0ab800d3d
12 files changed
+550
-98
No files matched your search
+82
-61
@@ -22,7 +22,7 @@ struct PostsPaneView: View {
|
||||
/// Width budget after the rail — drives column collapse (export media queries:
|
||||
/// library hides ≤1100, mentor hides ≤920).
|
||||
var availableWidth: CGFloat
|
||||
@State private var renamingPost: Post?
|
||||
@Environment(AppGateState.self) private var gate
|
||||
|
||||
private var showsLibrary: Bool {
|
||||
availableWidth >= 1100 - DesignTokens.railWidth
|
||||
@@ -33,26 +33,35 @@ struct PostsPaneView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
if showsLibrary {
|
||||
libraryColumn
|
||||
paneBorder
|
||||
}
|
||||
editorColumn
|
||||
if showsMentor {
|
||||
paneBorder
|
||||
mentorColumn
|
||||
Group {
|
||||
if gate.isFocused {
|
||||
// #21: columns recede; the editor surface + centered measure on
|
||||
// the workspace background is all that remains. The mentor
|
||||
// returns by right-edge hover (overlay below).
|
||||
ZStack(alignment: .trailing) {
|
||||
editorColumn
|
||||
FocusOverlayPanel(edge: .trailing, panelWidth: DesignTokens.mentorWidth) {
|
||||
mentorColumn
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HStack(spacing: 0) {
|
||||
if showsLibrary {
|
||||
PostsLibraryColumn(home: home, model: model)
|
||||
paneBorder
|
||||
}
|
||||
editorColumn
|
||||
if showsMentor {
|
||||
paneBorder
|
||||
mentorColumn
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.task(id: home) {
|
||||
// Bind: initial off-main scan + (re)start the FSEvents watcher (#61).
|
||||
model.bind(home: home)
|
||||
}
|
||||
.sheet(item: $renamingPost) { post in
|
||||
RenamePostSheet(post: post) { title in
|
||||
model.rename(post, to: title, home: home)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var paneBorder: some View {
|
||||
@@ -61,9 +70,60 @@ struct PostsPaneView: View {
|
||||
.frame(width: 1)
|
||||
}
|
||||
|
||||
// MARK: Library column
|
||||
// MARK: Editor column (#19: TextKit2 editor core)
|
||||
|
||||
private var libraryColumn: some View {
|
||||
private var editorColumn: some View {
|
||||
VStack(spacing: 0) {
|
||||
if let draft = model.draft {
|
||||
PostEditorView(
|
||||
session: nil,
|
||||
draftText: draft.text,
|
||||
draftEdited: { model.updateDraft($0) },
|
||||
draftSave: {
|
||||
model.saveDraft(home: home)
|
||||
},
|
||||
)
|
||||
.id("draft")
|
||||
} else if let session = model.session, session.postID == model.selectedPostID {
|
||||
PostEditorView(session: session, draftText: nil)
|
||||
.id(session.postID)
|
||||
} else {
|
||||
VStack(spacing: 10) {
|
||||
Image(systemName: "square.and.pencil")
|
||||
.font(.largeTitle)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
Text("Select a post, or start a new one.")
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
if let error = model.lastError {
|
||||
Text(error)
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(DesignTokens.surface)
|
||||
}
|
||||
|
||||
private var mentorColumn: some View {
|
||||
MentorPaneView(model: mentor, binaryPath: mentorBinaryPath)
|
||||
.frame(width: DesignTokens.mentorWidth)
|
||||
}
|
||||
}
|
||||
|
||||
/// #21: the library column, shared by the unfocused layout and the focus-mode
|
||||
/// left reveal overlay — one implementation, both surfaces. Owns the rename
|
||||
/// sheet + context menu (they travel with the post rows).
|
||||
struct PostsLibraryColumn: View {
|
||||
let home: URL
|
||||
var model: PostsModel
|
||||
@State private var renamingPost: Post?
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
PaneHeader(title: "Posts") {
|
||||
Button {
|
||||
@@ -110,6 +170,11 @@ struct PostsPaneView: View {
|
||||
}
|
||||
}
|
||||
.frame(width: DesignTokens.libraryWidth)
|
||||
.sheet(item: $renamingPost) { post in
|
||||
RenamePostSheet(post: post) { title in
|
||||
model.rename(post, to: title, home: home)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
@@ -124,50 +189,6 @@ struct PostsPaneView: View {
|
||||
.padding(38)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
|
||||
// MARK: Editor column (#19: TextKit2 editor core)
|
||||
|
||||
private var editorColumn: some View {
|
||||
VStack(spacing: 0) {
|
||||
if let draft = model.draft {
|
||||
PostEditorView(
|
||||
session: nil,
|
||||
draftText: draft.text,
|
||||
draftEdited: { model.updateDraft($0) },
|
||||
draftSave: {
|
||||
model.saveDraft(home: home)
|
||||
},
|
||||
)
|
||||
.id("draft")
|
||||
} else if let session = model.session, session.postID == model.selectedPostID {
|
||||
PostEditorView(session: session, draftText: nil)
|
||||
.id(session.postID)
|
||||
} else {
|
||||
VStack(spacing: 10) {
|
||||
Image(systemName: "square.and.pencil")
|
||||
.font(.largeTitle)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
Text("Select a post, or start a new one.")
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
if let error = model.lastError {
|
||||
Text(error)
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(DesignTokens.surface)
|
||||
}
|
||||
|
||||
private var mentorColumn: some View {
|
||||
MentorPaneView(model: mentor, binaryPath: mentorBinaryPath)
|
||||
.frame(width: DesignTokens.mentorWidth)
|
||||
}
|
||||
}
|
||||
|
||||
/// #60: Explicit Rename dialog — asks the new Title (not a slug).
|
||||
|
||||
Reference in new issue
Block a user