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