96 lines
3.0 KiB
Swift
96 lines
3.0 KiB
Swift
import SwiftUI
|
|
import Bedrock
|
|
|
|
struct RitualProgressStatsView: View {
|
|
let currentDay: Int
|
|
let totalDays: Int
|
|
let habitsCompleted: Int
|
|
let habitsTotal: Int
|
|
let daysRemaining: Int
|
|
let progress: Double
|
|
|
|
var body: some View {
|
|
VStack(spacing: Design.Spacing.large) {
|
|
// Stats row - evenly distributed
|
|
HStack(spacing: 0) {
|
|
statColumn(
|
|
value: "\(currentDay)",
|
|
secondary: String(localized: "of \(totalDays)"),
|
|
label: String(localized: "Days")
|
|
)
|
|
.frame(maxWidth: .infinity)
|
|
|
|
statColumn(
|
|
value: "\(habitsCompleted)",
|
|
secondary: String(localized: "of \(habitsTotal)"),
|
|
label: String(localized: "Habits")
|
|
)
|
|
.frame(maxWidth: .infinity)
|
|
|
|
statColumn(
|
|
value: "\(daysRemaining)",
|
|
secondary: nil,
|
|
label: String(localized: "Remaining")
|
|
)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
|
|
// Progress bar
|
|
VStack(alignment: .leading, spacing: Design.Spacing.xSmall) {
|
|
ProgressView(value: progress)
|
|
.tint(AppAccent.primary)
|
|
|
|
Text("\(Int(progress * 100))% complete")
|
|
.font(.caption)
|
|
.foregroundStyle(AppTextColors.secondary)
|
|
}
|
|
}
|
|
.padding(Design.Spacing.large)
|
|
.background(AppSurface.card)
|
|
.clipShape(.rect(cornerRadius: Design.CornerRadius.large))
|
|
.accessibilityElement(children: .combine)
|
|
}
|
|
|
|
private func statColumn(value: String, secondary: String?, label: String) -> some View {
|
|
VStack(spacing: Design.Spacing.xSmall) {
|
|
Text(value)
|
|
.font(.title)
|
|
.fontWeight(.bold)
|
|
.foregroundStyle(AppTextColors.primary)
|
|
|
|
// Always show secondary row for consistent height
|
|
Text(secondary ?? " ")
|
|
.font(.caption)
|
|
.foregroundStyle(secondary != nil ? AppTextColors.tertiary : .clear)
|
|
|
|
Text(label)
|
|
.font(.caption2)
|
|
.foregroundStyle(AppTextColors.secondary)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
VStack(spacing: Design.Spacing.large) {
|
|
RitualProgressStatsView(
|
|
currentDay: 16,
|
|
totalDays: 28,
|
|
habitsCompleted: 2,
|
|
habitsTotal: 3,
|
|
daysRemaining: 12,
|
|
progress: 0.57
|
|
)
|
|
|
|
RitualProgressStatsView(
|
|
currentDay: 1,
|
|
totalDays: 21,
|
|
habitsCompleted: 0,
|
|
habitsTotal: 4,
|
|
daysRemaining: 21,
|
|
progress: 0.0
|
|
)
|
|
}
|
|
.padding(Design.Spacing.large)
|
|
.background(AppSurface.primary)
|
|
}
|