summaryrefslogtreecommitdiffstats
path: root/Solsnu.Widget/Views
diff options
context:
space:
mode:
authorivar <i@oiee.no>2026-03-24 12:32:50 +0100
committerivar <i@oiee.no>2026-03-24 12:32:50 +0100
commit17ec71ada86cde7e4dcfdbc20cb0d59b18aa4e34 (patch)
tree77f3c649df1aec32ee1168fc3e4ef59822390c55 /Solsnu.Widget/Views
parent35346562bd81412ab998e79f3a64eda2585c9e41 (diff)
downloadsolverv-17ec71ada86cde7e4dcfdbc20cb0d59b18aa4e34.tar.xz
solverv-17ec71ada86cde7e4dcfdbc20cb0d59b18aa4e34.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'Solsnu.Widget/Views')
-rw-r--r--Solsnu.Widget/Views/SmallWidgetView.swift39
1 files 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)
-}