List testing
This commit is contained in:
parent
39a2590be8
commit
618779102b
@ -25,6 +25,7 @@ pub struct App {
|
|||||||
pub current_state: CurrentState,
|
pub current_state: CurrentState,
|
||||||
pub menu_state: MenuState,
|
pub menu_state: MenuState,
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
|
pub state: ListState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
@ -37,6 +38,7 @@ impl App {
|
|||||||
current_state: CurrentState::Lookup,
|
current_state: CurrentState::Lookup,
|
||||||
menu_state: MenuState::Main,
|
menu_state: MenuState::Main,
|
||||||
config: Config::from_file("test.ini".to_string()),
|
config: Config::from_file("test.ini".to_string()),
|
||||||
|
state: ListState::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,14 +50,15 @@ impl DomainData {
|
|||||||
// println!("{}", output);
|
// println!("{}", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_lookups(config: &Config) -> Vec<ListItem> {
|
pub fn list_lookups(config: &Config) -> Vec<String> {
|
||||||
let mut items: Vec<ListItem> = vec![];
|
let mut items: Vec<String> = vec![];
|
||||||
for item in fs::read_dir(format!("{}/lookups", config.data_dir)).unwrap() {
|
for item in fs::read_dir(format!("{}/lookups", config.data_dir)).unwrap() {
|
||||||
let item_name = item.unwrap();
|
let item_name = item.unwrap();
|
||||||
items.push(ListItem::new(Line::from(Span::styled(
|
// items.push(ListItem::new(Line::from(Span::styled(
|
||||||
String::from(item_name.path().to_string_lossy().clone()),
|
// String::from(item_name.path().to_string_lossy().clone()),
|
||||||
Style::default(),
|
// Style::default(),
|
||||||
))));
|
// ))));
|
||||||
|
items.push(String::from(item_name.path().to_string_lossy().clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
|||||||
11
src/ui.rs
11
src/ui.rs
@ -336,6 +336,17 @@ pub fn ui(f: &mut Frame, app: &mut App) {
|
|||||||
.repeat_highlight_symbol(true);
|
.repeat_highlight_symbol(true);
|
||||||
// f.render_stateful_widget(items, chunks[1], &mut app.state);
|
// f.render_stateful_widget(items, chunks[1], &mut app.state);
|
||||||
|
|
||||||
|
// let t_list = StatefulList::with_items(item_list);
|
||||||
|
// f.render_stateful_widget(t_list, chunks[1], t_list.state);
|
||||||
|
let items = ["Item 1", "Item 2", "Item 3"];
|
||||||
|
let list = List::new(items)
|
||||||
|
.block(Block::default().title("List").borders(Borders::ALL))
|
||||||
|
.highlight_style(Style::new().add_modifier(Modifier::REVERSED))
|
||||||
|
.highlight_symbol(">>")
|
||||||
|
.repeat_highlight_symbol(true);
|
||||||
|
|
||||||
|
f.render_stateful_widget(list, chunks[1], &mut app.state);
|
||||||
|
|
||||||
let footer_block = Block::new().borders(Borders::ALL).style(Style::default());
|
let footer_block = Block::new().borders(Borders::ALL).style(Style::default());
|
||||||
|
|
||||||
let footer = Paragraph::new(Text::styled(
|
let footer = Paragraph::new(Text::styled(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user