C1 — Localization: route the remaining hardcoded German strings through L10n (LoginView, ServerSetupView, SettingsView email, EventDetailSheet) so "System Default" + English device language shows fully English text. C2 — Per-calendar reminders: parse the new reminders_enabled flag on every calendar type; CalendarStore persists a reminderDisabledKeys set and passes it to NotificationScheduler, which skips events of muted calendars (default and per-event reminders). Filter sheet gains a per-calendar reminder toggle (leading swipe + bell.slash indicator), reconciled from the server and synced back via PUT. C3 — Widgets: - Shared WidgetTime.range helper; Today / Today & Tomorrow / Three Days / Up Next now show start–end instead of only the start time. - This Week: show up to 6 events per day (was 3) to use the height. - Two Weeks: mini event-title pills instead of bare dots. - Two Months: weeks expand to fill the column (no more empty lower third). - Day & Events: smaller header/strip/rows so content stops clipping. - Next 5 days → Next 7 days (range + labels), higher row cap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85 lines
2.7 KiB
Swift
85 lines
2.7 KiB
Swift
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct TodayWidgetView: View {
|
|
let entry: CalendarrEntry
|
|
|
|
private var snapshot: WidgetSnapshot? { entry.snapshot }
|
|
|
|
private var todayEvents: [WidgetEvent] {
|
|
guard let s = snapshot else { return [] }
|
|
return WidgetHelpers.events(for: entry.date, in: s)
|
|
}
|
|
|
|
private var lang: String { snapshot?.language ?? "system" }
|
|
|
|
private var timeFmt: DateFormatter {
|
|
let f = DateFormatter()
|
|
f.locale = WidgetL10n.locale(lang)
|
|
f.dateFormat = "HH:mm"
|
|
return f
|
|
}
|
|
|
|
var body: some View {
|
|
let primary = Color(widgetHex: snapshot?.primaryColorHex ?? "#4285f4")
|
|
let accent = Color(widgetHex: snapshot?.accentColorHex ?? "#ea4335")
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
HStack {
|
|
Text(WidgetL10n.t("widget.today", lang))
|
|
.font(.caption.weight(.bold))
|
|
.foregroundStyle(primary)
|
|
Spacer()
|
|
Text(headerDate)
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
|
|
if snapshot == nil {
|
|
Text(WidgetL10n.t("widget.no_data", lang))
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
} else if todayEvents.isEmpty {
|
|
Spacer()
|
|
Text(WidgetL10n.t("widget.no_events", lang))
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
Spacer()
|
|
} else {
|
|
ForEach(todayEvents.prefix(3)) { ev in
|
|
eventRow(ev)
|
|
}
|
|
if todayEvents.count > 3 {
|
|
Text(String(format: WidgetL10n.t("widget.more", lang), todayEvents.count - 3))
|
|
.font(.caption2)
|
|
.foregroundStyle(accent)
|
|
}
|
|
Spacer(minLength: 0)
|
|
}
|
|
}
|
|
}
|
|
|
|
private var headerDate: String {
|
|
let f = DateFormatter()
|
|
f.locale = WidgetL10n.locale(lang)
|
|
f.dateFormat = "d. MMM"
|
|
return f.string(from: entry.date)
|
|
}
|
|
|
|
private func eventRow(_ ev: WidgetEvent) -> some View {
|
|
HStack(spacing: 6) {
|
|
RoundedRectangle(cornerRadius: 2)
|
|
.fill(Color(widgetHex: ev.colorHex))
|
|
.frame(width: 3)
|
|
VStack(alignment: .leading, spacing: 1) {
|
|
Text(ev.title)
|
|
.font(.caption.weight(.medium))
|
|
.lineLimit(1)
|
|
Text(WidgetTime.range(ev, lang: lang))
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
Spacer(minLength: 0)
|
|
}
|
|
}
|
|
}
|