Commit 98b41213c1

98b41213c14d74d094f11cb5134cb8aac027be4e

parent: 990043b7ec

Verified · cmc

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

One agenda row layout on Mac and iOS

Both draw the time or status in the gutter with a timed entry's end
under its start and the icon below (AgendaRow.gutterLines, .symbol);
the category, progress and tags above the title on a line that wraps,
with the keyword and priority at its end; and a habit's graph under
the title. On iOS the Overdue group moves under today's header, as on
the Mac, and the icons are the Mac's.

Ref #223

Layout: unified · split

Sources/OrgPresentation/AgendaRows.swift +21
@@ -99,6 +99,27 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
9999 /// The calendar's color for an event.
100100 public var color: RGBA? { event?.color }
101101
102 /// The gutter as its lines: a timed row's start over its end, else the status.
103 public var gutterLines: [String] {
104 start == nil ? [gutter] : gutter.split(separator: "–", maxSplits: 1).map(String.init)
105 }
106
107 /// The SF Symbol under the gutter: a warning for overdue entries and a check for done ones,
108 /// as the status says first, else one for the kind of row.
109 public var symbol: String? {
110 guard let icon else { return nil }
111 if status == .overdue { return "exclamationmark.circle.fill" }
112 if status == .done { return "checkmark.circle.fill" }
113 switch icon {
114 case .scheduled: return "calendar"
115 case .deadline: return "flag.fill"
116 case .habit: return "repeat"
117 case .event: return "circle.fill"
118 case .reminder: return "circle"
119 case .timestamp: return start == nil ? "calendar" : "clock"
120 }
121 }
122
102123 /// Nil for the time grid and the current-time line.
103124 public init?(item: AgendaItem, day: Int, today: Int) {
104125 if item.kind == .timeGrid || item.kind == .currentTime { return nil }
Sources/Orgstar/AgendaRowView.swift +57 −63
@@ -5,8 +5,8 @@ import OrgCore
55import OrgPresentation
66import SwiftUI
77
8/// One agenda line: the time or status over an icon, the category above the title, progress
9/// and tags after it, and the TODO keyword and priority at the end.
8/// One agenda line: the time or status over an icon; above the title the category, progress and
9/// tags, with the TODO keyword and priority at the end; a habit's graph under the title.
1010struct AgendaRowView: View {
1111 let row: AgendaRow
1212 /// The agenda day the row is on, for habit graphs.
@@ -23,29 +23,24 @@ struct AgendaRowView: View {
2323 static let gutterWidth: CGFloat = 92
2424
2525 var body: some View {
26 HStack(alignment: .center, spacing: 12) {
26 HStack(alignment: .top, spacing: 12) {
2727 if showsGutter { gutter }
2828 VStack(alignment: .leading, spacing: 2) {
29 if !row.category.isEmpty { categoryLine }
30 titleLine
31 }
32 .layoutPriority(1)
33 Spacer(minLength: 8)
34 if let habit = row.item?.habit {
35 HabitGraph(cells: habit.graph(today: day), theme: theme)
36 }
37 if let todo = row.todo {
38 let color = theme.dynamic(row.isDone ? .systemGreen : .systemRed) { [theme, row] in theme.todoColor(todo, isDone: row.isDone, dark: $0) }
39 Text(todo)
40 .font(.caption.weight(.bold))
41 .foregroundStyle(color)
42 .padding(.horizontal, 7)
43 .padding(.vertical, 2)
44 .background(Capsule().fill(color.opacity(0.14)))
45 .fixedSize()
29 HStack(alignment: .top, spacing: 8) {
30 metaLine
31 Spacer(minLength: 0)
32 marks
33 }
34 Text(row.title.isEmpty ? " " : row.title)
35 .font(.body)
36 .strikethrough(row.isDone)
37 .foregroundStyle(row.isDone ? AnyShapeStyle(.secondary) : AnyShapeStyle(theme.color("foreground") ?? .primary))
38 .lineLimit(1)
39 .truncationMode(.tail)
40 if let habit = row.item?.habit {
41 HabitGraph(cells: habit.graph(today: day), theme: theme).padding(.top, 2)
42 }
4643 }
47 priorityBadge
48 .frame(width: badgeSize)
4944 }
5045 .padding(.horizontal, 16)
5146 .padding(.vertical, 6)
@@ -69,14 +64,19 @@ struct AgendaRowView: View {
6964 theme.dynamic(.secondaryLabelColor) { [theme, row] in theme.statusColor(row.status, dark: $0) }
7065 }
7166
67 /// The start over the end for timed rows, else the status; the icon under them.
7268 private var gutter: some View {
73 VStack(alignment: .leading, spacing: 3) {
74 Text(row.gutter)
69 VStack(alignment: .leading, spacing: 2) {
70 let lines = row.gutterLines
71 Text(lines[0])
7572 .font(.callout.weight(row.status == .overdue || row.status == .dueSoon ? .semibold : .regular).monospacedDigit())
7673 .foregroundStyle(statusColor)
7774 .lineLimit(1)
7875 .minimumScaleFactor(0.8)
79 if let symbol {
76 if lines.count > 1 {
77 Text(lines[1]).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
78 }
79 if let symbol = row.symbol {
8080 Image(systemName: symbol)
8181 .font(.caption.weight(.semibold))
8282 .imageScale(row.icon == .event ? .small : .medium)
@@ -86,36 +86,26 @@ struct AgendaRowView: View {
8686 .frame(width: gutterWidth, alignment: .leading)
8787 }
8888
89 /// Overdue entries show a warning, done ones a check, as the status says first.
90 private var symbol: String? {
91 guard let icon = row.icon else { return nil }
92 if row.status == .overdue { return "exclamationmark.circle.fill" }
93 if row.status == .done { return "checkmark.circle.fill" }
94 switch icon {
95 case .scheduled: return "calendar"
96 case .deadline: return "flag.fill"
97 case .habit: return "repeat"
98 case .event: return "circle.fill"
99 case .reminder: return "circle"
100 case .timestamp: return row.start == nil ? "calendar" : "clock"
101 }
102 }
103
10489 private var iconColor: Color {
10590 if let event = row.event { return theme.dynamic(.systemPurple) { [theme] in theme.eventColor(event, dark: $0) } }
10691 return row.status == .normal ? Color.secondary.opacity(0.8) : statusColor
10792 }
10893
109 private var categoryLine: some View {
110 HStack(spacing: 5) {
111 Circle()
112 .fill(row.event.map { event in theme.dynamic(.systemPurple) { [theme] in theme.eventColor(event, dark: $0) } }
113 ?? theme.dynamic { [theme, row] in theme.categoryColor(row.category, dark: $0) })
114 .frame(width: 6, height: 6)
115 Text(row.category)
116 .font(.subheadline)
117 .foregroundStyle(theme.color("agenda-category") ?? .secondary)
118 .lineLimit(1)
94 /// The category, the prefix's detail, progress and tags, wrapping to more lines as needed.
95 private var metaLine: some View {
96 FlowLayout(spacing: 5, lineSpacing: 3) {
97 if !row.category.isEmpty {
98 HStack(spacing: 5) {
99 Circle()
100 .fill(row.event.map { event in theme.dynamic(.systemPurple) { [theme] in theme.eventColor(event, dark: $0) } }
101 ?? theme.dynamic { [theme, row] in theme.categoryColor(row.category, dark: $0) })
102 .frame(width: 6, height: 6)
103 Text(row.category)
104 .font(.subheadline)
105 .foregroundStyle(theme.color("agenda-category") ?? .secondary)
106 .lineLimit(1)
107 }
108 }
119109 if let detail = row.prefixDetail {
120110 Text(detail)
121111 .font(.subheadline)
@@ -123,17 +113,6 @@ struct AgendaRowView: View {
123113 .lineLimit(1)
124114 .truncationMode(.middle)
125115 }
126 }
127 }
128
129 private var titleLine: some View {
130 HStack(spacing: 6) {
131 Text(row.title.isEmpty ? " " : row.title)
132 .font(.body)
133 .strikethrough(row.isDone)
134 .foregroundStyle(row.isDone ? AnyShapeStyle(.secondary) : AnyShapeStyle(theme.color("foreground") ?? .primary))
135 .lineLimit(1)
136 .truncationMode(.tail)
137116 ForEach([row.progress, row.detail].compactMap { $0 }, id: \.self) { progress in
138117 Text(progress)
139118 .font(.caption.weight(.semibold).monospacedDigit())
@@ -141,7 +120,6 @@ struct AgendaRowView: View {
141120 .padding(.horizontal, 6)
142121 .padding(.vertical, 1)
143122 .background(Capsule().fill(Color.secondary.opacity(0.14)))
144 .fixedSize()
145123 }
146124 ForEach(row.tags, id: \.self) { tag in
147125 Text(tag)
@@ -150,11 +128,27 @@ struct AgendaRowView: View {
150128 .padding(.horizontal, 6)
151129 .padding(.vertical, 1)
152130 .background(Capsule().strokeBorder((theme.color("tags") ?? .secondary).opacity(0.35), lineWidth: 0.5))
153 .fixedSize()
154131 }
155132 }
156133 }
157134
135 /// The TODO keyword and the priority, at the end of the category's line.
136 private var marks: some View {
137 HStack(spacing: 6) {
138 if let todo = row.todo {
139 let color = theme.dynamic(row.isDone ? .systemGreen : .systemRed) { [theme, row] in theme.todoColor(todo, isDone: row.isDone, dark: $0) }
140 Text(todo)
141 .font(.caption.weight(.bold))
142 .foregroundStyle(color)
143 .padding(.horizontal, 7)
144 .padding(.vertical, 2)
145 .background(Capsule().fill(color.opacity(0.14)))
146 }
147 priorityBadge
148 }
149 .fixedSize()
150 }
151
158152 @ViewBuilder
159153 private var priorityBadge: some View {
160154 if let priority = row.priority {
Sources/OrgstarMobile/AgendaScreen.swift +44 −53
@@ -114,12 +114,7 @@ struct AgendaScreen: View, Equatable {
114114 } else if case .agenda = agenda.mode {
115115 let _ = model.settingsVersion
116116 ForEach(Perf.measure("agenda.groups") { agenda.groups(showAllDates: OrgPreferences.agendaShowAllDates(), filter: filter) }) { group in
117 overdue(group)
118 Section {
119 day(group)
120 } header: {
121 header(group)
122 }
117 dayGroup(group)
123118 }
124119 } else if case .blocks = agenda.mode {
125120 // A block's title over its days, or over its entries.
@@ -127,12 +122,7 @@ struct AgendaScreen: View, Equatable {
127122 if block.isAgenda {
128123 Section { } header: { Text(block.header).font(.headline) }
129124 ForEach(agenda.groups(block, showAllDates: OrgPreferences.agendaShowAllDates(), filter: filter)) { group in
130 overdue(group)
131 Section {
132 day(group)
133 } header: {
134 header(group)
135 }
125 dayGroup(group)
136126 }
137127 } else {
138128 Section {
@@ -446,15 +436,12 @@ struct AgendaScreen: View, Equatable {
446436
447437 // MARK: - Days
448438
449 /// Today's entries from earlier days, in a section of their own above today's.
439 /// A day under its header. On today, the entries from earlier days come first, in a group
440 /// of their own headed Overdue.
450441 @ViewBuilder
451 private func overdue(_ group: AgendaDayGroup) -> some View {
442 private func dayGroup(_ group: AgendaDayGroup) -> some View {
452443 if group.isToday, !group.overdue.isEmpty {
453444 Section {
454 if overdueExpanded {
455 ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } }
456 }
457 } header: {
458445 Button {
459446 withAnimation { overdueExpanded.toggle() }
460447 } label: {
@@ -470,8 +457,23 @@ struct AgendaScreen: View, Equatable {
470457 .contentShape(Rectangle())
471458 }
472459 .buttonStyle(.plain)
473 .textCase(nil)
474460 .accessibilityValue(overdueExpanded ? "Expanded" : "Collapsed")
461 if overdueExpanded {
462 ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } }
463 }
464 } header: {
465 header(group)
466 }
467 if !group.rows.isEmpty {
468 Section {
469 day(group)
470 }
471 }
472 } else {
473 Section {
474 day(group)
475 } header: {
476 header(group)
475477 }
476478 }
477479 }
@@ -939,8 +941,8 @@ extension RGBA {
939941 var swiftUI: Color { Color(.sRGB, red: red, green: green, blue: blue, opacity: alpha) }
940942}
941943
942/// One agenda line: the time or status with an icon in the gutter; the category, title,
943/// progress and tags; the TODO keyword and priority on the right.
944/// One agenda line: the time or status over an icon; above the title the
945/// category, progress and tags, with the TODO keyword and priority at the end; a habit's graph under it.
944946struct AgendaRowView: View {
945947 let row: AgendaRow
946948 /// The day the row is on, for habit graphs.
@@ -1029,40 +1031,29 @@ struct AgendaRowView: View {
10291031
10301032 /// The start over the end for timed rows, else the status; the icon under them.
10311033 private var gutter: some View {
1032 HStack(alignment: .firstTextBaseline, spacing: 4) {
1033 Image(systemName: icon ?? "circle").font(.caption2.weight(.semibold)).foregroundStyle(iconColor)
1034 .frame(width: 14)
1035 .opacity(icon == nil ? 0 : 1)
1036 VStack(alignment: .leading, spacing: 1) {
1037 if row.start != nil {
1038 let parts = row.gutter.split(separator: "–", maxSplits: 1)
1039 Text(parts.first.map(String.init) ?? row.gutter)
1040 .font(.subheadline.monospacedDigit().weight(.semibold))
1041 .foregroundStyle(row.status == .normal ? Color.primary : row.status == .done ? Color.secondary : statusColor)
1042 if parts.count > 1 {
1043 Text(parts[1]).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
1044 }
1045 } else if !row.gutter.isEmpty {
1046 Text(row.gutter)
1047 .font(.caption.weight(.medium).monospacedDigit())
1048 .foregroundStyle(statusColor)
1049 .lineLimit(1)
1050 .allowsTightening(true)
1051 .minimumScaleFactor(0.8)
1034 VStack(alignment: .leading, spacing: 2) {
1035 let lines = row.gutterLines
1036 if row.start != nil {
1037 Text(lines[0])
1038 .font(.subheadline.monospacedDigit().weight(.semibold))
1039 .foregroundStyle(row.status == .normal ? Color.primary : row.status == .done ? Color.secondary : statusColor)
1040 if lines.count > 1 {
1041 Text(lines[1]).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
10521042 }
1043 } else if !row.gutter.isEmpty {
1044 Text(row.gutter)
1045 .font(.caption.weight(.medium).monospacedDigit())
1046 .foregroundStyle(statusColor)
1047 .lineLimit(1)
1048 .allowsTightening(true)
1049 .minimumScaleFactor(0.8)
1050 }
1051 if let symbol = row.symbol {
1052 Image(systemName: symbol)
1053 .font(.caption2.weight(.semibold))
1054 .imageScale(row.icon == .event ? .small : .medium)
1055 .foregroundStyle(iconColor)
10531056 }
1054 }
1055 }
1056
1057 private var icon: String? {
1058 switch row.icon {
1059 case .scheduled: row.status == .overdue ? "exclamationmark.circle.fill" : "calendar"
1060 case .deadline: row.status == .overdue ? "exclamationmark.triangle.fill" : "flag.fill"
1061 case .habit: "repeat"
1062 case .event: "calendar"
1063 case .reminder: "circle"
1064 case .timestamp: "clock"
1065 case nil: nil
10661057 }
10671058 }
10681059
Tests/OrgPresentationTests/AgendaRowsTests.swift +14
@@ -94,6 +94,20 @@ struct AgendaRowsTests {
9494 #expect(!rent.isEvent && rent.item != nil)
9595 }
9696
97 @Test func gutterLinesAndSymbols() {
98 let rows = Self.rows()
99 #expect(rows["Dentist"]?.gutterLines == ["13:50", "14:30"])
100 #expect(rows["Standup"]?.gutterLines == ["08:00"])
101 #expect(rows["Send forms"]?.gutterLines == ["3d late"])
102 #expect(rows["Send forms"]?.symbol == "exclamationmark.circle.fill")
103 #expect(rows["Pay rent"]?.symbol == "exclamationmark.circle.fill")
104 #expect(rows["Took out bins"]?.symbol == "checkmark.circle.fill")
105 #expect(rows["File taxes"]?.symbol == "flag.fill")
106 #expect(rows["Water plants"]?.symbol == "calendar")
107 #expect(rows["Dentist"]?.symbol == "clock")
108 #expect(rows["Birthday"]?.symbol == "calendar")
109 }
110
97111 @Test func logRowsKeepTheDurationAndState() {
98112 let text = """
99113 * DONE Write report
docs/manual/guide/07-agenda.org +6 −8
@@ -139,7 +139,7 @@ Days without entries are left out. Today always shows, with =Nothing scheduled=
139139org-agenda-show-all-dates = true
140140#+END_SRC
141141
142Today's past deadlines and entries and habits scheduled on earlier days go in a group headed =Overdue= with their count, above today's other entries; on iOS it is a section of its own above today. Their left column shows how late they are, not the time of day they had. The oldest date comes first; entries with the same date keep Org's order. Click or tap the header to collapse or expand the group; it stays as you left it.
142Today's past deadlines and entries and habits scheduled on earlier days go in a group headed =Overdue= with their count, above today's other entries. Their left column shows how late they are, not the time of day they had. The oldest date comes first; entries with the same date keep Org's order. Click or tap the header to collapse or expand the group; it stays as you left it.
143143
144144Days with a time grid show dotted lines at the grid's times among the timed entries, as =org-agenda-time-grid= does: by default at 8:00, 10:00 and every two hours to 20:00, on today and in one-day views, when the day has a timed entry, and not at a time an entry has. On today, a line marked with the current time sits among them: before the first entry that starts later, or after the last one when all have started. The grid's days and times are set in =[org-agenda-time-grid]= in =config.toml=, =org-agenda-use-time-grid= turns the grid off, and =org-agenda-show-current-time-in-grid= the now line (see [[file:13-configuration.org][Configuration]]). With the grid off there is no now line, as in Org.
145145
@@ -171,21 +171,19 @@ In the TODO list and matches, the date keys use the first one in the strategy: w
171171Press =l= to turn log mode (=org-agenda-log-mode=) on or off; on iOS, use Log Mode in the span menu. Each day then also shows:
172172
173173- =Closed= entries whose =CLOSED:= timestamp is on that day;
174- =Clocked= entries for each =CLOCK:= line that starts on that day, with the clock's start and end times in the left column and the time clocked, such as =1:30=, after the title;
174- =Clocked= entries for each =CLOCK:= line that starts on that day, with the clock's start and end times in the left column and the time clocked, such as =1:30=, above the title;
175175- with =state= in =org-agenda-log-mode-items=, =State:= entries for each state change logged that day (a =- State "DONE" from "TODO" [2026-10-05 Mon 16:20]= line), with the new state in parentheses and the note's first line after the title.
176176
177177A note under a clock line (a list item directly below it) is added to the title after a =-=. =org-agenda-log-mode-items= in =config.toml= picks the kinds, separated by spaces; the default is Org's, ="closed clock"=.
178178
179179* Rows
180180
181Each row shows, from left to right:
181Rows look the same on the Mac and iOS. Each shows:
182182
183- The time or status described above, with an icon below it on the Mac and before it on iOS: a calendar for scheduled entries, a flag for deadlines, arrows in a circle for habits, a clock or a calendar for timestamps, and a dot or a calendar for calendar events. An overdue entry shows a warning sign instead, and on the Mac a done entry shows a check mark.
184- The category, with a colored dot, above the title. For a calendar event this is the calendar's name.
183- On the left, the time or status described above, a timed entry's end under its start, and an icon below: a calendar for scheduled entries, a flag for deadlines, arrows in a circle for habits, a clock or a calendar for timestamps, and a dot for calendar events. An overdue entry shows a warning sign instead, and a done entry a check mark.
184- Above the title, the category with a colored dot (for a calendar event, the calendar's name), the value of the first statistics cookie (=1/3=, =50%=) and the tags, inherited tags first, as small capsules. The line wraps when they don't fit. At its end are the TODO keyword as a colored badge and the priority as a colored letter in a circle.
185185- The title: the heading without its TODO keyword, priority cookie, statistics cookies, timestamps and tags, with links shown as their descriptions. A done entry's title is struck through.
186- The value of the first statistics cookie (=1/3=, =50%=) and the tags, inherited tags first, as small capsules.
187- The habit's consistency graph, for habits.
188- The TODO keyword as a colored badge, and the priority as a colored letter in a circle.
186- Under the title, the habit's consistency graph, for habits.
189187
190188The status sets the color of the left column:
191189
docs/manual/guide/14-ios.org +1 −1
@@ -188,7 +188,7 @@ Tap a result to open it in the reader. A heading result opens at that heading.
188188
189189* The agenda
190190
191The Agenda tab shows the agenda over all your folders, with the span and start day from the settings (10 days from 3 days ago by default). Each day lists its entries in rows: the time or a status such as =Due today= or =3d late= on the left, the category and the keyword above the title. Days without entries are hidden, except today. Today's overdue entries are in a section of their own above today, and a line marks the current time between timed entries. Pull down to refresh.
191The Agenda tab shows the agenda over all your folders, with the span and start day from the settings (10 days from 3 days ago by default). Each day lists its entries in rows: the time or a status such as =Due today= or =3d late= on the left, the category, tags and keyword above the title, as on the Mac (see Rows in [[file:07-agenda.org][The agenda]]). Days without entries are hidden, except today. Under today's header, today's overdue entries come first under Overdue, and a line marks the current time between timed entries. Pull down to refresh.
192192
193193- Views (top left) :: the built-in views and those in =views.toml=, Tags and Properties… (a match such as =+work-home= or ~TODO="WAIT"~), and Search… (a phrase, or snippets such as =+invoice -paid=); Save as View… keeps the match or search showing as a view in =views.toml=. Below them are Go to Date…, Filter… and Select, which picks entries for an action on all of them.
194194- Folders (top right, with more than one folder) :: shows or hides each folder's files in the agenda, the widgets, the watch and the badge; the shown folders' names appear under the title. A Focus can hide folders too, and mute their reminders (see Hiding folders in [[file:07-agenda.org][The agenda]]).