diff --git a/src/tui/app.rs b/src/tui/app.rs index c87f49d..12ad08f 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -21,7 +21,9 @@ pub fn run(root_config: &mut RootConfig) -> anyhow::Result<()> { #[derive(Debug)] struct App<'a> { root_config: &'a mut RootConfig, + exit: bool, + active_modal: bool, mod_list_state: TableState, selected_instance: Option, @@ -37,6 +39,7 @@ impl<'a> App<'a> { mod_list_state: state, selected_instance: None, exit: false, + active_modal: false, } } @@ -155,16 +158,7 @@ impl<'a> Widget for &mut App<'a> { InstanceSelect::new(self.selected_instance.clone()).render(chunks[0], buf); - let list_block = Block::default() - .title("Mod list") - .borders(Borders::ALL) - .style(Style::default()); - - ModList::new(self.root_config).block(list_block).render( - chunks[1], - buf, - &mut self.mod_list_state, - ); + ModList::new(self.root_config).render(chunks[1], buf, &mut self.mod_list_state); StatusBar.render(chunks[2], buf); } diff --git a/src/tui/mod_list.rs b/src/tui/mod_list.rs index 2ab7e5b..ac720c7 100644 --- a/src/tui/mod_list.rs +++ b/src/tui/mod_list.rs @@ -2,7 +2,7 @@ use ratatui::{ buffer::Buffer, layout::{Constraint, Rect}, style::{Color, Modifier, Style}, - widgets::{Block, Cell, Row, StatefulWidget, Table, TableState}, + widgets::{Block, Borders, Cell, Row, StatefulWidget, Table, TableState}, }; use crate::types::{ModConfig, RootConfig}; @@ -16,7 +16,6 @@ pub struct ListItem<'a> { #[derive(Debug)] pub struct ModList<'a> { items: Vec>, - block: Option>, } impl<'a> ModList<'a> { @@ -31,12 +30,7 @@ impl<'a> ModList<'a> { .collect(); items.sort_by_key(|item| item.id); - Self { items, block: None } - } - - pub fn block(mut self, block: Block<'a>) -> Self { - self.block = Some(block); - self + Self { items } } } @@ -44,6 +38,11 @@ impl<'a> StatefulWidget for ModList<'a> { type State = TableState; fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { + let block = Block::default() + .title("Mod list") + .borders(Borders::ALL) + .style(Style::default()); + let rows: Vec = self .items .iter() @@ -62,13 +61,9 @@ impl<'a> StatefulWidget for ModList<'a> { .bg(Color::DarkGray) .add_modifier(Modifier::BOLD), ) + .block(block) .highlight_symbol(">> "); - let table = match self.block { - Some(b) => table.block(b), - None => table, - }; - StatefulWidget::render(table, area, buf, state); } }