iOS widget enhancements
This commit is contained in:
@@ -3,6 +3,7 @@ import WidgetKit
|
||||
|
||||
struct TimetableWeekView: View {
|
||||
let entry: TimetableEntry
|
||||
@Environment(\.widgetPalette) private var palette
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
@@ -15,7 +16,6 @@ struct TimetableWeekView: View {
|
||||
}
|
||||
}
|
||||
.background(MarianumWatermark())
|
||||
.widgetThemeOverride(entry.themeMode)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -52,7 +52,7 @@ struct TimetableWeekView: View {
|
||||
|
||||
private var columnDivider: some View {
|
||||
Rectangle()
|
||||
.fill(Color.primary.opacity(0.13))
|
||||
.fill(palette.divider)
|
||||
.frame(width: 1)
|
||||
}
|
||||
|
||||
@@ -63,16 +63,23 @@ struct TimetableWeekView: View {
|
||||
return HStack {
|
||||
Text("KW \(week) · \(shortDate(data.anchorDate))–\(shortDate(endDate))")
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
.foregroundStyle(.primary)
|
||||
.foregroundStyle(palette.textPrimary)
|
||||
Spacer()
|
||||
Text("Stand: \(freshnessLabel(for: data.fetchedAt))")
|
||||
.font(.system(size: 10))
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(palette.textSecondary)
|
||||
}
|
||||
}
|
||||
|
||||
private func dayHeaderRow(data: WidgetTimetableData) -> some View {
|
||||
let cal = Calendar.current
|
||||
// `.frame(maxWidth: .infinity)` is critical: without an explicit
|
||||
// greedy width (or a true `Spacer()` inside), this HStack collapses
|
||||
// to the sum of its fixed-width children in a `.leading` VStack
|
||||
// and the 5 day-columns end up sharing ~5pt of width — the labels
|
||||
// crunch to the left and stop aligning with the grid columns below.
|
||||
// The fixed height keeps `columnDivider`'s vertically-flexible
|
||||
// Rectangle from stealing space from the GeometryReader.
|
||||
return HStack(spacing: 0) {
|
||||
Spacer().frame(width: 28)
|
||||
columnDivider
|
||||
@@ -81,15 +88,16 @@ struct TimetableWeekView: View {
|
||||
VStack(spacing: 0) {
|
||||
Text(weekday(for: day))
|
||||
.font(.system(size: 11, weight: .bold))
|
||||
.foregroundStyle(.primary)
|
||||
.foregroundStyle(palette.textPrimary)
|
||||
Text(shortDate(day))
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(palette.textSecondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
if offset < 4 { columnDivider }
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 26, maxHeight: 26)
|
||||
}
|
||||
|
||||
private func timeLabelsColumn(hourHeight: CGFloat, periods: [WidgetPeriod]) -> some View {
|
||||
@@ -98,7 +106,7 @@ struct TimetableWeekView: View {
|
||||
return ZStack(alignment: .topTrailing) {
|
||||
ForEach(periodBoundaries(periods), id: \.self) { virtualMin in
|
||||
Rectangle()
|
||||
.fill(Color.primary.opacity(0.08))
|
||||
.fill(palette.divider)
|
||||
.frame(height: 1)
|
||||
.offset(y: CGFloat(virtualMin) * hourHeight / 60.0)
|
||||
}
|
||||
@@ -106,11 +114,11 @@ struct TimetableWeekView: View {
|
||||
VStack(alignment: .trailing, spacing: -2) {
|
||||
Text(String(format: "%02d:%02d", period.startMinutes / 60, period.startMinutes % 60))
|
||||
.font(.system(size: 8))
|
||||
.foregroundStyle(.primary)
|
||||
.foregroundStyle(palette.textPrimary)
|
||||
.lineLimit(1)
|
||||
Text("\(period.name).")
|
||||
.font(.system(size: 6, weight: .bold))
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(palette.textSecondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.offset(y: CGFloat(period.virtualStartMinutes) * hourHeight / 60.0)
|
||||
@@ -150,9 +158,10 @@ struct TimetableWeekView: View {
|
||||
VStack(spacing: 4) {
|
||||
Text("Marianum Stundenplan")
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundStyle(palette.textPrimary)
|
||||
Text(message)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(palette.textSecondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
Reference in New Issue
Block a user