Replaced all list uses with the SelectableList widget and popup widget. Simplified more popups to use the widgets

This commit is contained in:
2024-02-13 16:16:31 -07:00
parent 649f4b5e3b
commit 4b734811f4
7 changed files with 221 additions and 141 deletions
+40
View File
@@ -2,6 +2,7 @@
mod tests {
use crate::ui::widgets::popup::Popup;
use pretty_assertions::assert_eq;
use ratatui::layout::Alignment;
use ratatui::widgets::Block;
#[test]
@@ -11,5 +12,44 @@ mod tests {
assert_eq!(popup.widget, Block::new());
assert_eq!(popup.percent_x, 50);
assert_eq!(popup.percent_y, 50);
assert_eq!(popup.block, None);
assert_eq!(popup.footer, None);
assert_eq!(popup.footer_alignment, Alignment::Left);
}
#[test]
fn test_popup_block() {
let popup = Popup::new(Block::new(), 50, 50).block(Block::new());
assert_eq!(popup.block, Some(Block::new()));
assert_eq!(popup.widget, Block::new());
assert_eq!(popup.percent_x, 50);
assert_eq!(popup.percent_y, 50);
assert_eq!(popup.footer, None);
assert_eq!(popup.footer_alignment, Alignment::Left);
}
#[test]
fn test_popup_footer() {
let popup = Popup::new(Block::new(), 50, 50).footer("footer");
assert_eq!(popup.footer, Some("footer"));
assert_eq!(popup.widget, Block::new());
assert_eq!(popup.percent_x, 50);
assert_eq!(popup.percent_y, 50);
assert_eq!(popup.block, None);
assert_eq!(popup.footer_alignment, Alignment::Left);
}
#[test]
fn test_popup_footer_alignment() {
let popup = Popup::new(Block::new(), 50, 50).footer_alignment(Alignment::Center);
assert_eq!(popup.footer_alignment, Alignment::Center);
assert_eq!(popup.widget, Block::new());
assert_eq!(popup.percent_x, 50);
assert_eq!(popup.percent_y, 50);
assert_eq!(popup.block, None);
assert_eq!(popup.footer, None);
}
}