node_launchpad/components/
footer.rs1use crate::style::{COOL_GREY, EUCALYPTUS, GHOST_WHITE, LIGHT_PERIWINKLE};
10use ratatui::{prelude::*, widgets::*};
11
12pub enum NodesToStart {
13 Configured,
14 NotConfigured,
15 Running,
16}
17
18#[derive(Default)]
19pub struct Footer {}
20
21impl StatefulWidget for Footer {
22 type State = NodesToStart;
23
24 fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
25 let (text_style, command_style) = if matches!(state, NodesToStart::Configured) {
26 (
27 Style::default().fg(EUCALYPTUS),
28 Style::default().fg(GHOST_WHITE),
29 )
30 } else {
31 (
32 Style::default().fg(COOL_GREY),
33 Style::default().fg(LIGHT_PERIWINKLE),
34 )
35 };
36
37 let commands = vec![
38 Span::styled("[Ctrl+G] ", Style::default().fg(GHOST_WHITE)),
39 Span::styled("Manage Nodes", Style::default().fg(EUCALYPTUS)),
40 Span::styled(" ", Style::default()),
41 Span::styled("[Ctrl+S] ", command_style),
42 Span::styled("Start Nodes", text_style),
43 Span::styled(" ", Style::default()),
44 Span::styled("[L] ", command_style),
45 Span::styled("Open Logs", Style::default().fg(EUCALYPTUS)),
46 Span::styled(" ", Style::default()),
47 Span::styled("[Ctrl+X] ", command_style),
48 Span::styled(
49 "Stop All",
50 if matches!(state, NodesToStart::Running) {
51 Style::default().fg(EUCALYPTUS)
52 } else {
53 Style::default().fg(COOL_GREY)
54 },
55 ),
56 ];
57
58 let cell1 = Cell::from(Line::from(commands));
59 let row = Row::new(vec![cell1]);
60
61 let table = Table::new(vec![row], vec![Constraint::Max(1)])
62 .block(
63 Block::default()
64 .borders(Borders::ALL)
65 .border_style(Style::default().fg(EUCALYPTUS))
66 .padding(Padding::horizontal(1)),
67 )
68 .widths(vec![Constraint::Fill(1)]);
69
70 StatefulWidget::render(table, area, buf, &mut TableState::default());
71 }
72}