cloudflare_dns/ui/components/
app_layout.rs1use crate::ui::colors::*;
2use crate::ui::components::status_bar::StatusBar;
3use iocraft::prelude::*;
4
5#[allow(dead_code)]
6pub struct AppLayoutConfig {
7 pub border_color: Color,
8 pub title: String,
9 pub title_bg: Color,
10 pub title_color: Color,
11 pub menu: String,
12 pub menu_bg: Color,
13 pub menu_color: Color,
14 pub status: String,
15}
16
17impl Default for AppLayoutConfig {
18 fn default() -> Self {
19 Self {
20 border_color: BLUE,
21 title: " ☁ Cloudflare DNS ".to_string(),
22 title_bg: BLUE,
23 title_color: CRUST,
24 menu: String::new(),
25 menu_bg: SURFACE0,
26 menu_color: SUBTEXT1,
27 status: String::new(),
28 }
29 }
30}
31
32pub fn render_app_layout<'a>(
33 config: AppLayoutConfig,
34 content: AnyElement<'a>,
35 hooks: &mut Hooks,
36) -> AnyElement<'a> {
37 let (width, height) = hooks.use_terminal_size();
38
39 element! {
40 View(width: width, height: height, background_color: CRUST, flex_direction: FlexDirection::Column) {
41 View(background_color: config.title_bg, padding_left: 2, padding_right: 2, padding_top: 1, padding_bottom: 1) {
42 Text(content: config.title, color: config.title_color, weight: Weight::Bold)
43 }
44 View(background_color: config.menu_bg, padding_left: 2, padding_right: 2, padding_top: 1, padding_bottom: 1) {
45 Text(content: config.menu, color: config.menu_color)
46 }
47 #(content)
48 StatusBar(message: config.status)
49 }
50 }.into_any()
51}