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 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-02-11 23:56:48 +01:00
parent c99398c350
commit b4615ac558
3 changed files with 8 additions and 3 deletions
@@ -6,6 +6,7 @@ struct ChartsContainerView: View {
@StateObject private var viewModel: ChartsViewModel @StateObject private var viewModel: ChartsViewModel
@StateObject private var goalsViewModel = GoalsViewModel() @StateObject private var goalsViewModel = GoalsViewModel()
@AppStorage("calmModeEnabled") private var calmModeEnabled = true @AppStorage("calmModeEnabled") private var calmModeEnabled = true
@AppStorage("showForecast") private var showForecast = true
init(iapService: IAPService) { init(iapService: IAPService) {
_viewModel = StateObject(wrappedValue: ChartsViewModel(iapService: iapService)) _viewModel = StateObject(wrappedValue: ChartsViewModel(iapService: iapService))
@@ -92,7 +93,7 @@ struct ChartsContainerView: View {
private var chartTypeSelector: some View { private var chartTypeSelector: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 12) { HStack(spacing: 12) {
ForEach(viewModel.availableChartTypes(calmModeEnabled: calmModeEnabled)) { chartType in ForEach(viewModel.availableChartTypes(calmModeEnabled: calmModeEnabled).filter { showForecast || $0 != .prediction }) { chartType in
ChartTypeButton( ChartTypeButton(
chartType: chartType, chartType: chartType,
isSelected: viewModel.selectedChartType == chartType, isSelected: viewModel.selectedChartType == chartType,
@@ -11,6 +11,7 @@ struct DashboardView: View {
@State private var showingCustomize = false @State private var showingCustomize = false
@State private var sectionConfigs = DashboardLayoutStore.load() @State private var sectionConfigs = DashboardLayoutStore.load()
@AppStorage("calmModeEnabled") private var calmModeEnabled = true @AppStorage("calmModeEnabled") private var calmModeEnabled = true
@AppStorage("showForecast") private var showForecast = true
@State private var pendingAlertDismissed = false @State private var pendingAlertDismissed = false
init() { init() {
@@ -165,7 +166,7 @@ struct DashboardView: View {
isPositive: calmModeEnabled isPositive: calmModeEnabled
? viewModel.latestPortfolioChange.absolute >= 0 ? viewModel.latestPortfolioChange.absolute >= 0
: viewModel.isDayChangePositive, : viewModel.isDayChangePositive,
forecast: viewModel.portfolioForecast, forecast: showForecast ? viewModel.portfolioForecast : nil,
isPremium: iapService.isPremium, isPremium: iapService.isPremium,
onUnlockTap: { onUnlockTap: {
viewModel.showingPaywall = true viewModel.showingPaywall = true
@@ -7,6 +7,7 @@ struct SettingsView: View {
@StateObject private var viewModel: SettingsViewModel @StateObject private var viewModel: SettingsViewModel
@EnvironmentObject private var adMobService: AdMobService @EnvironmentObject private var adMobService: AdMobService
@AppStorage("calmModeEnabled") private var calmModeEnabled = true @AppStorage("calmModeEnabled") private var calmModeEnabled = true
@AppStorage("showForecast") private var showForecast = true
@AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false @AppStorage("cloudSyncEnabled") private var cloudSyncEnabled = false
@AppStorage("faceIdEnabled") private var faceIdEnabled = false @AppStorage("faceIdEnabled") private var faceIdEnabled = false
@AppStorage("pinEnabled") private var pinEnabled = false @AppStorage("pinEnabled") private var pinEnabled = false
@@ -568,6 +569,8 @@ struct SettingsView: View {
Section { Section {
Toggle("Calm Mode", isOn: $calmModeEnabled) Toggle("Calm Mode", isOn: $calmModeEnabled)
Toggle("Show Forecast", isOn: $showForecast)
NavigationLink { NavigationLink {
AllocationTargetsView() AllocationTargetsView()
} label: { } label: {
@@ -581,7 +584,7 @@ struct SettingsView: View {
} header: { } header: {
Text("Long-Term Focus") Text("Long-Term Focus")
} footer: { } 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.")
} }
} }