Skip to content

NotificationStack

Namespace: Hex1b

Assembly: Hex1b.dll

Manages a collection of notifications with floating/docked state tracking and timeout handling.

csharp
public sealed class NotificationStack

Inheritance

ObjectNotificationStack

Properties

All

Gets all active notifications in the stack (both floating and docked). Newest notifications are first.

Returns: IReadOnlyList<Notification>

csharp
public IReadOnlyList<Notification> All { get; }

Count

Gets the count of all notifications.

Returns: Int32

csharp
public int Count { get; }

Floating

Gets notifications that are currently floating (visible as overlays). Newest notifications are first.

Returns: IReadOnlyList<Notification>

csharp
public IReadOnlyList<Notification> Floating { get; }

FloatingCount

Gets the count of floating notifications.

Returns: Int32

csharp
public int FloatingCount { get; }

IsPanelVisible

Whether the notification panel/drawer is visible.

Returns: Boolean

csharp
public bool IsPanelVisible { get; set; }

Methods

CancelTimeout(Notification)

Cancels the timeout for a specific notification. The notification will remain visible until explicitly dismissed.

Parameters:

  • notification (Notification): The notification to cancel the timeout for.
csharp
public void CancelTimeout(Notification notification)

Dismiss(Notification)

Dismisses a notification, removing it from the stack entirely.

Parameters:

Returns: Boolean

True if the notification was found and removed.

csharp
public bool Dismiss(Notification notification)

DismissAll()

Dismisses all notifications from the stack.

csharp
public void DismissAll()

HideFromFloating(Notification)

Hides a notification from floating view without dismissing it. The notification remains in the panel.

Parameters:

csharp
public void HideFromFloating(Notification notification)

HidePanel()

Hides the notification panel/drawer.

csharp
public void HidePanel()

IsFloating(Notification)

Checks if a notification is currently floating.

Parameters:

Returns: Boolean

True if the notification is floating.

csharp
public bool IsFloating(Notification notification)

Post(Notification)

Posts a new notification to the stack. The notification will appear as a floating overlay.

Parameters:

csharp
public void Post(Notification notification)

ShowPanel()

Shows the notification panel/drawer. When the panel opens, all currently floating notifications are hidden from the floating view (they remain visible in the drawer). This signals that the user has seen them.

csharp
public void ShowPanel()

TogglePanel()

Toggles the notification panel/drawer visibility. When opening, all currently floating notifications are hidden from the floating view (they remain visible in the drawer).

csharp
public void TogglePanel()

Events

Changed

Event raised when the notification collection changes.

Returns: Action

csharp
public event Action? Changed

Remarks

The notification stack is the central manager for all notifications in an application. It tracks: All active notificationsWhich notifications are currently "floating" (visible as overlays)Timeout timers for auto-hiding from floating viewPanel/drawer visibility state

Notification lifecycle: Floating: Visible as overlay card, countdown timer running.Docked: Timed out or drawer opened - no longer floating but still in panel.Dismissed: Removed from the stack entirely.

Access the notification stack from event handlers via e.Context.Notifications or through the property.

Examples

Posting a notification from a button click:

csharp
ctx.Button("Save").OnClick(e => {
    SaveFile();
    e.Context.Notifications.Post(
        new Notification("File Saved", "document.txt saved successfully")
            .Timeout(TimeSpan.FromSeconds(5))
            .PrimaryAction("Open Folder", async ctx => OpenFolder())
    );
});

Released under the MIT License.