1use std::{path::absolute, thread::sleep, time::Duration};
2
3use win32_notif::{
4 NotificationBuilder, NotificationDataSet, notification::visual::{Image, Placement, Text, image::{AdaptiveImageAlign, ImageCrop}, text::HintStyle}, notifier::ToastsNotifier
5};
6
7fn main() {
8 let path = absolute("./examples/ahq.png").unwrap();
9 let path = path.to_string_lossy();
10
11 let notifier = ToastsNotifier::new("Microsoft.Windows.Explorer").unwrap();
12
13 let notif = NotificationBuilder::new()
14 .visual(
15 Text::create(0, "Welcome to \"win32_notif\"!! 👋")
16 .with_align_center(true)
17 .with_wrap(true)
18 .with_style(HintStyle::Title)
19 )
20 .visual(
21 Text::create_binded(1, "desc")
22 .with_align_center(true)
23 .with_wrap(true)
24 .with_style(HintStyle::Body)
25 )
26 .visual(
27 Image::create(2, format!("file:///{path}").as_str())
28 .with_align(AdaptiveImageAlign::Default)
29 .with_alt("AHQ Logo")
30 .with_crop(ImageCrop::Circle)
31 .with_placement(Placement::AppLogoOverride)
32 )
33 .value("desc", "Data binding works as well {WOW}!")
34 .build(0, ¬ifier, "01", "readme")
35 .unwrap();
36
37 notif.show()
38 .unwrap();
39
40 sleep(Duration::from_secs(1));
41
42 let data = NotificationDataSet::new().unwrap();
43
44 data.insert("desc", "Hello, the message is edited").unwrap();
45
46 notifier.update(&data, "readme", "01").unwrap();
47}