Calendar: fix Day/3-Day/Week/List task rendering; lighter checkbox; confirm future completes
Calendar timeline views only populated in Month. Fixes: - Day/3-Day time grid dropped untimed (midnight) tasks and ignored recurrence. Now uses occurrences(on:) + hasTime, and adds an all-day band for untimed tasks, all-day events, and the day's workout. - Week showed abstract color bars; now lists real task/event titles (up to 4/day + "N more") via a shared cvAgendaItems helper. - List view and the task-list toggle now use occurrences(on:) so recurring tasks appear. TodayView: - Slimmer task checkbox (18pt open ring vs 22pt filled donut). - Confirm before completing a future-dated task (Next 7 Days / Later) to prevent accidental completion; today/overdue still toggle instantly. Bump build to 2.0 (9). Add App Store support-site one-pager. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -482,10 +482,7 @@ struct CalendarView: View {
|
||||
// MARK: - Task list mode (toggle view)
|
||||
|
||||
private var calDayTaskListView: some View {
|
||||
let all = taskVM.tasks.filter { t in
|
||||
guard let d = t.dueDate else { return false }
|
||||
return cal.isDate(d, inSameDayAs: selectedDate)
|
||||
}
|
||||
let all = taskVM.occurrences(on: selectedDate)
|
||||
let incomplete = all.filter { !$0.isComplete }
|
||||
let complete = all.filter { $0.isComplete }
|
||||
|
||||
@@ -633,10 +630,7 @@ struct CalendarView: View {
|
||||
Divider().background(AppColors.border(cs)).padding(.horizontal, 16)
|
||||
ScrollView(showsIndicators: false) {
|
||||
VStack(spacing: 0) {
|
||||
let dayTasks = taskVM.tasks.filter { t in
|
||||
guard !t.isComplete, let d = t.dueDate else { return false }
|
||||
return cal.isDate(d, inSameDayAs: selectedDate)
|
||||
}
|
||||
let dayTasks = taskVM.occurrences(on: selectedDate).filter { !$0.isComplete }
|
||||
let events = calStore.isAuthorized ? calStore.events(for: selectedDate) : []
|
||||
if dayTasks.isEmpty && events.isEmpty {
|
||||
cvEmptyDay
|
||||
@@ -805,7 +799,7 @@ struct CalendarView: View {
|
||||
ForEach(cvWeekDays(), id: \.self) { date in
|
||||
let isTod = cal.isDateInToday(date)
|
||||
let isSel = cal.isDate(date, inSameDayAs: selectedDate)
|
||||
let dots = eventDots(for: date)
|
||||
let items = cvAgendaItems(date)
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
HStack(spacing: 4) {
|
||||
Text(cvDayFmt.string(from: date))
|
||||
@@ -815,12 +809,20 @@ struct CalendarView: View {
|
||||
.font(AppFonts.sans(12, weight: isTod ? .bold : .medium))
|
||||
.foregroundColor(isTod ? AppColors.accent : AppColors.text(cs))
|
||||
}
|
||||
if dots.isEmpty {
|
||||
if items.isEmpty {
|
||||
Text("Free").font(AppFonts.sans(9)).foregroundColor(AppColors.text3(cs))
|
||||
} else {
|
||||
ForEach(dots.indices, id: \.self) { i in
|
||||
RoundedRectangle(cornerRadius: 2).fill(dots[i].opacity(0.5))
|
||||
.frame(maxWidth: .infinity).frame(height: 7)
|
||||
ForEach(Array(items.prefix(4).enumerated()), id: \.offset) { _, item in
|
||||
HStack(spacing: 5) {
|
||||
RoundedRectangle(cornerRadius: 1.5).fill(item.color)
|
||||
.frame(width: 2.5, height: 11)
|
||||
Text(item.title).font(AppFonts.sans(9))
|
||||
.foregroundColor(AppColors.text2(cs)).lineLimit(1)
|
||||
}
|
||||
}
|
||||
if items.count > 4 {
|
||||
Text("+\(items.count - 4) more").font(AppFonts.sans(8))
|
||||
.foregroundColor(AppColors.text3(cs))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -890,7 +892,66 @@ struct CalendarView: View {
|
||||
|
||||
private func cvTimeGrid(days: [Date]) -> some View {
|
||||
let totalH = CGFloat(cvEndH - cvStartH) * cvHourH
|
||||
return ZStack(alignment: .topLeading) {
|
||||
return VStack(spacing: 0) {
|
||||
cvAllDayBand(days: days)
|
||||
cvHourGrid(days: days, totalH: totalH)
|
||||
}
|
||||
}
|
||||
|
||||
/// Untimed tasks, all-day events and the day's workout — these have no slot on
|
||||
/// the hour grid, so they sit in a compact band above it (one column per day).
|
||||
private func cvAllDayItems(_ date: Date) -> [CVTimeItem] {
|
||||
var items: [CVTimeItem] = []
|
||||
if let w = workoutVM.program(for: date) {
|
||||
items.append(CVTimeItem(title: w.name, color: AppColors.blue, startMin: -1, endMin: -1))
|
||||
}
|
||||
for t in taskVM.occurrences(on: date) where !t.isComplete && !t.hasTime {
|
||||
items.append(CVTimeItem(title: t.title, color: t.quadrant.color, startMin: -1, endMin: -1))
|
||||
}
|
||||
for ev in (calStore.isAuthorized ? calStore.events(for: date) : []) where ev.isAllDay {
|
||||
items.append(CVTimeItem(title: ev.title ?? "Event", color: Color(cgColor: ev.calendar.cgColor), startMin: -1, endMin: -1))
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
/// Everything happening on a date — all-day items first, then timed — for compact
|
||||
/// agenda listings (e.g. the Week column). Recurrence-aware.
|
||||
private func cvAgendaItems(_ date: Date) -> [CVTimeItem] {
|
||||
(cvAllDayItems(date) + cvTimeItems(date)).sorted { $0.startMin < $1.startMin }
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func cvAllDayBand(days: [Date]) -> some View {
|
||||
let perDay = days.map { cvAllDayItems($0) }
|
||||
if perDay.contains(where: { !$0.isEmpty }) {
|
||||
HStack(alignment: .top, spacing: 2) {
|
||||
Text("all-day")
|
||||
.font(AppFonts.mono(7, weight: .semibold))
|
||||
.foregroundColor(AppColors.text3(cs))
|
||||
.frame(width: 36, alignment: .trailing)
|
||||
ForEach(Array(days.enumerated()), id: \.offset) { idx, _ in
|
||||
VStack(spacing: 2) {
|
||||
ForEach(Array(perDay[idx].enumerated()), id: \.offset) { _, item in
|
||||
Text(item.title)
|
||||
.font(AppFonts.sans(8.5, weight: .medium))
|
||||
.foregroundColor(item.color)
|
||||
.lineLimit(1)
|
||||
.padding(.horizontal, 5).padding(.vertical, 3)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(item.color.opacity(0.18))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 8).padding(.vertical, 6)
|
||||
Divider().background(AppColors.border(cs))
|
||||
}
|
||||
}
|
||||
|
||||
private func cvHourGrid(days: [Date], totalH: CGFloat) -> some View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
VStack(spacing: 0) {
|
||||
ForEach(cvStartH...cvEndH, id: \.self) { h in
|
||||
HStack(spacing: 0) {
|
||||
@@ -996,10 +1057,11 @@ struct CalendarView: View {
|
||||
|
||||
private func cvTimeItems(_ date: Date) -> [CVTimeItem] {
|
||||
var items: [CVTimeItem] = []
|
||||
for task in taskVM.tasks where !task.isComplete {
|
||||
guard let d = task.dueDate, cal.isDate(d, inSameDayAs: date) else { continue }
|
||||
// Recurrence-aware, and only *timed* tasks belong on the hour grid —
|
||||
// untimed tasks are surfaced separately in the all-day band.
|
||||
for task in taskVM.occurrences(on: date) where !task.isComplete && task.hasTime {
|
||||
guard let d = task.dueDate else { continue }
|
||||
let h = cal.component(.hour, from: d), m = cal.component(.minute, from: d)
|
||||
guard h != 0 || m != 0 else { continue }
|
||||
items.append(CVTimeItem(title: task.title, color: task.quadrant.color, startMin: h * 60 + m, endMin: h * 60 + m + 30))
|
||||
}
|
||||
for ev in calStore.isAuthorized ? calStore.events(for: date) : [] {
|
||||
|
||||
@@ -1277,24 +1277,35 @@ struct TaskRowView: View {
|
||||
let task: TaskItem
|
||||
let onToggle: () -> Void
|
||||
|
||||
@State private var showCompleteConfirm = false
|
||||
|
||||
private let dueFmt: DateFormatter = {
|
||||
let f = DateFormatter(); f.dateFormat = "MMM d"; return f
|
||||
}()
|
||||
|
||||
/// A task scheduled for a day after today — completing one of these is easy to do
|
||||
/// by accident from the Next 7 Days / Later sections, so we confirm first.
|
||||
private var isFutureTask: Bool {
|
||||
guard let d = task.dueDate else { return false }
|
||||
let cal = Calendar.current
|
||||
return cal.startOfDay(for: d) > cal.startOfDay(for: Date())
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 10) {
|
||||
Button(action: onToggle) {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(task.quadrant.softColor)
|
||||
.frame(width: 22, height: 22)
|
||||
Circle()
|
||||
.stroke(task.quadrant.color, lineWidth: 2)
|
||||
.frame(width: 22, height: 22)
|
||||
Button {
|
||||
if !task.isComplete && isFutureTask {
|
||||
showCompleteConfirm = true
|
||||
} else {
|
||||
onToggle()
|
||||
}
|
||||
.frame(width: 36, height: 44)
|
||||
.padding(.leading, 4)
|
||||
.contentShape(Circle())
|
||||
} label: {
|
||||
Circle()
|
||||
.strokeBorder(task.quadrant.color, lineWidth: 1.5)
|
||||
.frame(width: 18, height: 18)
|
||||
.frame(width: 36, height: 44)
|
||||
.padding(.leading, 4)
|
||||
.contentShape(Circle())
|
||||
}
|
||||
.buttonStyle(PressButtonStyle(scale: 0.82))
|
||||
|
||||
@@ -1350,6 +1361,18 @@ struct TaskRowView: View {
|
||||
.clipShape(RoundedRectangle(cornerRadius: AppRadius.small))
|
||||
.overlay(RoundedRectangle(cornerRadius: AppRadius.small)
|
||||
.stroke(AppColors.border(cs), lineWidth: 1))
|
||||
.confirmationDialog(
|
||||
"Complete this task?",
|
||||
isPresented: $showCompleteConfirm,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Mark Complete") { onToggle() }
|
||||
Button("Cancel", role: .cancel) {}
|
||||
} message: {
|
||||
if let d = task.dueDate {
|
||||
Text("“\(task.title)” is scheduled for \(dueFmt.string(from: d)).")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func countdownLabel(to date: Date) -> String {
|
||||
|
||||
Reference in New Issue
Block a user