native: undo and redo move into ••• while the title is folded
The coordinator's ruling (a) on #180. While the title is folded into the bar, the undo/redo pill leaves it and Undo and Redo head the ••• menu (enabled from the history, as the pill's are); unfolded, the pill is back. With the pill gone the folded title is centred again (the bar dropped a centred title only for want of room) and shows about four times as much: "Native review docu…" where it was "Nat…". Test: the writer XCUITest checks the pill goes when typing folds the title, that ••• begins with Undo and Redo and Undo runs from there, and that the pill is back when the title unfolds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+38
−15
native/apple/Sources/DocsKit/DocsPhoneDocument.swift+23 −4native/apple/Sources/DocsKit/DocsPhoneHeader.swift+2 −3native/apple/Sources/DocsKit/DocsWorkspace.swift+4 −8native/ios/UITests/NativeUITests.swift+9 −0
diff --git a/native/apple/Sources/DocsKit/DocsPhoneDocument.swift b/native/apple/Sources/DocsKit/DocsPhoneDocument.swift| index 717e1bd..62ae967 100644 |
| --- a/native/apple/Sources/DocsKit/DocsPhoneDocument.swift |
| +++ b/native/apple/Sources/DocsKit/DocsPhoneDocument.swift |
| @@ -17,24 +17,29 @@ struct DocsPhoneActions { |
| /// The bar's trailing controls (spec §3): the undo/redo pill, Aa and ••• |
| /// for a writer; ••• alone for a reader. No Share pill (Paul's ruling 4): |
| -/// Share lives in •••. Their own view, reading the access, the history and |
| -/// the connectivity, so the text view's host reads none of them. |
| +/// Share lives in •••. While the title is folded into the bar, undo and |
| +/// redo move to the top of ••• so the title has the room (the |
| +/// coordinator's ruling on #180). Their own view, reading the access, the |
| +/// history, the connectivity and the fold, so the text view's host reads |
| +/// none of them. |
| @MainActor struct DocsPhoneDocumentControls: View { |
| let model: DocsModel |
| let origin: URL |
| @Binding var paged: Bool |
| + let header: DocumentHeaderState |
| let actions: DocsPhoneActions |
| var body: some View { |
| + let folded = header.collapsed |
| HStack(spacing: DocsSpacing.sp2) { |
| if model.documentAccess == .writable { |
| - DocsPhoneUndoRedoPill(model: model) |
| + if !folded { DocsPhoneUndoRedoPill(model: model) } |
| Button(action: actions.format) { |
| Text(verbatim: "Aa").font(.body.weight(.semibold)).frame(minWidth: 44, minHeight: 44) |
| } |
| .accessibilityLabel(Text("docs.editor.inspector.toggle", bundle: DocsResources.bundle)) |
| .accessibilityIdentifier("docs.format.toggle") |
| } |
| - DocsPhoneMoreMenu(model: model, origin: origin, paged: $paged, actions: actions) |
| + DocsPhoneMoreMenu(model: model, origin: origin, paged: $paged, actions: actions, history: folded) |
| } |
| } |
| } |
| @@ -74,12 +79,26 @@ struct DocsPhoneActions { |
| let origin: URL |
| @Binding var paged: Bool |
| let actions: DocsPhoneActions |
| + /// Undo and Redo at the top (the title folded into the bar). |
| + var history = false |
| var body: some View { |
| let offline = model.connectivity.isOffline(origin) |
| let owner = model.detail?.can_share == true && !model.isDraft && model.documentAccess != .unavailable |
| let writer = model.documentAccess == .writable |
| let saved = model.detail != nil && !model.isDraft |
| Menu { |
| + if history && writer { |
| + Section { |
| + Button { DocumentCommands(model: model, content: model.surface.content).perform("undo") } label: { |
| + Label { Text("docs.editor.toolbar.undo", bundle: DocsResources.bundle) } icon: { Image(systemName: "arrow.uturn.backward") } |
| + } |
| + .disabled(!model.history.canUndo) |
| + Button { DocumentCommands(model: model, content: model.surface.content).perform("redo") } label: { |
| + Label { Text("docs.editor.toolbar.redo", bundle: DocsResources.bundle) } icon: { Image(systemName: "arrow.uturn.forward") } |
| + } |
| + .disabled(!model.history.canRedo) |
| + } |
| + } |
| Section { |
| if owner { |
| Button(action: actions.share) { Label { Text("docs.share.action", bundle: DocsResources.bundle) } icon: { Image(systemName: "person.crop.circle.badge.plus") } } |
diff --git a/native/apple/Sources/DocsKit/DocsPhoneHeader.swift b/native/apple/Sources/DocsKit/DocsPhoneHeader.swift| index 1f4bc24..deb2253 100644 |
| --- a/native/apple/Sources/DocsKit/DocsPhoneHeader.swift |
| +++ b/native/apple/Sources/DocsKit/DocsPhoneHeader.swift |
| @@ -72,16 +72,15 @@ import UIKit |
| var body: some View { |
| // Present only while folded, so the bar holds nothing (and |
| // VoiceOver reads nothing) while the large title shows. |
| - ZStack(alignment: .leading) { |
| + ZStack { |
| if state.collapsed { |
| - VStack(alignment: .leading, spacing: 0) { |
| + VStack(spacing: 0) { |
| Text(verbatim: model.detail?.title ?? "") |
| .font(.headline) |
| .lineLimit(1) |
| .truncationMode(.tail) |
| DocsSubtitleView(model: model, team: team) |
| } |
| - .frame(maxWidth: .infinity, alignment: .leading) |
| .transition(.opacity) |
| .accessibilityElement(children: .combine) |
| // The bar caps its type at the largest sizes, as every bar |
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift| index 154edb5..6aa0d6e 100644 |
| --- a/native/apple/Sources/DocsKit/DocsWorkspace.swift |
| +++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift |
| @@ -696,15 +696,11 @@ extension DocsWorkspace { |
| .navigationTitle(model.detail?.title ?? "") |
| .navigationBarTitleDisplayMode(.inline) |
| .toolbar { |
| - // Beside Back, where it can truncate: a centred title has no |
| - // room left of the trailing controls, and the bar drops it. |
| - // The empty principal keeps the navigation title (which names |
| - // the page in Back's history) out of the bar. |
| - ToolbarItem(placement: .topBarLeading) { DocsPhoneInlineTitle(model: model, team: team, state: phoneChrome.header) } |
| - .sharedBackgroundVisibility(.hidden) |
| - ToolbarItem(placement: .principal) { Color.clear.frame(width: 0, height: 0).accessibilityHidden(true) } |
| + // Centred: while it shows, undo and redo are in ••• (the |
| + // coordinator's ruling on #180), which leaves it the room. |
| + ToolbarItem(placement: .principal) { DocsPhoneInlineTitle(model: model, team: team, state: phoneChrome.header) } |
| ToolbarItem(placement: .topBarTrailing) { |
| - DocsPhoneDocumentControls(model: model, origin: client.origin, paged: $paged, actions: phoneActions) |
| + DocsPhoneDocumentControls(model: model, origin: client.origin, paged: $paged, header: phoneChrome.header, actions: phoneActions) |
| } |
| } |
| .sheet(isPresented: $formatting, onDismiss: { |
diff --git a/native/ios/UITests/NativeUITests.swift b/native/ios/UITests/NativeUITests.swift| index 62dc427..87647f7 100644 |
| --- a/native/ios/UITests/NativeUITests.swift |
| +++ b/native/ios/UITests/NativeUITests.swift |
| @@ -317,6 +317,14 @@ final class NativeUITests: XCTestCase { |
| try audit(app) |
| editor.typeText("x") |
| XCTAssertTrue(inline.waitForExistence(timeout: 3), "typing folds the title into the bar") |
| + // Folded, undo and redo leave the bar for the top of •••. |
| + XCTAssertTrue(app.buttons["docs.undo"].waitForNonExistence(timeout: 3), "no undo/redo pill while the title is folded") |
| + app.buttons["docs.more"].tap() |
| + XCTAssertTrue(app.buttons["Undo"].waitForExistence(timeout: 3), "••• begins with Undo") |
| + XCTAssertTrue(app.buttons["Redo"].exists, "and Redo") |
| + app.buttons["Undo"].tap() |
| + XCTAssertTrue(app.buttons["Undo"].waitForNonExistence(timeout: 3), "Undo runs and the menu goes") |
| + editor.typeText("x") |
| let typed = XCTAttachment(screenshot: app.screenshot()); typed.name = "S3 keyboard bar"; typed.lifetime = .keepAlways; add(typed) |
| // Aa: the sheet, the keyboard gone, the text view still focused. |
| @@ -343,6 +351,7 @@ final class NativeUITests: XCTestCase { |
| XCTAssertTrue(app.keyboards.firstMatch.waitForNonExistence(timeout: 5)) |
| editor.swipeDown(); editor.swipeDown() |
| XCTAssertTrue(inline.waitForNonExistence(timeout: 5), "at the top with the keyboard down, the title unfolds") |
| + XCTAssertTrue(app.buttons["docs.undo"].waitForExistence(timeout: 3), "and the undo/redo pill is back in the bar") |
| editor.swipeUp() |
| XCTAssertTrue(inline.waitForExistence(timeout: 5), "scrolling past the title folds it") |