[feat] add keys description

This commit is contained in:
jay 2022-02-14 17:44:06 +08:00
parent fa3a2e60cd
commit 61c9fc623d

View File

@ -70,11 +70,13 @@ impl<T> StatefulList<T> {
}
}
#[derive(PartialEq)]
enum PageState {
Images,
Tags,
}
#[derive(PartialEq)]
enum LoadingState {
Init,
Loading,
@ -356,6 +358,46 @@ fn show_info<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {
let paragraph = Paragraph::new(texts).block(Block::default().borders(Borders::NONE));
f.render_widget(paragraph, chunks[0]);
{
// show keys
let chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Percentage(30),
Constraint::Percentage(30),
Constraint::Percentage(20),
]
.as_ref(),
)
.split(chunks[1]);
let mut global_keys = vec![Spans::from(vec![
Span::styled("q", Style::default().fg(Color::Yellow)),
Span::raw(" quit"),
])];
let mut tags_keys: Vec<Spans> = vec![];
if app.page_state == PageState::Tags {
global_keys.push(Spans::from(vec![
Span::styled("esc", Style::default().fg(Color::Yellow)),
Span::raw(" back to images"),
]));
tags_keys.push(Spans::from(vec![
Span::styled("c", Style::default().fg(Color::Yellow)),
Span::raw(" copy docker image uri"),
]));
}
let paragraph = Paragraph::new(global_keys).block(Block::default().borders(Borders::NONE));
f.render_widget(paragraph, chunks[0]);
let paragraph = Paragraph::new(tags_keys).block(Block::default().borders(Borders::NONE));
f.render_widget(paragraph, chunks[1]);
}
}
fn page_images<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {