Commit 10ba31996e
Verified · cmc
Layout: unified · split
Sources/Orgstar/AgendaRowView.swift +17 −15
| @@ -17,6 +17,8 @@ struct AgendaRowView: View { | ||
| 17 | 17 | /// Marked for a bulk action. |
| 18 | 18 | var marked = false |
| 19 | 19 | @Environment(\.orgTheme) private var theme |
| 20 | @ScaledMetric(relativeTo: .callout) private var gutterWidth = AgendaRowView.gutterWidth | |
| 21 | @ScaledMetric(relativeTo: .caption) private var badgeSize: CGFloat = 18 | |
| 20 | 22 | |
| 21 | 23 | static let gutterWidth: CGFloat = 92 |
| 22 | 24 | |
| @@ -35,7 +37,7 @@ struct AgendaRowView: View { | ||
| 35 | 37 | if let todo = row.todo { |
| 36 | 38 | let color = theme.dynamic(row.isDone ? .systemGreen : .systemRed) { [theme, row] in theme.todoColor(todo, isDone: row.isDone, dark: $0) } |
| 37 | 39 | Text(todo) |
| 38 | .font(.system(size: 10, weight: .bold)) | |
| 40 | .font(.caption.weight(.bold)) | |
| 39 | 41 | .foregroundStyle(color) |
| 40 | 42 | .padding(.horizontal, 7) |
| 41 | 43 | .padding(.vertical, 2) |
| @@ -43,7 +45,7 @@ struct AgendaRowView: View { | ||
| 43 | 45 | .fixedSize() |
| 44 | 46 | } |
| 45 | 47 | priorityBadge |
| 46 | .frame(width: 18) | |
| 48 | .frame(width: badgeSize) | |
| 47 | 49 | } |
| 48 | 50 | .padding(.horizontal, 16) |
| 49 | 51 | .padding(.vertical, 6) |
| @@ -70,18 +72,18 @@ struct AgendaRowView: View { | ||
| 70 | 72 | private var gutter: some View { |
| 71 | 73 | VStack(alignment: .leading, spacing: 3) { |
| 72 | 74 | Text(row.gutter) |
| 73 | .font(.system(size: 12, weight: row.status == .overdue || row.status == .dueSoon ? .semibold : .regular).monospacedDigit()) | |
| 75 | .font(.callout.weight(row.status == .overdue || row.status == .dueSoon ? .semibold : .regular).monospacedDigit()) | |
| 74 | 76 | .foregroundStyle(statusColor) |
| 75 | 77 | .lineLimit(1) |
| 76 | 78 | .minimumScaleFactor(0.8) |
| 77 | 79 | if let symbol { |
| 78 | 80 | Image(systemName: symbol) |
| 79 | .font(.system(size: row.icon == .event ? 8 : 10, weight: .semibold)) | |
| 81 | .font(.caption.weight(.semibold)) | |
| 82 | .imageScale(row.icon == .event ? .small : .medium) | |
| 80 | 83 | .foregroundStyle(iconColor) |
| 81 | .frame(height: 12) | |
| 82 | 84 | } |
| 83 | 85 | } |
| 84 | .frame(width: Self.gutterWidth, alignment: .leading) | |
| 86 | .frame(width: gutterWidth, alignment: .leading) | |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | 89 | /// Overdue entries show a warning, done ones a check, as the status says first. |
| @@ -111,12 +113,12 @@ struct AgendaRowView: View { | ||
| 111 | 113 | ?? theme.dynamic { [theme, row] in theme.categoryColor(row.category, dark: $0) }) |
| 112 | 114 | .frame(width: 6, height: 6) |
| 113 | 115 | Text(row.category) |
| 114 | .font(.system(size: 11)) | |
| 116 | .font(.subheadline) | |
| 115 | 117 | .foregroundStyle(theme.color("agenda-category") ?? .secondary) |
| 116 | 118 | .lineLimit(1) |
| 117 | 119 | if let detail = row.prefixDetail { |
| 118 | 120 | Text(detail) |
| 119 | .font(.system(size: 11)) | |
| 121 | .font(.subheadline) | |
| 120 | 122 | .foregroundStyle(.secondary) |
| 121 | 123 | .lineLimit(1) |
| 122 | 124 | .truncationMode(.middle) |
| @@ -127,14 +129,14 @@ struct AgendaRowView: View { | ||
| 127 | 129 | private var titleLine: some View { |
| 128 | 130 | HStack(spacing: 6) { |
| 129 | 131 | Text(row.title.isEmpty ? " " : row.title) |
| 130 | .font(.system(size: 13)) | |
| 132 | .font(.body) | |
| 131 | 133 | .strikethrough(row.isDone) |
| 132 | 134 | .foregroundStyle(row.isDone ? AnyShapeStyle(.secondary) : AnyShapeStyle(theme.color("foreground") ?? .primary)) |
| 133 | 135 | .lineLimit(1) |
| 134 | 136 | .truncationMode(.tail) |
| 135 | 137 | ForEach([row.progress, row.detail].compactMap { $0 }, id: \.self) { progress in |
| 136 | 138 | Text(progress) |
| 137 | .font(.system(size: 10, weight: .semibold).monospacedDigit()) | |
| 139 | .font(.caption.weight(.semibold).monospacedDigit()) | |
| 138 | 140 | .foregroundStyle(.secondary) |
| 139 | 141 | .padding(.horizontal, 6) |
| 140 | 142 | .padding(.vertical, 1) |
| @@ -143,7 +145,7 @@ struct AgendaRowView: View { | ||
| 143 | 145 | } |
| 144 | 146 | ForEach(row.tags, id: \.self) { tag in |
| 145 | 147 | Text(tag) |
| 146 | .font(.system(size: 10, weight: .medium)) | |
| 148 | .font(.caption.weight(.medium)) | |
| 147 | 149 | .foregroundStyle(theme.color("tags") ?? .secondary) |
| 148 | 150 | .padding(.horizontal, 6) |
| 149 | 151 | .padding(.vertical, 1) |
| @@ -158,14 +160,14 @@ struct AgendaRowView: View { | ||
| 158 | 160 | if let priority = row.priority { |
| 159 | 161 | let color = theme.dynamic(.systemOrange) { [theme] in theme.priorityColor(priority, dark: $0) } |
| 160 | 162 | Text(priority) |
| 161 | .font(.system(size: 10, weight: .bold)) | |
| 163 | .font(.caption.weight(.bold)) | |
| 162 | 164 | .foregroundStyle(color) |
| 163 | .frame(width: 18, height: 18) | |
| 165 | .frame(width: badgeSize, height: badgeSize) | |
| 164 | 166 | .background(Circle().fill(color.opacity(0.14))) |
| 165 | 167 | .overlay(Circle().strokeBorder(color.opacity(0.6), lineWidth: 1)) |
| 166 | 168 | .help("Priority \(priority)") |
| 167 | 169 | } else { |
| 168 | Color.clear.frame(width: 18, height: 18) | |
| 170 | Color.clear.frame(width: badgeSize, height: badgeSize) | |
| 169 | 171 | } |
| 170 | 172 | } |
| 171 | 173 | } |
| @@ -179,7 +181,7 @@ struct HabitGraph: View { | ||
| 179 | 181 | HStack(spacing: 1) { |
| 180 | 182 | ForEach(cells, id: \.day) { cell in |
| 181 | 183 | Text(String(cell.glyph)) |
| 182 | .font(.system(size: 9, weight: .bold, design: .monospaced)) | |
| 184 | .font(.caption2.monospaced().weight(.bold)) | |
| 183 | 185 | .frame(width: 8, height: 14) |
| 184 | 186 | .background(color(cell.face)) |
| 185 | 187 | .help(Self.label(cell)) |
Sources/Orgstar/AgendaView.swift +14 −13
| @@ -69,6 +69,7 @@ struct AgendaView: View { | ||
| 69 | 69 | @State var pickedDate = Date() |
| 70 | 70 | @AppStorage("agendaOverdueExpanded") private var overdueShown = true |
| 71 | 71 | @State private var hovered: String? |
| 72 | @ScaledMetric(relativeTo: .callout) private var gutterWidth = AgendaRowView.gutterWidth | |
| 72 | 73 | @FocusState private var focused: Bool |
| 73 | 74 | @AppStorage("agendaSpan") var span = 10 |
| 74 | 75 | @AppStorage("agendaStartOffset") var startOffset = 0 |
| @@ -307,7 +308,7 @@ struct AgendaView: View { | ||
| 307 | 308 | } |
| 308 | 309 | } |
| 309 | 310 | } header: { |
| 310 | header { Text(block.header).font(.system(size: 13, weight: .semibold)) } | |
| 311 | header { Text(block.header).font(.body.weight(.semibold)) } | |
| 311 | 312 | } |
| 312 | 313 | } |
| 313 | 314 | } else if isAgenda { |
| @@ -324,7 +325,7 @@ struct AgendaView: View { | ||
| 324 | 325 | rowView(Line(id: "list:\(index)", row: row, day: agenda.today), showsGutter: false) |
| 325 | 326 | } |
| 326 | 327 | } header: { |
| 327 | header { Text(listTitle).font(.system(size: 13, weight: .semibold)) } | |
| 328 | header { Text(listTitle).font(.body.weight(.semibold)) } | |
| 328 | 329 | } |
| 329 | 330 | } |
| 330 | 331 | } |
| @@ -477,8 +478,8 @@ struct AgendaView: View { | ||
| 477 | 478 | private func gridLine(_ time: Int) -> some View { |
| 478 | 479 | HStack(spacing: 6) { |
| 479 | 480 | Text(String(format: "%02d:%02d", time / 100, time % 100)) |
| 480 | .font(.system(size: 10).monospacedDigit()) | |
| 481 | .frame(width: AgendaRowView.gutterWidth, alignment: .leading) | |
| 481 | .font(.caption.monospacedDigit()) | |
| 482 | .frame(width: gutterWidth, alignment: .leading) | |
| 482 | 483 | GridRule().stroke(style: StrokeStyle(lineWidth: 0.5, dash: [2, 3])).frame(height: 1) |
| 483 | 484 | } |
| 484 | 485 | .foregroundStyle(.tertiary) |
| @@ -490,7 +491,7 @@ struct AgendaView: View { | ||
| 490 | 491 | private func header(@ViewBuilder _ content: () -> some View) -> some View { |
| 491 | 492 | HStack(spacing: 6) { content() } |
| 492 | 493 | .padding(.horizontal, 16) |
| 493 | .frame(height: 30) | |
| 494 | .frame(minHeight: 30) | |
| 494 | 495 | .frame(maxWidth: .infinity, alignment: .leading) |
| 495 | 496 | .background(theme.color("agenda-background") ?? Color(nsColor: .textBackgroundColor)) |
| 496 | 497 | .overlay(alignment: .bottom) { Divider() } |
| @@ -502,19 +503,19 @@ struct AgendaView: View { | ||
| 502 | 503 | return header { |
| 503 | 504 | if let relative = group.relativeName(today: agenda.today) { |
| 504 | 505 | Text(relative) |
| 505 | .font(.system(size: 13, weight: .bold)) | |
| 506 | .font(.body.weight(.bold)) | |
| 506 | 507 | .foregroundStyle(color) |
| 507 | 508 | Text("·").foregroundStyle(.tertiary) |
| 508 | 509 | } |
| 509 | 510 | Text(Self.format(group.day, Days.date(group.day).year == Days.date(agenda.today).year ? "EEEE d MMMM" : "EEEE d MMMM yyyy")) |
| 510 | .font(.system(size: 13, weight: group.isToday ? .bold : .semibold)) | |
| 511 | .font(.body.weight(group.isToday ? .bold : .semibold)) | |
| 511 | 512 | .foregroundStyle(color) |
| 512 | 513 | Spacer() |
| 513 | 514 | Button { |
| 514 | 515 | capture(on: group.day) |
| 515 | 516 | } label: { |
| 516 | 517 | Image(systemName: "plus") |
| 517 | .font(.system(size: 12, weight: .semibold)) | |
| 518 | .font(.callout.weight(.semibold)) | |
| 518 | 519 | .frame(width: 22, height: 22) |
| 519 | 520 | .contentShape(Rectangle()) |
| 520 | 521 | } |
| @@ -532,11 +533,11 @@ struct AgendaView: View { | ||
| 532 | 533 | } label: { |
| 533 | 534 | HStack(spacing: 6) { |
| 534 | 535 | Image(systemName: "chevron.right") |
| 535 | .font(.system(size: 10, weight: .bold)) | |
| 536 | .font(.caption.weight(.bold)) | |
| 536 | 537 | .rotationEffect(.degrees(overdueShown ? 90 : 0)) |
| 537 | Text("Overdue").font(.system(size: 12, weight: .semibold)) | |
| 538 | Text("Overdue").font(.callout.weight(.semibold)) | |
| 538 | 539 | Text("\(count)") |
| 539 | .font(.system(size: 10, weight: .bold).monospacedDigit()) | |
| 540 | .font(.caption.weight(.bold).monospacedDigit()) | |
| 540 | 541 | .padding(.horizontal, 6) |
| 541 | 542 | .padding(.vertical, 1) |
| 542 | 543 | .background(Capsule().fill(color.opacity(0.15))) |
| @@ -555,8 +556,8 @@ struct AgendaView: View { | ||
| 555 | 556 | private var nowLine: some View { |
| 556 | 557 | HStack(spacing: 6) { |
| 557 | 558 | Text(now.formatted(.dateTime.hour(.twoDigits(amPM: .omitted)).minute())) |
| 558 | .font(.system(size: 10, weight: .semibold).monospacedDigit()) | |
| 559 | .frame(width: AgendaRowView.gutterWidth, alignment: .leading) | |
| 559 | .font(.caption.weight(.semibold).monospacedDigit()) | |
| 560 | .frame(width: gutterWidth, alignment: .leading) | |
| 560 | 561 | Circle().frame(width: 6, height: 6) |
| 561 | 562 | Rectangle().frame(height: 1) |
| 562 | 563 | } |