WIP: Add UI to application #1

Draft
benjamyn wants to merge 16 commits from UI into master
3 changed files with 20 additions and 6 deletions
Showing only changes of commit 618779102b - Show all commits

View File

@ -25,6 +25,7 @@ pub struct App {
pub current_state: CurrentState,
pub menu_state: MenuState,
pub config: Config,
pub state: ListState,
}
impl App {
@ -37,6 +38,7 @@ impl App {
current_state: CurrentState::Lookup,
menu_state: MenuState::Main,
config: Config::from_file("test.ini".to_string()),
state: ListState::default(),
}
}
}

View File

@ -50,14 +50,15 @@ impl DomainData {
// println!("{}", output);
}
pub fn list_lookups(config: &Config) -> Vec<ListItem> {
let mut items: Vec<ListItem> = vec![];
pub fn list_lookups(config: &Config) -> Vec<String> {
let mut items: Vec<String> = vec![];
for item in fs::read_dir(format!("{}/lookups", config.data_dir)).unwrap() {
let item_name = item.unwrap();
items.push(ListItem::new(Line::from(Span::styled(
String::from(item_name.path().to_string_lossy().clone()),
Style::default(),
))));
// items.push(ListItem::new(Line::from(Span::styled(
// String::from(item_name.path().to_string_lossy().clone()),
// Style::default(),
// ))));
items.push(String::from(item_name.path().to_string_lossy().clone()))
}
return items;

View File

@ -336,6 +336,17 @@ pub fn ui(f: &mut Frame, app: &mut App) {
.repeat_highlight_symbol(true);
// 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 = Paragraph::new(Text::styled(