Skip to content

Commit

Permalink
~ let error message only display 3 secs
Browse files Browse the repository at this point in the history
  • Loading branch information
f91og committed Dec 3, 2023
1 parent 812fd72 commit cbb0925
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,8 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {

let app_add_secret_panel = app.panels.get(&PanelName::AddSecret).unwrap();

if app_add_secret_panel.index == 0 {
render_label_input(f, name_area, "name: ".to_string(), app_add_secret_panel.content[0].clone(), true);
render_label_input(f, value_area, "value: ".to_string(), app_add_secret_panel.content[1].clone(), false);
} else {
render_label_input(f, name_area, "name: ".to_string(), app_add_secret_panel.content[0].clone(), false);
render_label_input(f, value_area, "value: ".to_string(), app_add_secret_panel.content[1].clone(), true);
}
render_label_input(f, name_area, "name: ".to_string(), app_add_secret_panel.content[0].clone(), app_add_secret_panel.index == 0);
render_label_input(f, value_area, "value: ".to_string(), app_add_secret_panel.content[1].clone(), app_add_secret_panel.index == 1);
}
if app.mode == Mode::Delete {
let (current_secret, _) = app.get_selected_secret();
Expand All @@ -106,24 +101,18 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
advance_area.y += 4;

let app_make_secret_panel = app.panels.get(&PanelName::MakeSecret).unwrap();
let (mut name_set_cursor, mut length_set_cursor, mut advance_set_cursor) = (false, false, false);
if app_make_secret_panel.index == 0 {
name_set_cursor = true;
} else if app_make_secret_panel.index == 1 {
length_set_cursor = true;
} else {
advance_set_cursor = true;
}
render_label_input(f, name_area, "name: ".to_string(), app_make_secret_panel.content[0].clone(), name_set_cursor);
render_label_input(f, length_area, "length: ".to_string(), app_make_secret_panel.content[1].clone(), length_set_cursor);
render_label_input(f, advance_area, "advance: ".to_string(), app_make_secret_panel.content[2].clone(), advance_set_cursor);

render_label_input(f, name_area, "name: ".to_string(), app_make_secret_panel.content[0].clone(), app_make_secret_panel.index == 0);
render_label_input(f, length_area, "length: ".to_string(), app_make_secret_panel.content[1].clone(), app_make_secret_panel.index == 1);
render_label_input(f, advance_area, "advance: ".to_string(), app_make_secret_panel.content[2].clone(), app_make_secret_panel.index == 2);
}
let guide_chunk = Paragraph::new(app.guide.to_string()).alignment(Alignment::Center).style(Style::default().fg(Color::Blue));
let error_chunk = Paragraph::new(app.error.to_string()).alignment(Alignment::Center).style(Style::default().fg(Color::Red));
if app.error.is_empty() {
f.render_widget(guide_chunk, chunks[2]);
} else {
f.render_widget(error_chunk, chunks[2]);
app.clear_error_if_expired();
}
}

Expand Down

0 comments on commit cbb0925

Please sign in to comment.