From aceed608edf2efbde96ba9b36924c5b7128c2f21 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Wed, 11 Feb 2026 23:47:49 +0100 Subject: [PATCH] Show source value difference vs previous check-in (green/red coloring) When a source has been updated this cycle, shows the value change from the previous snapshot in green (increase) or red (decrease). Fixes #21 Co-Authored-By: Claude Opus 4.6 --- .../Views/Dashboard/MonthlyCheckInView.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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)