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
use crate::{Background, BootDisplay, Webpage};
use ramhorns::{Template, Content};
#[derive(Content)]
pub struct DialogOk {
#[md]
text: String,
ok_button: String,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum DialogOption {
Ok,
}
impl DialogOk {
pub fn new<S1, S2>(text: S1, ok_button: S2) -> Self
where S1: Into<String>,
S2: Into<String>,
{
Self {
text: text.into(),
ok_button: ok_button.into(),
}
}
pub fn ok<S: Into<String>>(message: S) -> bool {
match DialogOk::new(message, "OK").show() {
DialogOption::Ok => true,
}
}
pub fn show(&self) -> DialogOption {
let tpl = Template::new(include_str!("templates/dialog_ok.html")).unwrap();
let response = Webpage::new()
.background(Background::BlurredScreenshot)
.file("index.html", &tpl.render(self))
.boot_display(BootDisplay::BlurredScreenshot)
.open()
.unwrap();
DialogOption::Ok
}
}