downloading/
downloading.rs1use std::{thread::sleep, time::Duration};
2
3use win32_notif::{
4 NotificationBuilder, NotificationDataSet, ToastsNotifier, notification::{
5 AdaptiveText, Scenario, visual::{
6 Progress, Text, progress::ProgressValue
7 }
8 }
9};
10
11pub fn main() {
12 let notifier = ToastsNotifier::new("Microsoft.Windows.Explorer").unwrap();
13
14 let notification = NotificationBuilder::new()
15 .with_scenario(Scenario::IncomingCall)
16 .with_use_button_style(true)
17 .visual(
18 Text::create_binded(1, "status")
19 )
20 .visual(
21 Progress::create(AdaptiveText::BindTo("typeof"), ProgressValue::BindTo("value"))
22 )
23 .value("status", "AHQ Store")
24 .value("typeof", "Downloading...")
25 .value("value", "indeterminate")
26 .build(1, ¬ifier, "a", "ahq")
27 .expect("Error");
28
29 notification.show().expect("Not Sent");
30
31 let data = NotificationDataSet::new().unwrap();
32 for perc in 1..=100 {
33 data.insert("value", format!("{}", perc as f32 / 100.0).as_str()).unwrap();
34
35 _ = notifier.update(&data, "ahq", "a");
36
37 sleep(Duration::from_millis(100));
38 }
39}