79 lines
3.3 KiB
Swift
79 lines
3.3 KiB
Swift
import SwiftUI
|
|
import WidgetKit
|
|
import Bedrock
|
|
|
|
struct LargeWidgetView: View {
|
|
let entry: WidgetEntry
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: Design.Spacing.large) {
|
|
HStack {
|
|
VStack(alignment: .leading, spacing: Design.Spacing.xSmall) {
|
|
Text(String(localized: "Today's Progress"))
|
|
.styled(.heading, emphasis: .custom(.white))
|
|
Text("\(entry.currentStreak) day streak")
|
|
.styled(.subheading, emphasis: .custom(Color.brandingAccent))
|
|
}
|
|
Spacer()
|
|
ZStack {
|
|
Circle()
|
|
.stroke(Color.white.opacity(0.1), lineWidth: 6)
|
|
Circle()
|
|
.trim(from: 0, to: entry.completionRate)
|
|
.stroke(Color.brandingAccent, style: StrokeStyle(lineWidth: 6, lineCap: .round))
|
|
.rotationEffect(.degrees(-90))
|
|
Text("\(Int(entry.completionRate * 100))%")
|
|
.styled(.captionEmphasis, emphasis: .custom(.white))
|
|
}
|
|
.frame(width: 50, height: 50)
|
|
}
|
|
|
|
Divider()
|
|
.background(Color.white.opacity(0.2))
|
|
|
|
if entry.nextHabits.isEmpty {
|
|
Spacer()
|
|
WidgetEmptyStateView(
|
|
title: String(localized: "No rituals scheduled for \(entry.currentTimeOfDay.lowercased())."),
|
|
subtitle: entry.currentTimeOfDay,
|
|
symbolName: entry.currentTimeOfDaySymbol,
|
|
timeRange: entry.currentTimeOfDayRange
|
|
)
|
|
Spacer()
|
|
} else {
|
|
Text(String(localized: "Habits"))
|
|
.styled(.captionEmphasis, emphasis: .custom(.white.opacity(0.7)))
|
|
|
|
VStack(spacing: Design.Spacing.medium) {
|
|
ForEach(entry.nextHabits) { habit in
|
|
HStack(spacing: Design.Spacing.medium) {
|
|
Image(systemName: habit.symbolName)
|
|
.foregroundColor(Color.brandingAccent)
|
|
.font(.system(size: 18))
|
|
.frame(width: 24)
|
|
|
|
VStack(alignment: .leading, spacing: Design.Spacing.xSmall) {
|
|
Text(habit.title)
|
|
.styled(.subheading, emphasis: .custom(.white))
|
|
Text(habit.ritualTitle)
|
|
.styled(.caption, emphasis: .custom(.white.opacity(0.5)))
|
|
}
|
|
Spacer()
|
|
|
|
Image(systemName: habit.isCompleted ? "checkmark.circle.fill" : "circle")
|
|
.foregroundColor(habit.isCompleted ? .green : .white.opacity(0.2))
|
|
.font(.system(size: 20))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(Design.Spacing.large)
|
|
.containerBackground(for: .widget) {
|
|
Color.brandingPrimary
|
|
}
|
|
}
|
|
}
|