Skip to content

Commit

Permalink
Add key
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Dec 22, 2023
1 parent 53a45d2 commit 9895586
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/app/dashboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ where
},
_ => {},
},
KeyCode::Right =>
if dash_board.selected_tab == 2 {
dash_board.selected_pallet_info_tab =
(dash_board.selected_pallet_info_tab + 1) % dash_board.pallet_info_titles.len();
},
KeyCode::Left =>
if dash_board.selected_tab == 2 && dash_board.selected_pallet_info_tab > 0 {
dash_board.selected_pallet_info_tab = dash_board.selected_pallet_info_tab - 1;
},
_ => {},
}
}
Expand Down
56 changes: 54 additions & 2 deletions src/app/dashboard/tab_pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ fn render_pallet_list<CI: ChainInfo>(f: &mut Frame, app: &mut DashBoard<CI>, are
let l = List::new(pallets)
.block(
Block::default()
.title(" Pallets ")
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
Expand Down Expand Up @@ -58,8 +57,61 @@ fn render_pallet_info<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<C
.border_type(BorderType::Double)
.borders(Borders::ALL),
)
.select(dash_board.selected_tab)
.select(dash_board.selected_pallet_info_tab)
.style(Style::default().fg(Color::Yellow))
.highlight_style(Style::default().fg(Color::Cyan));
f.render_widget(tabs, chunks[0]);

match dash_board.selected_pallet_info_tab {
0 => render_pallet_events_page(f, dash_board, chunks[1]),
1 => render_pallet_errors_page(f, dash_board, chunks[1]),
2 => render_pallet_storages_page(f, dash_board, chunks[1]),
3 => render_pallet_calls_page(f, dash_board, chunks[1]),
_ => {},
};
}

fn render_pallet_events_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<CI>, area: Rect) {
let block_style = Block::default()
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
.style(Style::default().fg(Color::Yellow));

let text = "Events Page".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
}
fn render_pallet_errors_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<CI>, area: Rect) {
let block_style = Block::default()
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
.style(Style::default().fg(Color::Yellow));

let text = "Errors Page".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
}
fn render_pallet_storages_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<CI>, area: Rect) {
let block_style = Block::default()
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
.style(Style::default().fg(Color::Yellow));

let text = "Storages Page".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
}
fn render_pallet_calls_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<CI>, area: Rect) {
let block_style = Block::default()
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
.style(Style::default().fg(Color::Yellow));

let text = "Calls Page".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
}

0 comments on commit 9895586

Please sign in to comment.