80 lines
3.3 KiB
Swift
80 lines
3.3 KiB
Swift
import SwiftUI
|
|
import WidgetKit
|
|
import Bedrock
|
|
|
|
struct MediumWidgetView: View {
|
|
let entry: WidgetEntry
|
|
|
|
var body: some View {
|
|
HStack(spacing: 0) {
|
|
// Left side: Progress & Streak
|
|
VStack(spacing: Design.Spacing.medium) {
|
|
ZStack {
|
|
Circle()
|
|
.stroke(Color.white.opacity(0.1), lineWidth: 8)
|
|
Circle()
|
|
.trim(from: 0, to: entry.completionRate)
|
|
.stroke(Color.brandingAccent, style: StrokeStyle(lineWidth: 8, lineCap: .round))
|
|
.rotationEffect(.degrees(-90))
|
|
|
|
VStack(spacing: 0) {
|
|
Text("\(Int(entry.completionRate * 100))%")
|
|
.styled(.heading, emphasis: .custom(.white))
|
|
Text(String(localized: "Today"))
|
|
.styled(.caption, emphasis: .custom(.white.opacity(0.7)))
|
|
}
|
|
}
|
|
.frame(width: 72, height: 72)
|
|
|
|
HStack(spacing: Design.Spacing.xSmall) {
|
|
Image(systemName: "flame.fill")
|
|
.foregroundColor(Color.brandingAccent)
|
|
.font(.system(size: 14))
|
|
Text("\(entry.currentStreak)d")
|
|
.styled(.captionEmphasis, emphasis: .custom(.white))
|
|
}
|
|
}
|
|
.frame(width: 110)
|
|
|
|
// Right side: Habits
|
|
VStack(alignment: .leading, spacing: Design.Spacing.medium) {
|
|
if entry.nextHabits.isEmpty {
|
|
WidgetEmptyStateView(
|
|
title: String(localized: "No rituals now"),
|
|
subtitle: entry.currentTimeOfDay,
|
|
symbolName: entry.currentTimeOfDaySymbol,
|
|
timeRange: entry.currentTimeOfDayRange
|
|
)
|
|
} else {
|
|
Text(String(localized: "Next Habits"))
|
|
.styled(.captionEmphasis, emphasis: .custom(.white.opacity(0.7)))
|
|
|
|
VStack(alignment: .leading, spacing: Design.Spacing.small) {
|
|
ForEach(entry.nextHabits.prefix(3)) { habit in
|
|
HStack(spacing: Design.Spacing.small) {
|
|
Image(systemName: habit.isCompleted ? "checkmark.circle.fill" : habit.symbolName)
|
|
.foregroundColor(habit.isCompleted ? .green : Color.brandingAccent)
|
|
.font(.system(size: 14))
|
|
.frame(width: 20)
|
|
|
|
Text(habit.title)
|
|
.styled(.subheading, emphasis: .custom(.white))
|
|
.lineLimit(1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.vertical, Design.Spacing.large)
|
|
.padding(.trailing, Design.Spacing.medium)
|
|
|
|
Spacer()
|
|
}
|
|
.containerBackground(for: .widget) {
|
|
Color.brandingPrimary
|
|
}
|
|
}
|
|
}
|