diff --git a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift index 45481d2..5e2844a 100644 --- a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift +++ b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift @@ -437,6 +437,15 @@ struct MonthlyCheckInView: View { ForEach(viewModel.sources, id: \.objectID) { source in let latestSnapshot = source.latestSnapshot let updatedThisCycle = isSnapshotInCurrentCycle(latestSnapshot) + let snapshots = source.sortedSnapshotsByDateAscending + let previousSnapshot: Snapshot? = { + guard snapshots.count >= 2 else { return nil } + return snapshots[snapshots.count - 2] + }() + let valueDiff: Decimal? = { + guard let latest = latestSnapshot, let previous = previousSnapshot else { return nil } + return latest.decimalValue - previous.decimalValue + }() Button { if updatedThisCycle, let snapshot = latestSnapshot { editingSnapshot = snapshot @@ -459,6 +468,12 @@ struct MonthlyCheckInView: View { Spacer() + if let diff = valueDiff, updatedThisCycle { + Text(diff >= 0 ? "+\(diff.compactCurrencyString)" : diff.compactCurrencyString) + .font(.caption.weight(.semibold)) + .foregroundColor(diff >= 0 ? .positiveGreen : .negativeRed) + } + Text(latestSnapshot?.date.relativeDescription ?? String(localized: "date_never")) .font(.caption) .foregroundColor(.secondary)