-
Notifications
You must be signed in to change notification settings - Fork 17
Description
User Story:
As a GenHub user, I want a non-modal, consistent overlay for informational, success, warning, and error messages that appears on top of the current window, so I can receive real-time feedback without interrupting my workflow.
Description:
Implement a centralized Notification Manager and a corresponding overlay control that can be invoked from anywhere in the app (ViewModels, services, commands). Notifications should slide or fade in as toasts in a configurable corner of the window, stack or queue cleanly, support optional action buttons, and automatically disappear after a severity-based timeout. The manager must be theme-aware, support dynamic timeout settings, and expose a simple API for raising messages.
Sub-tasks / Checklist:
- Define an interface
INotificationServicewith methods:
•ShowInfo(string title, string message, TimeSpan? duration = null)
•ShowSuccess(string title, string message, TimeSpan? duration = null)
•ShowWarning(string title, string message, TimeSpan? duration = null)
•ShowError(string title, string message, TimeSpan? duration = null)
•ShowWithAction(string title, string message, string actionText, Action onAction, TimeSpan? duration = null) - Implement a concrete
NotificationServicethat:
• Maintains an in-memory queue or stack ofNotificationViewModelitems.
• Exposes anObservableCollection<NotificationViewModel>bound to the overlay control.
• Ensures thread-safe invocation (e.g., dispatch to UI thread). - Create a reusable
NotificationOverlaycontrol:
• Hosts anItemsControldisplaying active notifications.
• Animates entries/exits (slide/fade).
• Styles for four severities, pulling brushes and icons from the current theme.
• Shows title, message, optional action button, and close (“×”) button. - Integrate
NotificationOverlayinto the MainWindow (or root layout):
• Position configurable (top-right default, support for other corners).
• Overlay does not block underlying input. - Configuration & Settings:
• Default durations configurable inappsettings.jsonor via Settings UI:
– Info/Success: default 3s
– Warning: default 5s
– Error: manual dismiss only (duration = 0)
• User can choose stacking (multiple simultaneous) vs. queueing (one at a time). - Theming & Styling:
• Leverage ResourceDictionaries and DynamicResource to pull colors and icons.
• Provide default light and dark styles for notifications. - Testing & Documentation:
• Unit tests for service API: queue order, timeout behavior, manual close, action invocation.
• Integration test or manual verification of overlay on multiple windows.
• Document API in code comments and update README with usage examples.
Acceptance Criteria:
• A developer can inject INotificationService into any ViewModel or service and call one of its methods to display a toast.
• Notifications appear immediately in the configured corner, styled by severity, with correct icon and colors.
• Multiple notifications stack neatly up to a configurable MaxItems; older toasts queue or dismiss based on settings.
• Clicking the close icon or action button behaves correctly: closes the toast and executes the action callback if provided.
• Timeouts auto-dismiss toasts after their duration; error toasts remain until manually closed.
• All layout and animations are smooth; overlay does not block or shift underlying controls.
• Settings UI allows the user to change default durations and stacking behavior at runtime, with changes applying instantly.
• Comprehensive unit tests cover: raising notifications on background threads, honoring durations, queuing logic, manual closes, and action callbacks.
• Documentation in the Developer Guide demonstrates how to raise a notification with and without an action.
Technical Notes:
• Use MVVM pattern: NotificationOverlay bound to a Notifications collection exposed by a singleton NotificationService.
• Use Dispatcher.UIThread.Post (Avalonia) or Application.Current.Dispatcher.Invoke (WPF) for thread marshalling.
• Animations can be achieved via Avalonia’s Transitions or WPF’s Storyboards.
• For per-profile notifications (e.g., “Map added to Profile X”), include optional context tags so the UI can filter or highlight messages relevant to the current view.