Commit ab3a6a9d7e

ab3a6a9d7eefda3b6399b764a309fffd25313ba3

parent: 6ac7ed3093

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 20:28 UTC

iOS: one message view and one refusal wording

The editor and reader show messages in one view that times out after four
seconds. Commands that don't run here say which command and that it runs
on the Mac.

Ref #223

Layout: unified · split

Changed files (5)
Sources/OrgstarMobile/EditorScreen.swift +33 −11 · view
@@ -217,16 +217,9 @@ struct EditorScreen: View {
217 } 217 }
218 .frame(maxWidth: .infinity).padding(4).background(.bar) 218 .frame(maxWidth: .infinity).padding(4).background(.bar)
219 } 219 }
220 if let message {
221 Text(message).font(.callout).padding(8).frame(maxWidth: .infinity).background(.bar)
222 .onTapGesture { self.message = nil }
223 .task(id: message) {
224 try? await Task.sleep(for: .seconds(4))
225 if self.message == message { self.message = nil }
226 }
227 }
228 } 220 }
229 } 221 }
222 .message($message, edge: .top)
230 .sheet(item: $prompt) { request in 223 .sheet(item: $prompt) { request in
231 PromptSheet(prompt: request.prompt) { answer in 224 PromptSheet(prompt: request.prompt) { answer in
232 prompt = nil 225 prompt = nil
@@ -478,7 +471,7 @@ struct EditorScreen: View {
478 editor.onAppCommand = { id in 471 editor.onAppCommand = { id in
479 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return } 472 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return }
480 if Self.paneCommands.contains(id) { 473 if Self.paneCommands.contains(id) {
481 if let onPaneCommand { onPaneCommand(id) } else { message = "Not available here" } 474 if let onPaneCommand { onPaneCommand(id) } else { message = MobileEditor.unavailable(command: id) }
482 } else if id == "app.save" { 475 } else if id == "app.save" {
483 _ = session.save(path) 476 _ = session.save(path)
484 } else if id == "app.archive" { 477 } else if id == "app.archive" {
@@ -520,7 +513,7 @@ struct EditorScreen: View {
520 } else if MobileEditor.linkCommands.contains(id) { 513 } else if MobileEditor.linkCommands.contains(id) {
521 link(id) 514 link(id)
522 } else if !MobileClock.run(id, model: model, workspace: workspace, show: { message = $0 }) { 515 } else if !MobileClock.run(id, model: model, workspace: workspace, show: { message = $0 }) {
523 message = "Not available on iOS yet" 516 message = MobileEditor.unavailable(command: id)
524 } 517 }
525 } 518 }
526 } 519 }
@@ -1086,7 +1079,7 @@ struct CommandPalette: View {
1086 @State private var query = "" 1079 @State private var query = ""
1087 @Environment(\.dismiss) private var dismiss 1080 @Environment(\.dismiss) private var dismiss
1088 1081
1089 private static let viewCommands: [(id: String, title: String)] = [ 1082 static let viewCommands: [(id: String, title: String)] = [
1090 ("org.cycle", "Cycle Visibility"), ("org.cycle-global", "Cycle Global Visibility"), 1083 ("org.cycle", "Cycle Visibility"), ("org.cycle-global", "Cycle Global Visibility"),
1091 ("edit.undo", "Undo"), ("edit.redo", "Redo"), 1084 ("edit.undo", "Undo"), ("edit.redo", "Redo"),
1092 ("app.clock.in", "Clock In"), ("app.clock.out", "Clock Out"), ("app.clock.cancel", "Cancel Clock"), 1085 ("app.clock.in", "Clock In"), ("app.clock.out", "Clock Out"), ("app.clock.cancel", "Cancel Clock"),
@@ -1261,6 +1254,35 @@ final class PaneHolder {
1261 } 1254 }
1262} 1255}
1263 1256
1257/// A command's result or refusal, over the screen until it is tapped or for four seconds.
1258private struct MessageView: ViewModifier {
1259 @Binding var message: String?
1260 let edge: VerticalEdge
1261
1262 func body(content: Content) -> some View {
1263 content.overlay(alignment: edge == .top ? .top : .bottom) {
1264 if let message {
1265 Text(message).font(.callout).multilineTextAlignment(.center)
1266 .padding(.horizontal, 14).padding(.vertical, 8)
1267 .glassEffect(.regular, in: .rect(cornerRadius: 18))
1268 .padding(8)
1269 .onTapGesture { self.message = nil }
1270 .task(id: message) {
1271 try? await Task.sleep(for: .seconds(4))
1272 if self.message == message { self.message = nil }
1273 }
1274 }
1275 }
1276 }
1277}
1278
1279extension View {
1280 /// Shows `message` in the one message view, at the top or bottom of the screen.
1281 func message(_ message: Binding<String?>, edge: VerticalEdge = .bottom) -> some View {
1282 modifier(MessageView(message: message, edge: edge))
1283 }
1284}
1285
1264/// The screen's title, unless a split shows the focused pane's. 1286/// The screen's title, unless a split shows the focused pane's.
1265private struct EditorTitle: ViewModifier { 1287private struct EditorTitle: ViewModifier {
1266 let title: String 1288 let title: String
Sources/OrgstarMobile/MobileEditor.swift +13 −3 · view
@@ -366,7 +366,17 @@ final class MobileEditor: NSObject, DocumentBuffer {
366 if case .emacsTable(_, _, _, let reason, _, _, _) = request { 366 if case .emacsTable(_, _, _, let reason, _, _, _) = request {
367 return String(localized: "This table needs Emacs, which runs on the Mac: \(TableReason.localized(reason)).", comment: "Table formulas only Emacs can calculate") 367 return String(localized: "This table needs Emacs, which runs on the Mac: \(TableReason.localized(reason)).", comment: "Table formulas only Emacs can calculate")
368 } 368 }
369 return String(localized: "\(CommandTitle.localized(title)) isn't available on iPhone and iPad.", comment: "A command that runs only on the Mac") 369 return unavailable(title)
370 }
371
372 /// The refusal for a command that runs on the Mac and not here, by its title.
373 static func unavailable(_ title: String) -> String {
374 String(localized: "\(CommandTitle.localized(title)) isn't available on iPhone and iPad. It runs on the Mac.", comment: "A command that runs only on the Mac")
375 }
376
377 /// The refusal for a command identifier, named by its title where the app knows one.
378 static func unavailable(command id: String) -> String {
379 unavailable(Commands.command(id)?.title ?? CommandPalette.viewCommands.first { $0.id == id }?.title ?? id)
370 } 380 }
371 381
372 // MARK: - Commands by name and key 382 // MARK: - Commands by name and key
@@ -406,12 +416,12 @@ final class MobileEditor: NSObject, DocumentBuffer {
406 case "edit.redo": textView.undoManager?.redo() 416 case "edit.redo": textView.undoManager?.redo()
407 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand": tableColumnWidth(id) 417 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand": tableColumnWidth(id)
408 case _ where id.hasPrefix("app.") || Self.linkCommands.contains(id): 418 case _ where id.hasPrefix("app.") || Self.linkCommands.contains(id):
409 if let onAppCommand { onAppCommand(id) } else { onMessage?("Not available on iOS yet") } 419 if let onAppCommand { onAppCommand(id) } else { onMessage?(Self.unavailable(command: id)) }
410 default: 420 default:
411 if let command = Commands.command(id) { 421 if let command = Commands.command(id) {
412 _ = perform(command) 422 _ = perform(command)
413 } else { 423 } else {
414 onMessage?("Not available on iOS yet") 424 onMessage?(Self.unavailable(command: id))
415 } 425 }
416 } 426 }
417 } 427 }
Sources/OrgstarMobile/ReaderScreen.swift +1 −6 · view
@@ -117,12 +117,7 @@ struct ReaderScreen: View {
117 } 117 }
118 .quickLookPreview($previewed) 118 .quickLookPreview($previewed)
119 .sheet(isPresented: $showingOutline) { outlineSheet } 119 .sheet(isPresented: $showingOutline) { outlineSheet }
120 .safeAreaInset(edge: .bottom) { 120 .message($message)
121 if let message {
122 Text(message).font(.callout).padding(8).frame(maxWidth: .infinity).background(.bar)
123 .onTapGesture { self.message = nil }
124 }
125 }
126 .environment(\.openURL, OpenURLAction { url in follow(url) }) 121 .environment(\.openURL, OpenURLAction { url in follow(url) })
127 .onAppear(perform: open) 122 .onAppear(perform: open)
128 .onChange(of: pane?.path) { loadFolds() } 123 .onChange(of: pane?.path) { loadFolds() }
docs/manual/guide/14-ios.org +3 −3 · view
@@ -54,7 +54,7 @@ The toolbar has:
54- Undo 54- Undo
55- More :: Commands, Clock In, Show Markup, Recent Entries, Export, Sync Conflict Copies, and Recovered Versions. 55- More :: Commands, Clock In, Show Markup, Recent Entries, Export, Sync Conflict Copies, and Recovered Versions.
56 56
57Messages from commands show at the top of the editor for a few seconds; tap one to dismiss it. 57Messages from commands show at the top of the editor, and at the bottom of the reader, for a few seconds; tap one to dismiss it.
58 58
59** Panes and windows on iPad 59** Panes and windows on iPad
60 60
@@ -173,7 +173,7 @@ With a hardware keyboard, the editor uses the preset =keymap= sets in the folder
173- Command shortcuts are the system's. 173- Command shortcuts are the system's.
174- Keys the keymap leaves to the text system stay with iOS. These include the editing keys =C-a=, =C-e=, =C-k= and similar, which iOS handles itself. 174- Keys the keymap leaves to the text system stay with iOS. These include the editing keys =C-a=, =C-e=, =C-k= and similar, which iOS handles itself.
175- After a prefix such as =C-c=, the message line shows =C-c-= while it waits for the next key. An unbound sequence shows =… is undefined=. 175- After a prefix such as =C-c=, the message line shows =C-c-= while it waits for the next key. An unbound sequence shows =… is undefined=.
176- A sequence bound to a command that can't run at the caret, or that the iOS app doesn't have, shows why, as on the Mac: the command's own message (such as =Not on a heading=), or =Not available on iOS yet=. 176- A sequence bound to a command that can't run at the caret, or that the iOS app doesn't have, shows why, as on the Mac: the command's own message (such as =Not on a heading=), or that it isn't available on iPhone and iPad and runs on the Mac.
177 177
178See [[file:03-keys.org][Keys and commands]] for the Emacs bindings. 178See [[file:03-keys.org][Keys and commands]] for the Emacs bindings.
179 179
@@ -458,4 +458,4 @@ Quick Look in the Files app shows org files as the HTML export renders them.
458- The global capture hotkey and the Settings window. 458- The global capture hotkey and the Settings window.
459- Explicit saving. 459- Explicit saving.
460 460
461Commands the iOS app can't carry out show a message instead, such as "Not available on iOS yet" or "/Command/ isn't available on iPhone and iPad." Only tables that need Emacs say that Emacs is needed. Commands that only appear on the Mac aren't listed in Commands. Refile… in Commands (or =C-c C-w= with a hardware keyboard) refiles the entry at the caret, choosing the target as the agenda's Refile… does. 461Commands the iOS app can't carry out show a message instead: "/Command/ isn't available on iPhone and iPad. It runs on the Mac." Only tables that need Emacs say that Emacs is needed. Commands that only appear on the Mac aren't listed in Commands. Refile… in Commands (or =C-c C-w= with a hardware keyboard) refiles the entry at the caret, choosing the target as the agenda's Refile… does.
l10n/Localizable.xcstrings +6 −6 · view
@@ -435,37 +435,37 @@
435 } 435 }
436 } 436 }
437 }, 437 },
438 "%@ isn't available on iPhone and iPad.": { 438 "%@ isn't available on iPhone and iPad. It runs on the Mac.": {
439 "comment": "A command that runs only on the Mac", 439 "comment": "A command that runs only on the Mac",
440 "localizations": { 440 "localizations": {
441 "de": { 441 "de": {
442 "stringUnit": { 442 "stringUnit": {
443 "state": "translated", 443 "state": "translated",
444 "value": "%@ ist auf iPhone und iPad nicht verfügbar." 444 "value": "%@ ist auf iPhone und iPad nicht verfügbar, nur auf dem Mac."
445 } 445 }
446 }, 446 },
447 "es": { 447 "es": {
448 "stringUnit": { 448 "stringUnit": {
449 "state": "translated", 449 "state": "translated",
450 "value": "%@ no está disponible en iPhone ni en iPad." 450 "value": "%@ no está disponible en iPhone ni en iPad, solo en el Mac."
451 } 451 }
452 }, 452 },
453 "fr": { 453 "fr": {
454 "stringUnit": { 454 "stringUnit": {
455 "state": "translated", 455 "state": "translated",
456 "value": "%@ n'est pas disponible sur iPhone et iPad." 456 "value": "%@ n'est pas disponible sur iPhone et iPad, seulement sur Mac."
457 } 457 }
458 }, 458 },
459 "ja": { 459 "ja": {
460 "stringUnit": { 460 "stringUnit": {
461 "state": "translated", 461 "state": "translated",
462 "value": "%@はiPhoneとiPadでは利用できません。" 462 "value": "%@はiPhoneとiPadでは利用できません。Macで利用できます。"
463 } 463 }
464 }, 464 },
465 "pt-BR": { 465 "pt-BR": {
466 "stringUnit": { 466 "stringUnit": {
467 "state": "translated", 467 "state": "translated",
468 "value": "%@ não está disponível no iPhone e no iPad." 468 "value": "%@ não está disponível no iPhone e no iPad, só no Mac."
469 } 469 }
470 } 470 }
471 } 471 }
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form