Skip to content

Feature: Global Notification Handler/Manager #82

@undead2146

Description

@undead2146

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:

  1. Define an interface INotificationService with 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)
  2. Implement a concrete NotificationService that:
    • Maintains an in-memory queue or stack of NotificationViewModel items.
    • Exposes an ObservableCollection<NotificationViewModel> bound to the overlay control.
    • Ensures thread-safe invocation (e.g., dispatch to UI thread).
  3. Create a reusable NotificationOverlay control:
    • Hosts an ItemsControl displaying 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.
  4. Integrate NotificationOverlay into the MainWindow (or root layout):
    • Position configurable (top-right default, support for other corners).
    • Overlay does not block underlying input.
  5. Configuration & Settings:
    • Default durations configurable in appsettings.json or 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).
  6. Theming & Styling:
    • Leverage ResourceDictionaries and DynamicResource to pull colors and icons.
    • Provide default light and dark styles for notifications.
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestGUIFor graphical user interfaceInfrastructureFor cross cutting concerns

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions