Files
videorem/videorem/YearCalendarView.swift

47 lines
1.4 KiB
Swift

//
// YearCalendarView.swift
// videorem
//
// Created by Felix Förtsch on 07.02.26.
//
import SwiftUI
// MARK: - Year Calendar View
/// A grid of mini calendars displaying all 12 months for the selected year.
struct YearCalendarView: View {
let viewModel: CalendarViewModel
let videoEntries: [VideoEntry]
let selectedDate: Date
let onMonthTap: (Int) -> Void
private let calendar = CalendarConfig.calendar
var body: some View {
ScrollView {
LazyVGrid(columns: [
GridItem(.flexible(), spacing: 8),
GridItem(.flexible(), spacing: 8),
GridItem(.flexible(), spacing: 8)
], spacing: 20) {
ForEach(0..<12, id: \.self) { monthIndex in
YearMonthCell(
year: calendar.component(.year, from: selectedDate),
month: monthIndex + 1,
videoEntries: videoEntries,
isCurrentMonth: viewModel.isCurrentMonth(
monthIndex + 1,
in: calendar.component(.year, from: selectedDate)
)
)
.onTapGesture {
onMonthTap(monthIndex + 1)
}
}
}
.padding(16)
}
.background(Color(.systemGroupedBackground))
}
}