Input inboxes now show statuses on validity of said input

This commit is contained in:
Xithrius 2022-12-19 22:42:03 -08:00
parent e84ecb8dc2
commit ff35eca988
No known key found for this signature in database
GPG Key ID: A867F27CC80B28C1
2 changed files with 13 additions and 7 deletions

View File

@ -61,6 +61,12 @@ pub fn render_insert_box<T: Backend>(
let binding = [TitleStyle::Single(box_title)];
let status_color = if valid_input {
Color::Green
} else {
Color::Red
};
let paragraph = Paragraph::new(Spans::from(vec![
Span::raw(current_input),
Span::styled(
@ -81,13 +87,11 @@ pub fn render_insert_box<T: Backend>(
.borders(Borders::ALL)
.title(title_spans(
&binding,
Style::default().fg(Color::Red).add_modifier(Modifier::BOLD),
Style::default()
.fg(status_color)
.add_modifier(Modifier::BOLD),
))
.border_style(Style::default().fg(if valid_input {
Color::Yellow
} else {
Color::Red
})),
.border_style(Style::default().fg(status_color)),
)
.scroll((
0,

View File

@ -255,12 +255,14 @@ pub fn draw_ui<T: Backend>(frame: &mut Frame<T>, app: &mut App, config: &Complet
// States of the application that require a chunk of the main window
State::Insert => components::render_chat_box(window, config.storage.mentions),
State::MessageSearch => {
let checking_func = |s: String| -> bool { !s.is_empty() };
components::render_insert_box(
window,
format!("Message Search: {total_num_search_results} found").as_str(),
None,
None,
None,
Some(Box::new(checking_func)),
);
}