Commit 7d137d1b02
Verified · cmc
Changed files (9)
- Sources/OrgstarMobile/AppMenus.swift added +157
- Sources/OrgstarMobile/AppSidebar.swift added +29
- Sources/OrgstarMobile/EditorSplitScreen.swift +66 −12
- Sources/OrgstarMobile/FoldersScreen.swift +8 −8
- Sources/OrgstarMobile/MobileEditorStore.swift +3
- Sources/OrgstarMobile/MobileModel.swift +2
- Sources/OrgstarMobile/OrgstarMobileApp.swift +107 −18
- docs/manual/guide/14-ios.org +18 −2
- l10n/Localizable.xcstrings +70
Sources/OrgstarMobile/AppMenus.swift added +157 · view
| @@ -0,0 +1,157 @@ | |||
| 1 | #if os(iOS) | ||
| 2 | import OrgApp | ||
| 3 | import OrgCore | ||
| 4 | import SwiftUI | ||
| 5 | |||
| 6 | /// What the menu bar does in the focused window. | ||
| 7 | struct WindowActions { | ||
| 8 | var show: (AppTab) -> Void | ||
| 9 | var capture: () -> Void | ||
| 10 | var addFolder: () -> Void | ||
| 11 | var board: () -> Void | ||
| 12 | var clock: (String) -> Void | ||
| 13 | } | ||
| 14 | |||
| 15 | /// The editor of the focused pane in the focused window. | ||
| 16 | struct EditorActions { | ||
| 17 | let editor: MobileEditor | ||
| 18 | } | ||
| 19 | |||
| 20 | extension FocusedValues { | ||
| 21 | @Entry var windowActions: WindowActions? | ||
| 22 | @Entry var editorActions: EditorActions? | ||
| 23 | } | ||
| 24 | |||
| 25 | /// The iPad menu bar, after the Mac's File, Edit, View and Org menus, with their keys, and Go | ||
| 26 | /// in place of the Mac's windows. | ||
| 27 | struct AppMenus: SwiftUI.Commands { | ||
| 28 | let model: MobileModel | ||
| 29 | @FocusedValue(\.windowActions) private var window | ||
| 30 | @FocusedValue(\.editorActions) private var editor | ||
| 31 | |||
| 32 | var body: some SwiftUI.Commands { | ||
| 33 | CommandGroup(after: .newItem) { | ||
| 34 | Button("Capture…") { window?.capture() } | ||
| 35 | .keyboardShortcut("n", modifiers: [.command, .shift]) | ||
| 36 | .disabled(window == nil) | ||
| 37 | Button("Add Folder…") { window?.addFolder() } | ||
| 38 | .keyboardShortcut("o", modifiers: [.command, .shift]) | ||
| 39 | .disabled(window == nil) | ||
| 40 | } | ||
| 41 | CommandGroup(replacing: .saveItem) { | ||
| 42 | Button("Save") { editor?.editor.run("app.save") } | ||
| 43 | .keyboardShortcut("s") | ||
| 44 | .disabled(editor == nil) | ||
| 45 | Button("Save All") { for path in model.session.dirtyPaths { _ = model.session.save(path) } } | ||
| 46 | .keyboardShortcut("s", modifiers: [.command, .option]) | ||
| 47 | .disabled(model.session.dirtyPaths.isEmpty) | ||
| 48 | } | ||
| 49 | CommandGroup(after: .textEditing) { | ||
| 50 | Button("Search Notes") { window?.show(.search) } | ||
| 51 | .keyboardShortcut("f", modifiers: [.command, .shift]) | ||
| 52 | .disabled(window == nil) | ||
| 53 | } | ||
| 54 | CommandGroup(after: .sidebar) { | ||
| 55 | editorItem("Split Pane Below", "app.split-below", "2", [.command, .control]) | ||
| 56 | editorItem("Split Pane Right", "app.split-right", "3", [.command, .control]) | ||
| 57 | editorItem("Close Pane", "app.pane-close", "0", [.command, .control]) | ||
| 58 | editorItem("Close Other Panes", "app.pane-only", "1", [.command, .control]) | ||
| 59 | editorItem("Next Pane", "app.pane-next", "`", [.command, .option]) | ||
| 60 | Divider() | ||
| 61 | Toggle("Show Markup", isOn: Bindable(model).showMarkup) | ||
| 62 | .keyboardShortcut("m", modifiers: [.command, .shift]) | ||
| 63 | Toggle("Truncate Long Lines", isOn: Binding(get: { editor?.editor.truncatesLines ?? false }, set: { _ in editor?.editor.run("editor.toggle-truncate-lines") })) | ||
| 64 | .disabled(editor == nil) | ||
| 65 | Toggle("Auto Fill", isOn: Binding(get: { editor?.editor.autoFills ?? false }, set: { _ in editor?.editor.run("editor.toggle-auto-fill") })) | ||
| 66 | .disabled(editor == nil) | ||
| 67 | } | ||
| 68 | CommandMenu("Org") { | ||
| 69 | Menu("Clock") { | ||
| 70 | ForEach(Self.clockCommands, id: \.id) { command in | ||
| 71 | Button(CommandTitle.localized(command.title)) { window?.clock(command.id) } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | .disabled(window == nil) | ||
| 75 | Divider() | ||
| 76 | OrgMenuItems(editor: editor?.editor) | ||
| 77 | } | ||
| 78 | CommandMenu("Go") { | ||
| 79 | Button("Agenda") { window?.show(.agenda) } | ||
| 80 | .keyboardShortcut("a", modifiers: [.command, .shift]) | ||
| 81 | Button("Board") { window?.board() } | ||
| 82 | .keyboardShortcut("b", modifiers: [.command, .shift]) | ||
| 83 | Button("Folders") { window?.show(.folders) } | ||
| 84 | Button("Settings") { window?.show(.settings) } | ||
| 85 | .keyboardShortcut(",") | ||
| 86 | Divider() | ||
| 87 | Button(CommandTitle.localized("Go to Clocked Entry")) { window?.clock("app.clock.goto") } | ||
| 88 | .disabled(model.clock.running == nil) | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | /// Clock commands that run without an editor, as the clock accessory runs them. | ||
| 93 | static let clockCommands = CommandPalette.viewCommands.filter { $0.id.hasPrefix("app.clock.") } + [("app.clock.report", "Clock Report")] | ||
| 94 | |||
| 95 | private func editorItem(_ title: LocalizedStringKey, _ id: String, _ key: KeyEquivalent, _ modifiers: EventModifiers) -> some View { | ||
| 96 | Button(title) { editor?.editor.run(id) } | ||
| 97 | .keyboardShortcut(key, modifiers: modifiers) | ||
| 98 | .disabled(editor == nil) | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | /// Org: the org commands and the app's commands for entries and notes, in the Mac's submenus, | ||
| 103 | /// with the keys that run them in the current keymap. | ||
| 104 | private struct OrgMenuItems: View { | ||
| 105 | let editor: MobileEditor? | ||
| 106 | |||
| 107 | /// The Mac's Org submenus (`Sources/Orgstar/OrgstarApp.swift`) and the command id prefixes | ||
| 108 | /// they hold. A command goes in the first submenu with a prefix it starts with. | ||
| 109 | static let groups: [(title: LocalizedStringKey, prefixes: [String])] = [ | ||
| 110 | ("Visibility", ["org.cycle", "org.fold.", "org.narrow.", "org.widen", "org.sparse-tree", "org.toggle-inline-images", "org.latex-preview"]), | ||
| 111 | ("Headings", ["org.heading.", "org.subtree.", "org.element.", "org.goto", "org.sort", "org.archive.", "app.refile", "app.archive"]), | ||
| 112 | ("TODO and Tags", ["org.todo.", "org.priority.", "org.tags.", "org.effort."]), | ||
| 113 | ("Properties and Columns", ["org.property.", "org.columns", "org.drawer."]), | ||
| 114 | ("Dates and Timers", ["org.schedule", "org.deadline", "org.timestamp.", "org.timer."]), | ||
| 115 | ("Lists", ["org.item.", "org.checkbox."]), | ||
| 116 | ("Tables", ["org.table", "app.table-", "app.plot"]), | ||
| 117 | ("Links and Footnotes", ["org.link.", "org.id.", "org.footnote."]), | ||
| 118 | ("Blocks", ["org.babel.", "org.structure-template", "org.edit-special", "org.dblock.", "org.clock.report", "org.denote."]), | ||
| 119 | ("Text", ["org.emphasize", "org.fill-"]), | ||
| 120 | ("Attachments", ["app.attach."]), | ||
| 121 | ("Notes", ["app.dailies.", "app.node."]), | ||
| 122 | ("Encryption", ["app.crypt."]), | ||
| 123 | ] | ||
| 124 | |||
| 125 | private static func group(of id: String) -> Int? { | ||
| 126 | groups.firstIndex { $0.prefixes.contains { id.hasPrefix($0) } } | ||
| 127 | } | ||
| 128 | |||
| 129 | /// The commands the iOS editor knows, less the ones the App Store build hides, once each. | ||
| 130 | private static let shown: [(id: String, title: String)] = { | ||
| 131 | var seen = Set<String>() | ||
| 132 | return (CommandPalette.viewCommands + OrgCore.Commands.everything.map { ($0.id, $0.title) }) | ||
| 133 | .filter { ($0.id.hasPrefix("org.") || group(of: $0.id) != nil) && !AppStoreCommands.hidden.contains($0.id) && seen.insert($0.id).inserted } | ||
| 134 | }() | ||
| 135 | |||
| 136 | var body: some View { | ||
| 137 | // Commands that fit no subject, such as Act at Point, come first. | ||
| 138 | ForEach(Self.shown.filter { Self.group(of: $0.id) == nil }, id: \.id) { item($0) } | ||
| 139 | Divider() | ||
| 140 | ForEach(Self.groups.indices, id: \.self) { index in | ||
| 141 | Menu(Self.groups[index].title) { | ||
| 142 | ForEach(Self.shown.filter { Self.group(of: $0.id) == index }, id: \.id) { item($0) } | ||
| 143 | } | ||
| 144 | } | ||
| 145 | } | ||
| 146 | |||
| 147 | private func item(_ command: (id: String, title: String)) -> some View { | ||
| 148 | Button { | ||
| 149 | editor?.run(command.id) | ||
| 150 | } label: { | ||
| 151 | Text(CommandTitle.localized(command.title)) | ||
| 152 | if let keys = editor?.keymap.keyLabels(for: command.id).first { Text(keys) } | ||
| 153 | } | ||
| 154 | .disabled(editor == nil) | ||
| 155 | } | ||
| 156 | } | ||
| 157 | #endif | ||
Sources/OrgstarMobile/AppSidebar.swift added +29 · view
| @@ -0,0 +1,29 @@ | |||
| 1 | #if os(iOS) | ||
| 2 | import OrgApp | ||
| 3 | import SwiftUI | ||
| 4 | |||
| 5 | /// The sidebar of a regular-width iPad window: the iPhone's tabs, search, and each added folder. | ||
| 6 | struct AppSidebar: View { | ||
| 7 | let workspace: WorkspaceModel | ||
| 8 | @Binding var selection: AppTab | ||
| 9 | |||
| 10 | var body: some View { | ||
| 11 | List(selection: Binding<AppTab?> { selection } set: { if let new = $0 { selection = new } }) { | ||
| 12 | Section { | ||
| 13 | Label("Agenda", systemImage: "calendar").tag(AppTab.agenda) | ||
| 14 | Label("Search", systemImage: "magnifyingglass").tag(AppTab.search) | ||
| 15 | } | ||
| 16 | Section("Folders") { | ||
| 17 | Label("All Folders", systemImage: "folder").tag(AppTab.folders) | ||
| 18 | ForEach(workspace.rootPaths, id: \.self) { root in | ||
| 19 | Label((root as NSString).lastPathComponent, systemImage: "folder").tag(AppTab.folder(root)) | ||
| 20 | } | ||
| 21 | } | ||
| 22 | Section { | ||
| 23 | Label("Settings", systemImage: "gearshape").tag(AppTab.settings) | ||
| 24 | } | ||
| 25 | } | ||
| 26 | .navigationTitle(Text(verbatim: "orgstar")) | ||
| 27 | } | ||
| 28 | } | ||
| 29 | #endif | ||
Sources/OrgstarMobile/EditorSplitScreen.swift +66 −12 · view
| @@ -59,6 +59,12 @@ final class EditorSplit { | |||
| 59 | return nil | 59 | return nil |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | /// Sets the first side's share of the split between `before` and `after`, as dragging its | ||
| 63 | /// divider does. | ||
| 64 | func setFraction(_ fraction: Double, ofSplitBetween before: PaneID, and after: PaneID) { | ||
| 65 | layout = layout.settingFraction(fraction, ofSplitBetween: before, and: after) | ||
| 66 | } | ||
| 67 | |||
| 62 | private func close(_ id: PaneID, session: DocumentSession, store: MobileEditorStore) { | 68 | private func close(_ id: PaneID, session: DocumentSession, store: MobileEditorStore) { |
| 63 | guard let rest = layout.removing(id) else { return } | 69 | guard let rest = layout.removing(id) else { return } |
| 64 | let next = layout.next(after: id) | 70 | let next = layout.next(after: id) |
| @@ -87,6 +93,8 @@ struct EditorSplitScreen: View { | |||
| 87 | layoutView(split.layout, split: split) | 93 | layoutView(split.layout, split: split) |
| 88 | .navigationTitle(split.paths[split.focused].map { session.bufferName($0) + (session.dirtyPaths.contains($0) ? " •" : "") } ?? "") | 94 | .navigationTitle(split.paths[split.focused].map { session.bufferName($0) + (session.dirtyPaths.contains($0) ? " •" : "") } ?? "") |
| 89 | .navigationBarTitleDisplayMode(.inline) | 95 | .navigationBarTitleDisplayMode(.inline) |
| 96 | // The menu bar's editor commands act on the focused pane. | ||
| 97 | .focusedSceneValue(\.editorActions, split.paths[split.focused].flatMap { model.editors.existing($0) }.map(EditorActions.init)) | ||
| 90 | } else { | 98 | } else { |
| 91 | ProgressView() | 99 | ProgressView() |
| 92 | } | 100 | } |
| @@ -112,20 +120,66 @@ struct EditorSplitScreen: View { | |||
| 112 | if split.isSplit, split.focused == id { Rectangle().fill(Color.accentColor).frame(height: 2) } | 120 | if split.isSplit, split.focused == id { Rectangle().fill(Color.accentColor).frame(height: 2) } |
| 113 | } | 121 | } |
| 114 | ) | 122 | ) |
| 115 | case .split(let axis, let first, let second, _): | 123 | case .split(let axis, let first, let second, let fraction): |
| 116 | if axis == .horizontal { | 124 | return AnyView(GeometryReader { geometry in |
| 117 | return AnyView(HStack(spacing: 0) { | 125 | let total = axis == .horizontal ? geometry.size.width : geometry.size.height |
| 118 | layoutView(first, split: split) | 126 | let firstSize = max(120, min(max(120, total - 120), total * fraction)) |
| 119 | Divider() | 127 | let divider = PaneDivider(axis: axis, firstSize: firstSize, total: total) { size in |
| 120 | layoutView(second, split: split) | 128 | split.setFraction(size / max(total, 1), ofSplitBetween: first.panes[first.panes.count - 1], and: second.panes[0]) |
| 121 | }) | 129 | } |
| 122 | } | 130 | if axis == .horizontal { |
| 123 | return AnyView(VStack(spacing: 0) { | 131 | HStack(spacing: 0) { |
| 124 | layoutView(first, split: split) | 132 | layoutView(first, split: split).frame(width: firstSize) |
| 125 | Divider() | 133 | divider |
| 126 | layoutView(second, split: split) | 134 | layoutView(second, split: split).frame(maxWidth: .infinity) |
| 135 | } | ||
| 136 | } else { | ||
| 137 | VStack(spacing: 0) { | ||
| 138 | layoutView(first, split: split).frame(height: firstSize) | ||
| 139 | divider | ||
| 140 | layoutView(second, split: split).frame(maxHeight: .infinity) | ||
| 141 | } | ||
| 142 | } | ||
| 127 | }) | 143 | }) |
| 128 | } | 144 | } |
| 129 | } | 145 | } |
| 130 | } | 146 | } |
| 147 | |||
| 148 | /// The line between two panes, with a wider area to drag; dragging resizes the first pane. | ||
| 149 | private struct PaneDivider: View { | ||
| 150 | let axis: PaneLayout.Axis | ||
| 151 | let firstSize: CGFloat | ||
| 152 | let total: CGFloat | ||
| 153 | let resize: (CGFloat) -> Void | ||
| 154 | @State private var start: CGFloat? | ||
| 155 | |||
| 156 | var body: some View { | ||
| 157 | let horizontal = axis == .horizontal | ||
| 158 | Rectangle() | ||
| 159 | .fill(Color(uiColor: .separator)) | ||
| 160 | .frame(width: horizontal ? 1 : nil, height: horizontal ? nil : 1) | ||
| 161 | .frame(maxWidth: horizontal ? 1 : .infinity, maxHeight: horizontal ? .infinity : 1) | ||
| 162 | .overlay { | ||
| 163 | Capsule().fill(Color(uiColor: .tertiaryLabel)) | ||
| 164 | .frame(width: horizontal ? 4 : 36, height: horizontal ? 36 : 4) | ||
| 165 | } | ||
| 166 | .overlay { | ||
| 167 | Color.clear | ||
| 168 | .frame(width: horizontal ? 20 : nil, height: horizontal ? nil : 20) | ||
| 169 | .contentShape(Rectangle()) | ||
| 170 | .gesture(DragGesture(minimumDistance: 1).onChanged { drag in | ||
| 171 | let base = start ?? firstSize | ||
| 172 | start = base | ||
| 173 | resize(base + (horizontal ? drag.translation.width : drag.translation.height)) | ||
| 174 | }.onEnded { _ in start = nil }) | ||
| 175 | .hoverEffect(.highlight) | ||
| 176 | } | ||
| 177 | .accessibilityElement() | ||
| 178 | .accessibilityLabel(Text("Pane Divider")) | ||
| 179 | .accessibilityValue(Text(Double(firstSize / max(total, 1)), format: .percent.precision(.fractionLength(0)))) | ||
| 180 | .accessibilityAdjustableAction { direction in | ||
| 181 | resize(firstSize + (direction == .increment ? 0.1 : -0.1) * total) | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 131 | #endif | 185 | #endif |
Sources/OrgstarMobile/FoldersScreen.swift +8 −8 · view
| @@ -7,7 +7,6 @@ import UniformTypeIdentifiers | |||
| 7 | struct FoldersScreen: View { | 7 | struct FoldersScreen: View { |
| 8 | let workspace: WorkspaceModel | 8 | let workspace: WorkspaceModel |
| 9 | let session: DocumentSession | 9 | let session: DocumentSession |
| 10 | @State private var importing = false | ||
| 11 | /// The file whose deletion is being confirmed. | 10 | /// The file whose deletion is being confirmed. |
| 12 | @State private var deleting: String? | 11 | @State private var deleting: String? |
| 13 | /// Counts deletions and new folders, so the list reads the empty folders on disk again. | 12 | /// Counts deletions and new folders, so the list reads the empty folders on disk again. |
| @@ -87,13 +86,13 @@ struct FoldersScreen: View { | |||
| 87 | } description: { | 86 | } description: { |
| 88 | Text("Add the folder your org files are in, from iCloud Drive or another app's storage.") | 87 | Text("Add the folder your org files are in, from iCloud Drive or another app's storage.") |
| 89 | } actions: { | 88 | } actions: { |
| 90 | Button("Add Folder") { importing = true } | 89 | Button("Add Folder") { model.addingFolder = true } |
| 91 | } | 90 | } |
| 92 | } | 91 | } |
| 93 | } | 92 | } |
| 94 | .toolbar { | 93 | .toolbar { |
| 95 | ToolbarItem(placement: .topBarLeading) { | 94 | ToolbarItem(placement: .topBarLeading) { |
| 96 | Button("Add Folder", systemImage: "folder.badge.plus") { importing = true } | 95 | Button("Add Folder", systemImage: "folder.badge.plus") { model.addingFolder = true } |
| 97 | } | 96 | } |
| 98 | if !workspace.rootPaths.isEmpty { | 97 | if !workspace.rootPaths.isEmpty { |
| 99 | ToolbarItem(placement: .primaryAction) { | 98 | ToolbarItem(placement: .primaryAction) { |
| @@ -117,7 +116,7 @@ struct FoldersScreen: View { | |||
| 117 | } | 116 | } |
| 118 | } | 117 | } |
| 119 | } | 118 | } |
| 120 | .fileImporter(isPresented: $importing, allowedContentTypes: [.folder]) { result in | 119 | .fileImporter(isPresented: Bindable(model).addingFolder, allowedContentTypes: [.folder]) { result in |
| 121 | guard case .success(let url) = result else { return } | 120 | guard case .success(let url) = result else { return } |
| 122 | // Kept for the bookmark; WorkspaceRoot resolves it with access again at launch. | 121 | // Kept for the bookmark; WorkspaceRoot resolves it with access again at launch. |
| 123 | _ = url.startAccessingSecurityScopedResource() | 122 | _ = url.startAccessingSecurityScopedResource() |
| @@ -145,8 +144,9 @@ extension FoldersScreen { | |||
| 145 | } | 144 | } |
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | /// A subfolder's own list, asking about its own changes. | 147 | /// A subfolder's own list, asking about its own changes; an added folder's, from the iPad's |
| 149 | private struct FolderPage: View { | 148 | /// sidebar. |
| 149 | struct FolderPage: View { | ||
| 150 | let workspace: WorkspaceModel | 150 | let workspace: WorkspaceModel |
| 151 | let session: DocumentSession | 151 | let session: DocumentSession |
| 152 | let route: FolderRoute | 152 | let route: FolderRoute |
| @@ -155,9 +155,9 @@ private struct FolderPage: View { | |||
| 155 | @State private var creating: NewItem? | 155 | @State private var creating: NewItem? |
| 156 | 156 | ||
| 157 | var body: some View { | 157 | var body: some View { |
| 158 | let folder = route.root + "/" + route.folder | 158 | let folder = route.folder.isEmpty ? route.root : route.root + "/" + route.folder |
| 159 | List { FolderContents(workspace: workspace, root: route.root, folder: route.folder, deleting: $deleting, changes: changes) } | 159 | List { FolderContents(workspace: workspace, root: route.root, folder: route.folder, deleting: $deleting, changes: changes) } |
| 160 | .navigationTitle((route.folder as NSString).lastPathComponent) | 160 | .navigationTitle(((route.folder.isEmpty ? route.root : route.folder) as NSString).lastPathComponent) |
| 161 | .confirmDeletion($deleting, workspace: workspace, session: session) { changes += 1 } | 161 | .confirmDeletion($deleting, workspace: workspace, session: session) { changes += 1 } |
| 162 | .createItem($creating, workspace: workspace) { changes += 1 } | 162 | .createItem($creating, workspace: workspace) { changes += 1 } |
| 163 | .toolbar { | 163 | .toolbar { |
Sources/OrgstarMobile/MobileEditorStore.swift +3 · view
| @@ -21,6 +21,9 @@ final class MobileEditorStore { | |||
| 21 | return made | 21 | return made |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | /// The editor of `path`, when a pane shows it. | ||
| 25 | func existing(_ path: String) -> MobileEditor? { editors[path] } | ||
| 26 | |||
| 24 | /// The text view `pane` shows `editor` in: one no other pane owns, else a new one. | 27 | /// The text view `pane` shows `editor` in: one no other pane owns, else a new one. |
| 25 | func view(for pane: PaneID, of editor: MobileEditor) -> UITextView { | 28 | func view(for pane: PaneID, of editor: MobileEditor) -> UITextView { |
| 26 | if let owned = editor.textViews.first(where: { owners[ObjectIdentifier($0)] == pane }) { return owned } | 29 | if let owned = editor.textViews.first(where: { owners[ObjectIdentifier($0)] == pane }) { return owned } |
Sources/OrgstarMobile/MobileModel.swift +2 · view
| @@ -39,6 +39,8 @@ final class MobileModel { | |||
| 39 | var agendaRequest: AgendaDays? | 39 | var agendaRequest: AgendaDays? |
| 40 | /// A capture to show, from the agenda or the capture control. | 40 | /// A capture to show, from the agenda or the capture control. |
| 41 | var captureRequest: CaptureRequest? | 41 | var captureRequest: CaptureRequest? |
| 42 | /// Folders shows its folder picker, from File ▸ Add Folder… in the menu bar. | ||
| 43 | var addingFolder = false | ||
| 42 | /// Calendar's events for the agenda, with `calendar-events`. | 44 | /// Calendar's events for the agenda, with `calendar-events`. |
| 43 | let calendarEvents = CalendarEvents() | 45 | let calendarEvents = CalendarEvents() |
| 44 | /// Captures the watch sent, for the root view to pick up from the inbox. | 46 | /// Captures the watch sent, for the root view to pick up from the inbox. |
Sources/OrgstarMobile/OrgstarMobileApp.swift +107 −18 · view
| @@ -45,6 +45,7 @@ struct OrgstarMobileApp: App { | |||
| 45 | .onChange(of: scenePhase) { _, phase in | 45 | .onChange(of: scenePhase) { _, phase in |
| 46 | if phase == .background { model.clock.wentAway() } | 46 | if phase == .background { model.clock.wentAway() } |
| 47 | } | 47 | } |
| 48 | .commands { AppMenus(model: model) } | ||
| 48 | } | 49 | } |
| 49 | } | 50 | } |
| 50 | 51 | ||
| @@ -72,11 +73,25 @@ final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCent | |||
| 72 | } | 73 | } |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | enum AppTab: Hashable { case agenda, folders, settings } | 76 | /// A tab on iPhone, or a row of the sidebar on a regular-width iPad, which also lists search |
| 77 | /// and each added folder. | ||
| 78 | enum AppTab: Hashable { case agenda, search, folders, folder(String), settings } | ||
| 76 | 79 | ||
| 77 | /// The search screen, pushed from the Agenda and Folders tabs. | 80 | /// The search screen, pushed from the Agenda and Folders tabs. |
| 78 | struct SearchRoute: Hashable {} | 81 | struct SearchRoute: Hashable {} |
| 79 | 82 | ||
| 83 | extension AppTab { | ||
| 84 | /// The tab that shows this on iPhone: search is pushed from Agenda and Folders, and folders | ||
| 85 | /// are listed in Folders. | ||
| 86 | var inTabBar: AppTab { | ||
| 87 | switch self { | ||
| 88 | case .search: .agenda | ||
| 89 | case .folder: .folders | ||
| 90 | default: self | ||
| 91 | } | ||
| 92 | } | ||
| 93 | } | ||
| 94 | |||
| 80 | extension View { | 95 | extension View { |
| 81 | /// Readers pushed for `ReaderRoute`s. | 96 | /// Readers pushed for `ReaderRoute`s. |
| 82 | func readerDestination(workspace: WorkspaceModel, session: DocumentSession) -> some View { | 97 | func readerDestination(workspace: WorkspaceModel, session: DocumentSession) -> some View { |
| @@ -129,7 +144,9 @@ struct RootView: View { | |||
| 129 | @State private var agendaPath = NavigationPath() | 144 | @State private var agendaPath = NavigationPath() |
| 130 | @State private var hour = 0 | 145 | @State private var hour = 0 |
| 131 | @State private var showingClockReport = false | 146 | @State private var showingClockReport = false |
| 147 | @State private var showingBoard = false | ||
| 132 | @State private var message: String? | 148 | @State private var message: String? |
| 149 | @Environment(\.horizontalSizeClass) private var sizeClass | ||
| 133 | @Environment(\.scenePhase) private var scenePhase | 150 | @Environment(\.scenePhase) private var scenePhase |
| 134 | @AppStorage(OnboardingScreen.doneKey) private var onboarded = false | 151 | @AppStorage(OnboardingScreen.doneKey) private var onboarded = false |
| 135 | @State private var onboarding = false | 152 | @State private var onboarding = false |
| @@ -188,29 +205,91 @@ struct RootView: View { | |||
| 188 | var hour: Int | 205 | var hour: Int |
| 189 | } | 206 | } |
| 190 | 207 | ||
| 191 | var body: some View { | 208 | /// Tabs on iPhone and in a narrow window; a sidebar beside the content on a wider iPad. |
| 192 | TabView(selection: $tab) { | 209 | private var tabs: some View { |
| 193 | Tab("Agenda", systemImage: "calendar", value: .agenda) { | 210 | TabView(selection: Binding { tab.inTabBar } set: { tab = $0 }) { |
| 194 | NavigationStack(path: $agendaPath) { | 211 | Tab("Agenda", systemImage: "calendar", value: .agenda) { agendaStack } |
| 195 | AgendaScreen(workspace: workspace, session: session, agenda: agenda, scheduler: model.scheduler) | 212 | Tab("Folders", systemImage: "folder", value: .folders) { foldersStack } |
| 196 | .equatable() | 213 | Tab("Settings", systemImage: "gearshape", value: .settings) { settingsStack } |
| 197 | .toolbar { searchButton; captureButton } | 214 | } |
| 198 | .readerDestination(workspace: workspace, session: session) | 215 | .clockAccessory(model.clock, perform: clock) |
| 216 | } | ||
| 217 | |||
| 218 | private var split: some View { | ||
| 219 | NavigationSplitView { | ||
| 220 | AppSidebar(workspace: workspace, selection: $tab) | ||
| 221 | } detail: { | ||
| 222 | Group { | ||
| 223 | switch tab { | ||
| 224 | case .agenda: agendaStack | ||
| 225 | case .search: | ||
| 226 | NavigationStack { | ||
| 227 | SearchScreen(workspace: workspace, session: session) | ||
| 228 | .toolbar { captureButton } | ||
| 229 | .readerDestination(workspace: workspace, session: session) | ||
| 230 | } | ||
| 231 | case .folders: foldersStack | ||
| 232 | case .folder(let root): | ||
| 233 | NavigationStack { | ||
| 234 | FolderPage(workspace: workspace, session: session, route: FolderRoute(root: root, folder: "")) | ||
| 235 | .toolbar { searchButton; captureButton } | ||
| 236 | .readerDestination(workspace: workspace, session: session) | ||
| 237 | .navigationDestination(for: FolderRoute.self) { FolderPage(workspace: workspace, session: session, route: $0) } | ||
| 238 | } | ||
| 239 | .id(root) | ||
| 240 | case .settings: settingsStack | ||
| 199 | } | 241 | } |
| 200 | } | 242 | } |
| 201 | Tab("Folders", systemImage: "folder", value: .folders) { | 243 | .safeAreaInset(edge: .bottom) { |
| 202 | NavigationStack { | 244 | if let running = model.clock.running { |
| 203 | FoldersScreen(workspace: workspace, session: session) | 245 | ClockAccessory(running: running, clock: model.clock, perform: clock).padding(.vertical, 8).background(.bar) |
| 204 | .toolbar { searchButton; captureButton } | ||
| 205 | .readerDestination(workspace: workspace, session: session) | ||
| 206 | } | 246 | } |
| 207 | } | 247 | } |
| 208 | Tab("Settings", systemImage: "gearshape", value: .settings) { | ||
| 209 | NavigationStack { SettingsScreen(model: model) } | ||
| 210 | } | ||
| 211 | } | 248 | } |
| 212 | .clockAccessory(model.clock, perform: clock) | 249 | } |
| 250 | |||
| 251 | private var agendaStack: some View { | ||
| 252 | NavigationStack(path: $agendaPath) { | ||
| 253 | AgendaScreen(workspace: workspace, session: session, agenda: agenda, scheduler: model.scheduler) | ||
| 254 | .equatable() | ||
| 255 | .toolbar { searchButton; captureButton } | ||
| 256 | .readerDestination(workspace: workspace, session: session) | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | private var foldersStack: some View { | ||
| 261 | NavigationStack { | ||
| 262 | FoldersScreen(workspace: workspace, session: session) | ||
| 263 | .toolbar { searchButton; captureButton } | ||
| 264 | .readerDestination(workspace: workspace, session: session) | ||
| 265 | } | ||
| 266 | } | ||
| 267 | |||
| 268 | private var settingsStack: some View { | ||
| 269 | NavigationStack { SettingsScreen(model: model) } | ||
| 270 | } | ||
| 271 | |||
| 272 | var body: some View { | ||
| 273 | // One view around both layouts, so that what follows runs once, not again when the | ||
| 274 | // window's width class changes. | ||
| 275 | ZStack { | ||
| 276 | if sizeClass == .regular { split } else { tabs } | ||
| 277 | } | ||
| 213 | .tint(model.theme.accentColor) | 278 | .tint(model.theme.accentColor) |
| 279 | .focusedSceneValue(\.windowActions, WindowActions( | ||
| 280 | show: show, capture: { capture = CaptureRequest() }, | ||
| 281 | addFolder: { | ||
| 282 | tab = .folders | ||
| 283 | model.addingFolder = true | ||
| 284 | }, | ||
| 285 | board: { showingBoard = true }, clock: clock)) | ||
| 286 | .fullScreenCover(isPresented: $showingBoard) { | ||
| 287 | BoardScreen(workspace: workspace, session: session) { showingBoard = false } | ||
| 288 | } | ||
| 289 | // A removed folder's row goes from the sidebar. | ||
| 290 | .onChange(of: workspace.rootPaths) { | ||
| 291 | if case .folder(let root) = tab, !workspace.rootPaths.contains(root) { tab = .folders } | ||
| 292 | } | ||
| 214 | // Until a folder is added there is nothing for the agenda to show. | 293 | // Until a folder is added there is nothing for the agenda to show. |
| 215 | .onAppear { | 294 | .onAppear { |
| 216 | if workspace.rootPaths.isEmpty { tab = .folders } | 295 | if workspace.rootPaths.isEmpty { tab = .folders } |
| @@ -401,6 +480,16 @@ struct RootView: View { | |||
| 401 | } | 480 | } |
| 402 | } | 481 | } |
| 403 | 482 | ||
| 483 | /// A tab or sidebar row; on iPhone, search is pushed on the agenda. | ||
| 484 | private func show(_ destination: AppTab) { | ||
| 485 | if destination == .search, sizeClass != .regular { | ||
| 486 | tab = .agenda | ||
| 487 | agendaPath.append(SearchRoute()) | ||
| 488 | } else { | ||
| 489 | tab = destination | ||
| 490 | } | ||
| 491 | } | ||
| 492 | |||
| 404 | /// A widget's or the Live Activity's link. | 493 | /// A widget's or the Live Activity's link. |
| 405 | private func open(_ link: AppLink) { | 494 | private func open(_ link: AppLink) { |
| 406 | switch link { | 495 | switch link { |
docs/manual/guide/14-ios.org +18 −2 · view
| @@ -12,6 +12,8 @@ On first launch, a few screens introduce the app, ask for the folder of org file | |||
| 12 | 12 | ||
| 13 | The search button (the magnifying glass) at the top right of Agenda and Folders opens Search. | 13 | The search button (the magnifying glass) at the top right of Agenda and Folders opens Search. |
| 14 | 14 | ||
| 15 | On an iPad, and in an iPad window wide enough, a sidebar takes the place of the tabs: Agenda, Search, All Folders and each added folder on its own row, and Settings. In a narrow window, such as Slide Over or a narrow split, the tabs come back. | ||
| 16 | |||
| 15 | Files open in a reader first. The Edit button in the reader opens the editor. Both use the same open file, so an edit in the editor shows in the reader when you go back. | 17 | Files open in a reader first. The Edit button in the reader opens the editor. Both use the same open file, so an edit in the editor shows in the reader when you go back. |
| 16 | 18 | ||
| 17 | * Folders and file access | 19 | * Folders and file access |
| @@ -71,7 +73,7 @@ On iPad, the editor can show a file in several panes, as a Mac window does (see | |||
| 71 | | Close Pane | More ▸ Panes, Commands, a hardware keyboard | =C-x 0= | Closes the focused pane | | 73 | | Close Pane | More ▸ Panes, Commands, a hardware keyboard | =C-x 0= | Closes the focused pane | |
| 72 | | Close Other Panes | More ▸ Panes, Commands, a hardware keyboard | =C-x 1= | Closes every pane but the focused one | | 74 | | Close Other Panes | More ▸ Panes, Commands, a hardware keyboard | =C-x 1= | Closes every pane but the focused one | |
| 73 | 75 | ||
| 74 | The focused pane has a line along its top and the toolbar acts on it; tap in a pane to focus it. Every pane shows the same buffer: text typed in one shows in the others at once, and folds, narrowing and styles are the buffer's. The caret and scroll position are each pane's own, and so is undo: Undo in a pane undoes what was typed or changed in that pane. A link to another file opens it on its own screen, leaving the panes as they are. | 76 | The focused pane has a line along its top and the toolbar acts on it; tap in a pane to focus it. Drag the line between two panes to resize them; with VoiceOver, swipe up or down on it. Every pane shows the same buffer: text typed in one shows in the others at once, and folds, narrowing and styles are the buffer's. The caret and scroll position are each pane's own, and so is undo: Undo in a pane undoes what was typed or changed in that pane. A link to another file opens it on its own screen, leaving the panes as they are. |
| 75 | 77 | ||
| 76 | Each iPad window (scene), opened from the app switcher or by dragging the app from the Dock, has its own tabs, screens and panes over the same open files, so a file edited in one window shows the edit in the others. The pane commands aren't offered on iPhone or in a narrow window. Close Pane with one pane says "This is the only pane." | 78 | Each iPad window (scene), opened from the app switcher or by dragging the app from the Dock, has its own tabs, screens and panes over the same open files, so a file edited in one window shows the edit in the others. The pane commands aren't offered on iPhone or in a narrow window. Close Pane with one pane says "This is the only pane." |
| 77 | 79 | ||
| @@ -168,6 +170,20 @@ Archive Subtree in Commands (or =C-c C-x C-s= with a hardware keyboard) archives | |||
| 168 | 170 | ||
| 169 | More ▸ Encryption has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode. | 171 | More ▸ Encryption has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode. |
| 170 | 172 | ||
| 173 | ** The menu bar on iPad | ||
| 174 | |||
| 175 | The iPad's menu bar, and the list of keys shown while =⌘= is held on a hardware keyboard, have these menus, after the Mac's and with the Mac's keys: | ||
| 176 | |||
| 177 | | Menu | Items | | ||
| 178 | |------+-----------------------------------------------------------------------------------------------------------| | ||
| 179 | | File | Capture… (=⇧⌘N=), Add Folder… (=⇧⌘O=), Save (=⌘S=), Save All (=⌥⌘S=) | | ||
| 180 | | Edit | Search Notes (=⇧⌘F=), with the system's Undo, Redo and Find | | ||
| 181 | | View | Split Pane Below (=⌃⌘2=), Split Pane Right (=⌃⌘3=), Close Pane (=⌃⌘0=), Close Other Panes (=⌃⌘1=), Next Pane (=⌥⌘`=), Show Markup (=⇧⌘M=), Truncate Long Lines, Auto Fill | | ||
| 182 | | Org | Clock, then the org commands in the Mac's submenus (Visibility, Headings, TODO and Tags, Properties and Columns, Dates and Timers, Lists, Tables, Links and Footnotes, Blocks, Text, Attachments, Notes, Encryption), each with its key in the keymap | | ||
| 183 | | Go | Agenda (=⇧⌘A=), Board (=⇧⌘B=), Folders, Settings (=⌘,=), Go to Clocked Entry | | ||
| 184 | |||
| 185 | The Save, View and Org items act on the focused pane of the editor, and are dimmed when no editor is open. A command that doesn't apply at the caret says why, as it does from Commands. | ||
| 186 | |||
| 171 | ** Hardware keyboard | 187 | ** Hardware keyboard |
| 172 | 188 | ||
| 173 | With a hardware keyboard, the editor uses the preset =keymap= sets in the folder's =config.toml= (=emacs=, =mac= or =doom=), with the folder's =keymap.toml= on it. The Doom preset brings Vim keys; see [[file:03-keys.org][Keys]]. Bindings with =⌘= stay with iOS, so the Mac preset adds little. | 189 | With a hardware keyboard, the editor uses the preset =keymap= sets in the folder's =config.toml= (=emacs=, =mac= or =doom=), with the folder's =keymap.toml= on it. The Doom preset brings Vim keys; see [[file:03-keys.org][Keys]]. Bindings with =⌘= stay with iOS, so the Mac preset adds little. |
| @@ -457,7 +473,7 @@ Quick Look in the Files app shows org files as the HTML export renders them. | |||
| 457 | - In the download version, LaTeX-made PDF export. | 473 | - In the download version, LaTeX-made PDF export. |
| 458 | - Idle detection from keyboard and mouse input; iOS uses the time away from the app instead. | 474 | - Idle detection from keyboard and mouse input; iOS uses the time away from the app instead. |
| 459 | - In the download version, attaching by hard link or symbolic link. | 475 | - In the download version, attaching by hard link or symbolic link. |
| 460 | - The Columns inspector, the buffer list and tab bar, and resizing panes by dragging their divider. The board and column view are there (see [[file:07-agenda.org][The agenda]] and [[file:04-outlines.org][Outlines]]). | 476 | - The Columns inspector, and the buffer list and tab bar. The board and column view are there (see [[file:07-agenda.org][The agenda]] and [[file:04-outlines.org][Outlines]]). |
| 461 | - The global capture hotkey and the Settings window. | 477 | - The global capture hotkey and the Settings window. |
| 462 | - Explicit saving. | 478 | - Explicit saving. |
| 463 | 479 | ||
l10n/Localizable.xcstrings +70 · view
| @@ -16378,6 +16378,41 @@ | |||
| 16378 | } | 16378 | } |
| 16379 | } | 16379 | } |
| 16380 | }, | 16380 | }, |
| 16381 | "Go": { | ||
| 16382 | "comment": "The iPad menu bar's Go menu", | ||
| 16383 | "localizations": { | ||
| 16384 | "de": { | ||
| 16385 | "stringUnit": { | ||
| 16386 | "state": "translated", | ||
| 16387 | "value": "Gehe zu" | ||
| 16388 | } | ||
| 16389 | }, | ||
| 16390 | "es": { | ||
| 16391 | "stringUnit": { | ||
| 16392 | "state": "translated", | ||
| 16393 | "value": "Ir" | ||
| 16394 | } | ||
| 16395 | }, | ||
| 16396 | "fr": { | ||
| 16397 | "stringUnit": { | ||
| 16398 | "state": "translated", | ||
| 16399 | "value": "Aller" | ||
| 16400 | } | ||
| 16401 | }, | ||
| 16402 | "ja": { | ||
| 16403 | "stringUnit": { | ||
| 16404 | "state": "translated", | ||
| 16405 | "value": "移動" | ||
| 16406 | } | ||
| 16407 | }, | ||
| 16408 | "pt-BR": { | ||
| 16409 | "stringUnit": { | ||
| 16410 | "state": "translated", | ||
| 16411 | "value": "Ir" | ||
| 16412 | } | ||
| 16413 | } | ||
| 16414 | } | ||
| 16415 | }, | ||
| 16381 | "Go to Clocked Entry": { | 16416 | "Go to Clocked Entry": { |
| 16382 | "comment": "Command title", | 16417 | "comment": "Command title", |
| 16383 | "localizations": { | 16418 | "localizations": { |
| @@ -26777,6 +26812,41 @@ | |||
| 26777 | } | 26812 | } |
| 26778 | } | 26813 | } |
| 26779 | }, | 26814 | }, |
| 26815 | "Pane Divider": { | ||
| 26816 | "comment": "VoiceOver name of the line between two editor panes", | ||
| 26817 | "localizations": { | ||
| 26818 | "de": { | ||
| 26819 | "stringUnit": { | ||
| 26820 | "state": "translated", | ||
| 26821 | "value": "Bereichstrenner" | ||
| 26822 | } | ||
| 26823 | }, | ||
| 26824 | "es": { | ||
| 26825 | "stringUnit": { | ||
| 26826 | "state": "translated", | ||
| 26827 | "value": "Divisor de paneles" | ||
| 26828 | } | ||
| 26829 | }, | ||
| 26830 | "fr": { | ||
| 26831 | "stringUnit": { | ||
| 26832 | "state": "translated", | ||
| 26833 | "value": "Séparateur de sous-fenêtres" | ||
| 26834 | } | ||
| 26835 | }, | ||
| 26836 | "ja": { | ||
| 26837 | "stringUnit": { | ||
| 26838 | "state": "translated", | ||
| 26839 | "value": "ペインの区切り" | ||
| 26840 | } | ||
| 26841 | }, | ||
| 26842 | "pt-BR": { | ||
| 26843 | "stringUnit": { | ||
| 26844 | "state": "translated", | ||
| 26845 | "value": "Divisor de Painéis" | ||
| 26846 | } | ||
| 26847 | } | ||
| 26848 | } | ||
| 26849 | }, | ||
| 26780 | "Panes": { | 26850 | "Panes": { |
| 26781 | "localizations": { | 26851 | "localizations": { |
| 26782 | "de": { | 26852 | "de": { |