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
36
37
38
39
40
41
42
43
44
45
46
47
|
use iced::{Element, Task};
use iced_dialog::button;
use crate::Message;
use crate::types::{DialogAction, DialogButtons};
pub const UNSAVED_CHANGES_TITLE: &str = "Unsaved changes";
pub const WARNING_TITLE: &str = "Heads up!";
pub const ERROR_TITLE: &str = "Oops! Something went wrong.";
pub fn ok_button<'a>() -> Element<'a, Message> {
button("Ok", Message::DialogOk).into()
}
pub fn cancel_button<'a>() -> Element<'a, Message> {
button("Cancel", Message::DialogCancel).into()
}
pub fn error_dialog(description: impl Into<String>) -> Task<Message> {
Task::done(Message::OpenDialog(
ERROR_TITLE,
description.into(),
DialogButtons::Ok,
DialogAction::None,
))
}
pub fn warning_dialog(description: impl Into<String>) -> Task<Message> {
Task::done(Message::OpenDialog(
WARNING_TITLE,
description.into(),
DialogButtons::Ok,
DialogAction::None,
))
}
pub fn unsaved_changes_dialog(
description: impl Into<String>,
action: DialogAction,
) -> Task<Message> {
Task::done(Message::OpenDialog(
UNSAVED_CHANGES_TITLE,
description.into(),
DialogButtons::OkCancel,
action,
))
}
|