1mod builder;
2
3use crossterm::event::KeyCode;
4use builder::{tools, components::{Page, Line::*}};
5
6pub use builder::components;
7
8pub struct Application<'a> {
9 home: Option<Page<'a>>
10}
11impl<'a> Application<'a> {
12 pub fn new() -> Application<'a> {
13 tools::clear_terminal();
14 Application { home: None }
15 }
16 pub fn hello_builder(&self) {
17 let mut page = Page::new(37, None);
18 page.title("Hello builder");
19 page.content(vec![
20 Str("Welcome to Interface Builder")
21 ]);
22 page.footer(vec![
23 Str("Press ESC to exit...")
24 ]);
25 page.print();
26
27 tools::await_key_code(KeyCode::Esc);
28
29 tools::clear_terminal();
30 }
31 pub fn set_home(&mut self, home: Page<'a>) {
32 self.home = Some(home);
33 }
34 pub fn run(&mut self) {
35 match &mut self.home {
36 Some(home) => {
37 home.print();
38 tools::await_key_code(KeyCode::Esc);
39 tools::clear_terminal();
40 },
41 None => panic!(
42 "home is not implemented, use \"application.home(Page)\" before \"application.run()\""
43 )
44 }
45 }
46}