summaryrefslogtreecommitdiffstats
path: root/Solsnu.Widget/Views/MediumWidgetView.swift
blob: f6fdbd94a98c18b92691669bfbd2de8d5904f4be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import SwiftUI
import WidgetKit

struct MediumWidgetView: View {
    let entry: SolvervEntry

    var body: some View {
        HStack(spacing: 12) {
            VStack(alignment: .leading, spacing: 8) {
                if let next = entry.nextEvent {
                    Text(next.shortName)
                        .font(.headline)
                        .lineLimit(1)

                    Text("\(next.daysUntil(from: entry.date)) dager")
                        .font(.system(.title3, design: .default).weight(.semibold))
                }

                ProgressView(value: entry.progressRatio)

                if let sunrise = entry.sunriseTime, let sunset = entry.sunsetTime {
                    HStack {
                        Label {
                            Text(sunrise, style: .time)
                        } icon: {
                            Image(systemName: "sunrise.fill")
                        }
                        Spacer()
                        Label {
                            Text(sunset, style: .time)
                        } icon: {
                            Image(systemName: "sunset.fill")
                        }
                    }
                    .font(.system(size: 12, weight: .regular))
                    .foregroundStyle(Color(red: 0.152, green: 0.136, blue: 0.056))
                }

                Spacer()
            }

            Spacer()
        }
        .padding()
        .containerBackground(.fill.tertiary, for: .widget)
    }
}