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 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-02-11 23:45:16 +01:00
parent d71e98c60c
commit 8fa66c1c70
@@ -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 {