Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2026-01-26 17:31:37 -06:00
parent dd89905b29
commit e514f60ded
4 changed files with 10 additions and 4 deletions

View File

@ -82,7 +82,7 @@ final class Ritual {
var defaultDurationDays: Int = 28 var defaultDurationDays: Int = 28
// Scheduling // Scheduling
var timeOfDay: TimeOfDay = .anytime var timeOfDay: TimeOfDay = TimeOfDay.anytime
// Organization // Organization
var iconName: String = "sparkles" var iconName: String = "sparkles"

View File

@ -132,7 +132,7 @@ struct HistoryView: View {
Spacer() Spacer()
if hasMoreHistory || showingExpandedHistory { if hasMoreHistory || monthsToShow > baseMonthsToShow {
Button { Button {
withAnimation(.easeInOut(duration: Design.Animation.standard)) { withAnimation(.easeInOut(duration: Design.Animation.standard)) {
if monthsToShow > baseMonthsToShow { if monthsToShow > baseMonthsToShow {

View File

@ -226,8 +226,9 @@ struct RitualDetailView: View {
} }
if let lastArc = ritual.latestArc { if let lastArc = ritual.latestArc {
let totalCheckIns = lastArc.habits.reduce(0) { $0 + $1.completedDayIDs.count } let habits = lastArc.habits ?? []
let possibleCheckIns = lastArc.habits.count * lastArc.durationDays let totalCheckIns = habits.reduce(0) { $0 + $1.completedDayIDs.count }
let possibleCheckIns = habits.count * lastArc.durationDays
let completionRate = possibleCheckIns > 0 ? Int(Double(totalCheckIns) / Double(possibleCheckIns) * 100) : 0 let completionRate = possibleCheckIns > 0 ? Int(Double(totalCheckIns) / Double(possibleCheckIns) * 100) : 0
Text(String(localized: "Last arc completed with \(completionRate)% habit completion over \(lastArc.durationDays) days.")) Text(String(localized: "Last arc completed with \(completionRate)% habit completion over \(lastArc.durationDays) days."))

View File

@ -9,6 +9,7 @@ struct RitualsView: View {
@State private var showingCreateRitual = false @State private var showingCreateRitual = false
@State private var ritualToDelete: Ritual? @State private var ritualToDelete: Ritual?
@State private var ritualToRestart: Ritual? @State private var ritualToRestart: Ritual?
@State private var refreshToken = UUID()
enum RitualsTab: String, CaseIterable { enum RitualsTab: String, CaseIterable {
case current case current
@ -41,6 +42,7 @@ struct RitualsView: View {
pastRitualsContent pastRitualsContent
} }
} }
.id(refreshToken)
.padding(Design.Spacing.large) .padding(Design.Spacing.large)
} }
.background(LinearGradient( .background(LinearGradient(
@ -108,6 +110,9 @@ struct RitualsView: View {
} message: { } message: {
Text(String(localized: "This will start a new arc for this ritual with the same habits. You can modify habits after starting.")) Text(String(localized: "This will start a new arc for this ritual with the same habits. You can modify habits after starting."))
} }
.onChange(of: store.rituals) { _, _ in
refreshToken = UUID()
}
} }
// MARK: - Current Tab Content // MARK: - Current Tab Content