From b4615ac5587722ea153e87d4a21f5cc748422e88 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Wed, 11 Feb 2026 23:56:48 +0100 Subject: [PATCH] Add setting to toggle forecast visibility in charts and dashboard Adds a "Show Forecast" toggle in Settings > Long-Term Focus section. When disabled, hides the forecast from the total portfolio card and removes the prediction chart type from the charts tab. Fixes #26 Co-Authored-By: Claude Opus 4.6 --- PortfolioJournal/Views/Charts/ChartsContainerView.swift | 3 ++- PortfolioJournal/Views/Dashboard/DashboardView.swift | 3 ++- PortfolioJournal/Views/Settings/SettingsView.swift | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PortfolioJournal/Views/Charts/ChartsContainerView.swift b/PortfolioJournal/Views/Charts/ChartsContainerView.swift index 291ecdb..4d86335 100644 --- a/PortfolioJournal/Views/Charts/ChartsContainerView.swift +++ b/PortfolioJournal/Views/Charts/ChartsContainerView.swift @@ -6,6 +6,7 @@ struct ChartsContainerView: View { @StateObject private var viewModel: ChartsViewModel @StateObject private var goalsViewModel = GoalsViewModel() @AppStorage("calmModeEnabled") private var calmModeEnabled = true + @AppStorage("showForecast") private var showForecast = true init(iapService: IAPService) { _viewModel = StateObject(wrappedValue: ChartsViewModel(iapService: iapService)) @@ -92,7 +93,7 @@ struct ChartsContainerView: View { private var chartTypeSelector: some View { ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 12) { - ForEach(viewModel.availableChartTypes(calmModeEnabled: calmModeEnabled)) { chartType in + ForEach(viewModel.availableChartTypes(calmModeEnabled: calmModeEnabled).filter { showForecast || $0 != .prediction }) { chartType in ChartTypeButton( chartType: chartType, isSelected: viewModel.selectedChartType == chartType, diff --git a/PortfolioJournal/Views/Dashboard/DashboardView.swift b/PortfolioJournal/Views/Dashboard/DashboardView.swift index f783e7f..23c91ab 100644 --- a/PortfolioJournal/Views/Dashboard/DashboardView.swift +++ b/PortfolioJournal/Views/Dashboard/DashboardView.swift @@ -11,6 +11,7 @@ struct DashboardView: View { @State private var showingCustomize = false @State private var sectionConfigs = DashboardLayoutStore.load() @AppStorage("calmModeEnabled") private var calmModeEnabled = true + @AppStorage("showForecast") private var showForecast = true @State private var pendingAlertDismissed = false init() { @@ -165,7 +166,7 @@ struct DashboardView: View { isPositive: calmModeEnabled ? viewModel.latestPortfolioChange.absolute >= 0 : viewModel.isDayChangePositive, - forecast: viewModel.portfolioForecast, + forecast: showForecast ? viewModel.portfolioForecast : nil, isPremium: iapService.isPremium, onUnlockTap: { viewModel.showingPaywall = true diff --git a/PortfolioJournal/Views/Settings/SettingsView.swift b/PortfolioJournal/Views/Settings/SettingsView.swift index f9fb318..b8c31f5 100644 --- a/PortfolioJournal/Views/Settings/SettingsView.swift +++ b/PortfolioJournal/Views/Settings/SettingsView.swift @@ -7,6 +7,7 @@ struct SettingsView: View { @StateObject private var viewModel: SettingsViewModel @EnvironmentObject private var adMobService: AdMobService @AppStorage("calmModeEnabled") private var calmModeEnabled = true + @AppStorage("showForecast") private var showForecast = true @AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false @AppStorage("faceIdEnabled") private var faceIdEnabled = false @AppStorage("pinEnabled") private var pinEnabled = false @@ -568,6 +569,8 @@ struct SettingsView: View { Section { Toggle("Calm Mode", isOn: $calmModeEnabled) + Toggle("Show Forecast", isOn: $showForecast) + NavigationLink { AllocationTargetsView() } label: { @@ -581,7 +584,7 @@ struct SettingsView: View { } header: { Text("Long-Term Focus") } footer: { - Text("Calm Mode hides short-term noise and advanced charts, keeping the app focused on monthly check-ins.") + Text("Calm Mode hides short-term noise and advanced charts. Show Forecast controls whether prediction data appears in portfolio and charts.") } }