Widget änderungen, sync änderungen

This commit is contained in:
Scarriffle
2026-05-28 21:43:18 +02:00
parent 4125bfc728
commit e71fd7512f
9 changed files with 726 additions and 57 deletions

View File

@@ -10,7 +10,7 @@ struct ThisWeekWidgetView: View {
private var cal: Calendar {
var c = Calendar(identifier: .gregorian)
c.locale = WidgetL10n.locale(lang)
c.firstWeekday = 2 // Monday
c.firstWeekday = 2
return c
}
@@ -40,7 +40,7 @@ struct ThisWeekWidgetView: View {
if let s = snapshot {
let primary = Color(widgetHex: s.primaryColorHex)
let accent = Color(widgetHex: s.accentColorHex)
VStack(alignment: .leading, spacing: 2) {
VStack(alignment: .leading, spacing: 3) {
HStack(alignment: .firstTextBaseline, spacing: 4) {
Text(monthHeader.split(separator: " ").first.map(String.init) ?? "")
.font(.system(size: 10, weight: .bold))
@@ -48,22 +48,21 @@ struct ThisWeekWidgetView: View {
Text(monthHeader.split(separator: " ").dropFirst().joined(separator: " "))
.font(.system(size: 10, weight: .semibold))
}
GeometryReader { geo in
let colW = geo.size.width / 7
HStack(spacing: 0) {
ForEach(Array(weekDays.enumerated()), id: \.offset) { idx, day in
dayColumn(day, snapshot: s, primary: primary, accent: accent)
.frame(width: colW)
.overlay(alignment: .trailing) {
if idx < 6 {
Rectangle()
.fill(Color(widgetHex: s.lineColorHex).opacity(0.35))
.frame(width: 0.5)
}
// Equal-width columns via maxWidth no GeometryReader needed
HStack(spacing: 0) {
ForEach(Array(weekDays.enumerated()), id: \.offset) { idx, day in
dayColumn(day, snapshot: s, primary: primary, accent: accent)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.overlay(alignment: .trailing) {
if idx < 6 {
Rectangle()
.fill(Color(widgetHex: s.lineColorHex).opacity(0.35))
.frame(width: 0.5)
}
}
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
} else {
Text(WidgetL10n.t("widget.no_data", lang))
@@ -80,22 +79,22 @@ struct ThisWeekWidgetView: View {
let isToday = cal.isDateInToday(day)
let evs = WidgetHelpers.events(for: day, in: snapshot)
let dayIdx = (0..<7).firstIndex { i in cal.isDate(weekDays[i], inSameDayAs: day) } ?? 0
return VStack(spacing: 1) {
return VStack(alignment: .center, spacing: 1) {
Text(weekdayHeaders[dayIdx])
.font(.system(size: 7.5, weight: .bold))
.foregroundStyle(isToday ? accent : .secondary)
Text("\(cal.component(.day, from: day))")
.font(.system(size: 10, weight: isToday ? .bold : .semibold))
.foregroundStyle(isToday ? Color.white : Color.primary)
.frame(width: 15, height: 15)
.frame(width: 16, height: 16)
.background(isToday ? primary : Color.clear)
.clipShape(Circle())
ForEach(evs.prefix(2)) { ev in
ForEach(evs.prefix(3)) { ev in
eventPill(ev)
}
if evs.count > 2 {
Text("+\(evs.count - 2)")
.font(.system(size: 7))
if evs.count > 3 {
Text("+\(evs.count - 3)")
.font(.system(size: 6.5))
.foregroundStyle(accent)
}
Spacer(minLength: 0)