Module notification

Module notification 

Source
Expand description

Notification view component for displaying temporary or persistent messages.

§Examples

§Auto-dismissing notification

use cadmus_core::view::notification::Notification;
use cadmus_core::view::{Event, NotificationEvent};

let (tx, rx) = std::sync::mpsc::channel();
// Send via event for standard notifications
tx.send(Event::Notification(NotificationEvent::Show("File saved successfully.".to_string()))).ok();

§Pinned notification with progress bar

use cadmus_core::view::{Event, NotificationEvent, ViewId, ID_FEEDER};
let (tx, rx) = std::sync::mpsc::channel();
// Create a pinned notification with a custom ID
let download_id = ViewId::MessageNotif(ID_FEEDER.next());
tx.send(Event::Notification(NotificationEvent::ShowPinned(download_id, "Download: 0%".to_string()))).ok();

// Update the notification text as progress changes
tx.send(Event::Notification(NotificationEvent::UpdateText(
    download_id,
    "Download: 50%".to_string()
))).ok();

// Update the progress bar (0-100)
tx.send(Event::Notification(NotificationEvent::UpdateProgress(download_id, 50))).ok();

// Dismiss when done
tx.send(Event::Close(download_id)).ok();

Structs§

Notification
A notification view that displays temporary or persistent messages.

Enums§

NotificationEvent
Events related to notifications.

Constants§

NOTIFICATION_CLOSE_DELAY 🔒