summaryrefslogtreecommitdiff
path: root/src/dialogs.rs
blob: 5954ff5b9ec2815032d49a734b8a57ea191382d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use rfd::{
    AsyncMessageDialog, MessageButtons, MessageDialog, MessageDialogResult,
    MessageLevel,
};

pub async fn error_dialog(description: impl Into<String>) {
    let _ = AsyncMessageDialog::new()
        .set_level(MessageLevel::Error)
        .set_buttons(MessageButtons::Ok)
        .set_title("Oops! Something went wrong.")
        .set_description(description)
        .show()
        .await;
}

pub async fn warning_dialog(description: impl Into<String>) {
    let _ = AsyncMessageDialog::new()
        .set_level(MessageLevel::Warning)
        .set_buttons(MessageButtons::Ok)
        .set_title("Heads up!")
        .set_description(description)
        .show()
        .await;
}

pub fn unsaved_changes_dialog(description: impl Into<String>) -> bool {
    let result = MessageDialog::new()
        .set_level(MessageLevel::Warning)
        .set_buttons(MessageButtons::OkCancel)
        .set_title("Unsaved changes")
        .set_description(description)
        .show();

    matches!(result, MessageDialogResult::Ok)
}