Commit ec53628273

ec53628273f55cd59d0f0f84327235bd7554900f

parent: ccac43494f

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-10 19:58 UTC

iOS: swipe to delete agenda entries; delete files from Folders

Swiping left on an agenda entry offers Delete, confirmed as in the menu. Files in the Folders tab delete by swipe or menu, after asking: to Recently Deleted where the provider has one, otherwise removed.

Layout: unified · split

Sources/OrgstarMobile/AgendaScreen.swift +4
@@ -491,6 +491,10 @@ struct AgendaScreen: View, Equatable {
491491 Button("Done", systemImage: "checkmark") { markDone(item) }.tint(.green)
492492 Button("Next State", systemImage: "arrow.right.circle") { run("org.todo.next", on: item) }.tint(.blue)
493493 }
494 // Last, so a full swipe doesn't reach it; it asks first.
495 if let item = row.item, item.path != nil, item.headingLine != nil {
496 Button("Delete", systemImage: "trash") { deleting = item }.tint(.red)
497 }
494498 }
495499 .swipeActions(edge: .leading) {
496500 if canReschedule(row), let item = row.item {
Sources/OrgstarMobile/FoldersScreen.swift +47 −3
@@ -6,13 +6,16 @@ import UniformTypeIdentifiers
66/// The folders of org files the agenda reads, and their files.
77struct FoldersScreen: View {
88 let workspace: WorkspaceModel
9 let session: DocumentSession
910 @State private var importing = false
11 /// The file whose deletion is being confirmed.
12 @State private var deleting: String?
1013
1114 var body: some View {
1215 List {
1316 ForEach(workspace.rootPaths, id: \.self) { root in
1417 Section((root as NSString).lastPathComponent) {
15 FolderContents(workspace: workspace, root: root, folder: "")
18 FolderContents(workspace: workspace, root: root, folder: "", deleting: $deleting)
1619 Button("Remove Folder", role: .destructive) { try? workspace.removeRoot(path: root) }
1720 }
1821 }
@@ -22,9 +25,9 @@ struct FoldersScreen: View {
2225 }
2326 .navigationTitle("Folders")
2427 .navigationDestination(for: FolderRoute.self) { route in
25 List { FolderContents(workspace: workspace, root: route.root, folder: route.folder) }
26 .navigationTitle((route.folder as NSString).lastPathComponent)
28 FolderPage(workspace: workspace, session: session, route: route)
2729 }
30 .confirmDeletion($deleting, workspace: workspace, session: session)
2831 .overlay {
2932 if workspace.rootPaths.isEmpty {
3033 ContentUnavailableView {
@@ -55,6 +58,40 @@ struct FoldersScreen: View {
5558 }
5659 }
5760}
61/// A subfolder's own list, asking about its own deletions.
62private struct FolderPage: View {
63 let workspace: WorkspaceModel
64 let session: DocumentSession
65 let route: FolderRoute
66 @State private var deleting: String?
67
68 var body: some View {
69 List { FolderContents(workspace: workspace, root: route.root, folder: route.folder, deleting: $deleting) }
70 .navigationTitle((route.folder as NSString).lastPathComponent)
71 .confirmDeletion($deleting, workspace: workspace, session: session)
72 }
73}
74
75private extension View {
76 /// Asks before deleting the file in `deleting`, closing it first.
77 func confirmDeletion(_ deleting: Binding<String?>, workspace: WorkspaceModel, session: DocumentSession) -> some View {
78 let name = deleting.wrappedValue.map { ($0 as NSString).lastPathComponent } ?? ""
79 return confirmationDialog("Delete “\(name)”?", isPresented: Binding { deleting.wrappedValue != nil } set: { if !$0 { deleting.wrappedValue = nil } },
80 titleVisibility: .visible) {
81 Button("Delete", role: .destructive) {
82 guard let path = deleting.wrappedValue else { return }
83 deleting.wrappedValue = nil
84 session.kill(path)
85 Task {
86 do { try await workspace.trash(path) } catch { workspace.lastError = "Can't delete \(name): \(error.localizedDescription)" }
87 }
88 }
89 } message: {
90 Text("The whole file is removed. Files in iCloud Drive go to Recently Deleted in the Files app.")
91 }
92 }
93}
94
5895/// A subfolder to show, relative to its root.
5996struct FolderRoute: Hashable {
6097 let root: String
@@ -67,6 +104,7 @@ private struct FolderContents: View {
67104 let workspace: WorkspaceModel
68105 let root: String
69106 let folder: String
107 @Binding var deleting: String?
70108
71109 private var prefix: String { folder.isEmpty ? "" : folder + "/" }
72110
@@ -91,6 +129,12 @@ private struct FolderContents: View {
91129 NavigationLink(value: ReaderRoute.file(file.path)) {
92130 Label(file.name, systemImage: "doc.text")
93131 }
132 .swipeActions(edge: .trailing) {
133 Button("Delete", systemImage: "trash") { deleting = file.path }.tint(.red)
134 }
135 .contextMenu {
136 Button("Delete…", systemImage: "trash", role: .destructive) { deleting = file.path }
137 }
94138 }
95139 ForEach(pending.filter { !$0.contains("/") }, id: \.self) { name in
96140 Label(name, systemImage: "icloud.and.arrow.down").foregroundStyle(.secondary)
Sources/OrgstarMobile/MobileModel.swift +4
@@ -65,6 +65,10 @@ final class MobileModel {
6565 let settings = OrgPreferences.orgSettings()
6666 do {
6767 let workspace = try WorkspaceModel(directory: WorkspaceModel.defaultDirectory, settings: .with(todoKeywords: settings))
68 // Recently Deleted where the folder's provider keeps one (iCloud Drive); otherwise gone.
69 workspace.trasher = { url in
70 do { try FileManager.default.trashItem(at: url, resultingItemURL: nil) } catch { try FileManager.default.removeItem(at: url) }
71 }
6872 self.workspace = workspace
6973 agenda = AgendaModel(workspace: workspace)
7074 failure = nil
Sources/OrgstarMobile/OrgstarMobileApp.swift +1 −1
@@ -162,7 +162,7 @@ struct RootView: View {
162162 }
163163 Tab("Folders", systemImage: "folder", value: .folders) {
164164 NavigationStack {
165 FoldersScreen(workspace: workspace)
165 FoldersScreen(workspace: workspace, session: session)
166166 .toolbar { captureButton }
167167 .readerDestination(workspace: workspace, session: session)
168168 }
docs/manual/guide/07-agenda.org +1 −1
@@ -567,7 +567,7 @@ The Agenda tab shows the same views from the same files, using the settings in t
567567- Pull down to refresh.
568568- The Filter button opens a sheet: type a filter as for =/=, or tap a tag or category to cycle between Keep, Leave out and no filter.
569569- Tap an entry to open it. Tap a calendar event to open Calendar on the event's day; iOS can't open Calendar at one event.
570- Swipe left on an open TODO entry for Done, which sets the first done keyword of its sequence, and Next State, which moves to the next keyword. The sequence is the one the file defines: the default keywords from =config.toml=, the file's own =#+TODO= lines, and those of its setup files, with unsaved edits in an open buffer included.
570- Swipe left on an open TODO entry for Done, which sets the first done keyword of its sequence, and Next State, which moves to the next keyword; and on any entry with a heading, for Delete, which asks first, as Delete… in the menu does. The sequence is the one the file defines: the default keywords from =config.toml=, the file's own =#+TODO= lines, and those of its setup files, with unsaved edits in an open buffer included.
571571- Swipe right on a scheduled entry, a deadline, a habit or a TODO entry, when it isn't done, for Tomorrow, Next Week and Pick Date. Tomorrow is the day after today and Next Week is next Monday. On a deadline row these move the deadline; on other rows they set the scheduled date. A timed row keeps its times.
572572- Touch and hold an entry for TODO State…, Reschedule (Tomorrow, Next Week, Pick Date…), Schedule…, Deadline…, Tags…, Priority…, Clock In, Refile…, Archive… and Delete…, which removes the heading and everything under it.
573573- Marking an entry done and rescheduling one give haptic feedback.
docs/manual/guide/14-ios.org +3 −1
@@ -22,6 +22,8 @@ orgstar on iOS works on folders you choose, in iCloud Drive or in another app's
2222
2323orgstar keeps access to the folder across launches. Each folder appears as a section listing its =.org= files by their path inside the folder. Remove Folder at the end of a section removes it from orgstar; the files stay where they are.
2424
25Swipe left on a file, or touch and hold it, to delete it. orgstar asks first. A file in iCloud Drive goes to Recently Deleted in the Files app; elsewhere it is removed.
26
2527Files that iCloud hasn't downloaded to the device yet appear in grey with a cloud icon. orgstar asks iCloud to download them and lists them as files once they arrive.
2628
2729orgstar sees changes made by iCloud and by apps that use the system's file coordination, and reads every folder again each time you return to the app, since not every sync app reports its changes. An open file takes in changes from disk as described in [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]].
@@ -159,7 +161,7 @@ The Agenda tab shows the agenda over all your folders, with the span and start d
159161- Filter :: keep or leave out tags and categories of the entries shown, or type a filter as Org's =/= takes it: =+keep= and =-drop= tags or categories, =<0:30= for effort, =/regexp/=. The filter in use shows above the bar.
160162- + on a day's header :: captures an entry scheduled on that day (see [[file:08-capture.org][Capture]]).
161163- Tap :: an entry to read it, at its heading.
162- Swipe left :: on a TODO entry for Done, which sets the first done keyword of its sequence, or Next State.
164- Swipe left :: on a TODO entry for Done, which sets the first done keyword of its sequence, or Next State; on any entry with a heading for Delete, which asks first.
163165- Swipe right :: for Tomorrow, Next Week (next Monday) or Pick Date, which move the entry's scheduled date, or its deadline on a deadline row.
164166- Touch and hold :: an entry for TODO State…, Reschedule, Schedule…, Deadline…, Tags…, Priority…, Clock In, Refile…, Archive…, and Delete…. Delete… removes the heading and every line under it, after asking. Refile… lists files; the entry goes to the end of the one you choose. Refiling under a heading is Mac only.
165167