From 17ec71ada86cde7e4dcfdbc20cb0d59b18aa4e34 Mon Sep 17 00:00:00 2001 From: ivar Date: Tue, 24 Mar 2026 12:32:50 +0100 Subject: feat: display sunrise/sunset times in small widget Updated SmallWidgetView to show sunrise/sunset times below the countdown when they're available. Uses a VStack layout with the countdown at top and times below it (only displayed if both sunrise and sunset are available). Times use the same text color with smaller font (11pt) to fit in the widget. Co-Authored-By: Claude Haiku 4.5 --- Solsnu.Widget/Views/SmallWidgetView.swift | 39 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Solsnu.Widget/Views/SmallWidgetView.swift b/Solsnu.Widget/Views/SmallWidgetView.swift index 4ca73a7..86aa913 100644 --- a/Solsnu.Widget/Views/SmallWidgetView.swift +++ b/Solsnu.Widget/Views/SmallWidgetView.swift @@ -1,28 +1,33 @@ import SwiftUI import WidgetKit +import Combine struct SmallWidgetView: View { let entry: SolvervEntry @Environment(\.widgetRenderingMode) var renderingMode - + @Environment(\.locale) var locale + var body: some View { - VStack(spacing: 8) { - // Seasonal emoji - Text(entry.emoji) - .font(.system(size: 40)) - - // Days countdown - Text("\(entry.def.daysUntilNext())") - .font(.system(.title, design: .default).weight(.bold)) + ZStack { + Image(entry.def.bg) + .resizable() + .scaledToFill() + VStack(spacing: 8) { + Text("\(entry.def.daysUntilNext())") + .font(.system(size: 26, weight: .bold, design: .serif)) + .foregroundStyle(Color(red: 0.152, green: 0.136, blue: 0.056)) + .italic() - Text("days") - .font(.caption2) + if !entry.def.sunriseFormatted.isEmpty && !entry.def.sunsetFormatted.isEmpty { + HStack(spacing: 4) { + Text("↑ \(entry.def.sunriseFormatted)") + Text("↓ \(entry.def.sunsetFormatted)") + } + .font(.system(size: 11, weight: .regular)) + .foregroundStyle(Color(red: 0.152, green: 0.136, blue: 0.056)) + } + } } - .padding() + .containerBackground(for: .widget, alignment: .center) { Color.clear } } } - -#Preview { - let entry = SolvervEntry(def: SolvervDef(utcString: "2026-12-21 20:50:00")) - SmallWidgetView(entry: entry) -} -- cgit v1.3