A lightweight crate to help you to compose beautiful notifications for Windows OS.
This crate aims for 100% coverage of the WinRT Toast api as much as possible.
Thankfully we are quite near that goal due to our unique approach to notification content: widgets
You declare your own style, however you like as long as the XML Supports it.
use std::{path::absolute, thread::sleep, time::Duration};
use win32_notif::{
NotificationBuilder, NotificationDataSet, notification::visual::{Image, Placement, Text, image::{AdaptiveImageAlign, ImageCrop}, text::HintStyle}, notifier::ToastsNotifier
};
fn main() {
let notifier = ToastsNotifier::new("Microsoft.Windows.Explorer").unwrap();
let notif = NotificationBuilder::new()
.visual(
Text::create(0, "Welcome to \"win32_notif\"!! 👋")
.align_center(true)
.wrap(true)
.with_style(HintStyle::Title)
)
.visual(
Text::create_binded(1, "desc")
.align_center(true)
.wrap(true)
.with_style(HintStyle::Body)
)
.value("desc", "Data binding works as well {WOW}!")
.build(0, ¬ifier, "01", "readme")
.unwrap();
notif.show()
.unwrap();
sleep(Duration::from_secs(1));
let data = NotificationDataSet::new().unwrap();
data.insert("desc", "Hello, the message is edited").unwrap();
notifier.update(&data, "readme", "01").unwrap();
}We've actually implemented a lot of the Notification APIs
- Text
- Image
- Progressbar
- Groups
- Subgroups
- Foreground OnActivated
- Foreground OnError
- Foregrounf OnDismissed
- Notification Updating
- Data Binding (so that you can update notification content)
- Notification Duration
- Scenarios
- Command
- Actions
- Inputs
- Selections
- Visual
- Idiomatic Rust Builder Style (with_... methods)
and a lot of other things... 🎉
- COM Activator
- Background Activation Handling
...and that's it