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 {