Skip to main content

alerts/
alerts.rs

1#[path = "support/mod.rs"]
2mod support;
3
4use embedded_graphics::{
5    pixelcolor::Rgb565,
6    prelude::{Point, RgbColor, Size},
7    primitives::Rectangle,
8};
9use faststep::{AlertHost, AlertSpec, AlertView, Localized, ModalHost, TouchEvent, TouchPhase};
10
11fn main() {
12    let bounds = Rectangle::new(Point::zero(), Size::new(320, 240));
13    let theme = support::theme();
14    let i18n = support::i18n();
15    let mut canvas = support::NullCanvas::new(bounds.size);
16
17    let spec = AlertSpec::confirm(
18        Localized::new("alert.title", "Delete item?"),
19        Localized::new("alert.message", "This action cannot be undone."),
20    );
21    let mut alert = AlertView::new(spec);
22    let panel = alert.panel(bounds, &theme, &i18n);
23    alert.draw(&mut canvas, panel, &theme, &i18n);
24    let _ = alert.handle_touch(TouchEvent::new(panel.center(), TouchPhase::Start, 1), panel);
25
26    let mut host = AlertHost::<u8, 2>::new();
27    let _ = host.present(7, spec);
28    let _ = host.layer(bounds, &theme, &i18n);
29    host.draw(&mut canvas, bounds, &theme, &i18n);
30    let _ = host.handle_touch(
31        TouchEvent::new(Point::new(160, 160), TouchPhase::End, 2),
32        bounds,
33        &theme,
34        &i18n,
35    );
36
37    let mut modal = ModalHost::new();
38    modal.show(3_u8);
39    let _ = modal.current(bounds, &theme);
40    let _ = Rgb565::BLACK;
41}