iOS: refile under a heading !238

merged merged by cmc on 2026-10-11 06:20 UTC · krz/orgstar:ios-refile-headings into main

2 files changed, +34 −4

Layout: unified · split

Sources/OrgstarMobile/AgendaScreen.swift +33 −3
@@ -916,16 +916,46 @@ struct FilterSheet: View {
916916 }
917917}
918918
919/// Files to refile an entry to, at their end, searchable. Headings within them aren't offered.
919/// Where to refile an entry: each file, at its end, and the headings in it down to level 3,
920/// as the Mac's prompt offers them, searchable by their path.
920921struct RefileSheet: View {
921922 let targets: [RefileTarget]
922923 let choose: (RefileTarget?) -> Void
923924 @State private var query = ""
924925
926 /// Targets by file, in the order given, each file's own row first.
927 private var files: [(path: String, targets: [RefileTarget])] {
928 var order: [String] = []
929 var byPath: [String: [RefileTarget]] = [:]
930 for target in targets where query.isEmpty || target.label.localizedCaseInsensitiveContains(query) {
931 if byPath[target.path] == nil { order.append(target.path) }
932 byPath[target.path, default: []].append(target)
933 }
934 return order.map { ($0, byPath[$0] ?? []) }
935 }
936
925937 var body: some View {
926938 NavigationStack {
927 List(targets.filter { $0.start == nil && (query.isEmpty || $0.label.localizedCaseInsensitiveContains(query)) }, id: \.self) { target in
928 Button(target.label) { choose(target) }.foregroundStyle(.primary)
939 List {
940 ForEach(files, id: \.path) { file in
941 Section {
942 ForEach(file.targets, id: \.self) { target in
943 Button {
944 choose(target)
945 } label: {
946 HStack(spacing: 6) {
947 if target.start == nil {
948 Image(systemName: "doc.text").foregroundStyle(.secondary)
949 Text(target.label)
950 } else {
951 Text(String(repeating: " ", count: max(0, target.level - 1)) + target.title)
952 }
953 }
954 }
955 .foregroundStyle(.primary)
956 }
957 }
958 }
929959 }
930960 .searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
931961 .navigationTitle("Refile to")
docs/manual/guide/14-ios.org +1 −1
@@ -164,7 +164,7 @@ The Agenda tab shows the agenda over all your folders, with the span and start d
164164- Tap :: an entry to read it, at its heading.
165165- 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.
166166- 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.
167- 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.
167- 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 each file and the headings in it down to level 3, as the Mac's prompt does; the entry goes to the end of the file, or under the heading, you choose. Search narrows the list by file and heading path.
168168
169169Commands from the agenda change the file directly when it isn't open, and through the editor when it is. If the heading changed since the agenda was built, nothing runs.
170170