From 8fa66c1c70b928ff8f51073ddbb875c3a7d09d28 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Wed, 11 Feb 2026 23:45:16 +0100 Subject: [PATCH] Add dismissible pending updates alert banner at top of Dashboard Shows a warning-colored banner when sources need updating, with an X to dismiss. The existing Pending Updates section lower in the dashboard remains unchanged. Fixes #18 Co-Authored-By: Claude Opus 4.6 --- .../Views/Dashboard/DashboardView.swift | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/PortfolioJournal/Views/Dashboard/DashboardView.swift b/PortfolioJournal/Views/Dashboard/DashboardView.swift index 5423add..f783e7f 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 + @State private var pendingAlertDismissed = false init() { _viewModel = StateObject(wrappedValue: DashboardViewModel()) @@ -24,6 +25,18 @@ struct DashboardView: View { ScrollView { VStack(spacing: 20) { if viewModel.hasData { + if !pendingAlertDismissed && !viewModel.sourcesNeedingUpdate.isEmpty { + PendingUpdatesAlertBanner( + count: viewModel.sourcesNeedingUpdate.count, + onDismiss: { + withAnimation { + pendingAlertDismissed = true + } + } + ) + .transition(.move(edge: .top).combined(with: .opacity)) + } + ForEach(visibleSections) { config in sectionView(for: config) } @@ -1046,6 +1059,36 @@ struct EmptyDashboardView: View { } } +// MARK: - Pending Updates Alert Banner + +struct PendingUpdatesAlertBanner: View { + let count: Int + let onDismiss: () -> Void + + var body: some View { + HStack(spacing: 10) { + Image(systemName: "exclamationmark.triangle.fill") + .foregroundColor(.white) + + Text("\(count) source\(count == 1 ? "" : "s") pending update") + .font(.subheadline.weight(.semibold)) + .foregroundColor(.white) + + Spacer() + + Button(action: onDismiss) { + Image(systemName: "xmark") + .font(.caption.weight(.bold)) + .foregroundColor(.white.opacity(0.8)) + } + } + .padding(.horizontal, 16) + .padding(.vertical, 12) + .background(Color.appWarning) + .cornerRadius(AppConstants.UI.cornerRadius) + } +} + // MARK: - Pending Updates Card struct PendingUpdatesCard: View {