use crate::app::App; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, text::{Span, Spans}, widgets::{Block, Borders, List, ListItem}, Frame, }; pub fn ui(f: &mut Frame, app: &mut App) { let chunks = Layout::default() .direction(Direction::Vertical) .constraints([Constraint::Percentage(6), Constraint::Percentage(94)].as_ref()) .split(f.size()); // Iterate through all elements in the `items` app and append some debug text to it. let items: Vec = app .items .items .iter() .map(|i| { let mut lines = vec![Spans::from(i.0)]; for _ in 0..i.1 { lines.push(Spans::from(Span::styled( "Just some random garbage", Style::default().add_modifier(Modifier::ITALIC), ))); } ListItem::new(lines).style(Style::default()) }) .collect(); // Create a List from all list items and highlight the currently selected one let items = List::new(items) .block(Block::default().borders(Borders::ALL).title("List")) .highlight_style(Style::default().bg(Color::LightGreen).add_modifier(Modifier::BOLD)) .highlight_symbol(">> "); // Render the item list f.render_stateful_widget(items, chunks[0], &mut app.items.state); }