Compare commits

..

3 Commits

Author SHA1 Message Date
kutesir
3134c064e9 Calendar: fix week/3-day dead space (pin content to top)
Some checks failed
CI / build-and-test (push) Has been cancelled
The timeline views' content is a thin header + a greedy ScrollView (≈0 ideal
height), so the top-level VStack shrank and the bottomTrailing ZStack floated
it to the bottom — leaving a big empty gap above the day header. Month view
has a tall fixed grid so it never surfaced. Pin the VStack to fill height and
top-align.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 01:13:23 +03:00
kutesir
0a87769561 Revert "Calendar month view: TickTick-style bars + collapse-to-week"
This reverts commit 2ec3278632.
2026-07-07 01:12:14 +03:00
kutesir
e8d74d4f59 Revert "Calendar month: drag-to-collapse + full-column selection highlight"
This reverts commit bd43eecfbe.
2026-07-07 01:09:58 +03:00

View File

@@ -296,9 +296,6 @@ struct CalendarView: View {
@State private var calTaskListMode: Bool = false
/// Year currently at the top of the continuous year scroll (drives the header in .year mode).
@State private var visibleYear: Int = Calendar.current.component(.year, from: Date())
/// Month view: full grid when true, only the selected day's week when false
/// (TickTick-style collapses to give the day agenda more room).
@State private var monthExpanded: Bool = true
/// Week view: timeline when false, grid of day-cards when true.
@State private var weekGrid: Bool = false
@State private var showAddTask = false
@@ -395,6 +392,9 @@ struct CalendarView: View {
calDayTaskListView
}
}
// Pin to the top so views whose content doesn't fill the height
// (week / 3-day timelines) don't float to the bottom of the ZStack.
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
FAB { showAddTask = true }
.padding(.trailing, 20).padding(.bottom, 10)
@@ -467,25 +467,10 @@ struct CalendarView: View {
CalendarGrid.monthGrid(for: displayMonth, calendar: cal)
}
/// The month grid split into week rows of 7.
private func weekRows() -> [[Date]] {
let days = gridDays()
return stride(from: 0, to: days.count, by: 7).map { Array(days[$0..<min($0 + 7, days.count)]) }
}
/// The single week row that contains the currently selected day.
private func selectedWeekRow() -> [Date] {
let rows = weekRows()
return rows.first { row in row.contains { cal.isDate($0, inSameDayAs: selectedDate) } } ?? (rows.first ?? [])
}
/// Colors of the schedule bars shown under a day in the month grid
/// (workout · calendar events · tasks), capped so cells stay compact.
private func eventDots(for date: Date) -> [Color] {
let maxBars = 4
var dots: [Color] = []
if workoutVM.program(for: date) != nil { dots.append(AppColors.blue) }
if calStore.isAuthorized && dots.count < maxBars {
if calStore.isAuthorized && dots.count < 3 {
let calDay = calStore.events(for: date)
if !calDay.isEmpty {
let calColor = calDay.first.flatMap { Color(cgColor: $0.calendar.cgColor) } ?? AppColors.green
@@ -495,7 +480,7 @@ struct CalendarView: View {
// Includes recurring occurrences that land on this date.
let taskDots = taskVM.occurrences(on: date)
.filter { !$0.isComplete }
.prefix(max(0, maxBars - dots.count))
.prefix(max(0, 3 - dots.count))
.map { $0.quadrant.color }
dots.append(contentsOf: taskDots)
return dots
@@ -584,59 +569,25 @@ struct CalendarView: View {
}
.padding(.horizontal, 16).padding(.top, 14).padding(.bottom, 3)
// Full month (expanded) or just the selected day's week (collapsed).
let rows = monthExpanded ? weekRows() : [selectedWeekRow()]
VStack(spacing: 1) {
ForEach(rows.indices, id: \.self) { ri in
HStack(spacing: 1) {
ForEach(rows[ri], id: \.self) { date in
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 1), count: 7), spacing: 1) {
ForEach(gridDays(), id: \.self) { date in
DayCell(
date: date,
isCurrentMonth: cal.isDate(date, equalTo: displayMonth, toGranularity: .month),
isToday: cal.isDateInToday(date),
isSelected: cal.isDate(date, inSameDayAs: selectedDate),
bars: eventDots(for: date),
highlightColumn: !monthExpanded && cal.isDate(date, inSameDayAs: selectedDate)
dots: eventDots(for: date)
)
.onTapGesture {
withAnimation(KisaniSpring.snappy) {
selectedDate = date
monthExpanded = false // collapse to this week, reveal the agenda
}
}
}
}
.onTapGesture { withAnimation(KisaniSpring.micro) { selectedDate = date } }
}
}
.padding(.horizontal, 16)
.gesture(DragGesture(minimumDistance: 30).onEnded { v in
let dx = v.translation.width, dy = v.translation.height
if abs(dx) > abs(dy) {
// Horizontal swipe previous/next month
if dx < -40 { navigateMonth(1) }
else if dx > 40 { navigateMonth(-1) }
} else {
// Vertical drag collapse to week (up) / expand to month (down)
withAnimation(KisaniSpring.snappy) {
if dy < -30 { monthExpanded = false }
else if dy > 30 { monthExpanded = true }
}
}
.gesture(DragGesture(minimumDistance: 40).onEnded { v in
if v.translation.width < -40 { navigateMonth(1) }
else if v.translation.width > 40 { navigateMonth(-1) }
})
// Grabber expand back to the full month, or collapse to the week.
Button {
withAnimation(KisaniSpring.snappy) { monthExpanded.toggle() }
} label: {
Image(systemName: monthExpanded ? "chevron.up" : "chevron.down")
.font(.system(size: 11, weight: .semibold))
.foregroundColor(AppColors.text3(cs))
.frame(maxWidth: .infinity).frame(height: 22)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
Divider().background(AppColors.border(cs)).padding(.horizontal, 16)
Divider().background(AppColors.border(cs)).padding(.horizontal, 16).padding(.top, 6)
ScrollView(showsIndicators: false) {
DayTimelineView(
@@ -1742,8 +1693,7 @@ struct AddCalendarHolidaysView: View {
// MARK: - Day Cell
struct DayCell: View {
@Environment(\.colorScheme) private var cs
let date: Date; let isCurrentMonth: Bool; let isToday: Bool; let isSelected: Bool; let bars: [Color]
var highlightColumn: Bool = false
let date: Date; let isCurrentMonth: Bool; let isToday: Bool; let isSelected: Bool; let dots: [Color]
private let cal = Calendar.current
var dayNum: String { "\(cal.component(.day, from: date))" }
/// Locale week-of-year (NOT ISO), intentionally matching the locale-driven grid
@@ -1768,24 +1718,14 @@ struct DayCell: View {
Text("W\(weekNum)").font(AppFonts.mono(6.5)).foregroundColor(AppColors.text3(cs)).offset(x: -2, y: -10)
}
}
// Schedule bars one per event/task, stacked (TickTick-style).
VStack(spacing: 1.5) {
ForEach(bars.indices, id: \.self) { i in
RoundedRectangle(cornerRadius: 1)
.fill(bars[i].opacity(0.85))
.frame(height: 3)
HStack(spacing: 2) {
ForEach(dots.indices, id: \.self) { i in
Circle().fill(dots[i]).frame(width: 3.5, height: 3.5)
}
}
.frame(maxWidth: .infinity, alignment: .top)
.padding(.horizontal, 3)
Spacer(minLength: 0)
.frame(height: 4)
}
.padding(.top, 4)
.frame(maxWidth: .infinity).frame(height: 54).contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10)
.fill(highlightColumn ? AppColors.text3(cs).opacity(0.12) : .clear)
)
.frame(maxWidth: .infinity).frame(height: 42).contentShape(Rectangle())
}
}