mirror of
https://github.com/apognu/tuigreet.git
synced 2024-11-25 20:32:09 +03:00
Refactored some code.
This commit is contained in:
parent
0c4c127bae
commit
a07fdeca67
@ -52,17 +52,12 @@ pub fn draw(
|
||||
f.render_widget(time, chunks[0]);
|
||||
}
|
||||
|
||||
let command = greeter.command.clone().unwrap_or("-".to_string());
|
||||
let status_text = [
|
||||
Text::styled(
|
||||
format!("ESC"),
|
||||
Style::default().modifier(Modifier::REVERSED),
|
||||
),
|
||||
Text::raw(format!(" {} ", EXIT)),
|
||||
Text::styled(COMMAND, Style::default().modifier(Modifier::REVERSED)),
|
||||
Text::raw(format!(
|
||||
" {} ",
|
||||
greeter.command.clone().unwrap_or("-".to_string())
|
||||
)),
|
||||
status_label("ESC"),
|
||||
status_value(format!(" {} ", EXIT)),
|
||||
status_label(COMMAND),
|
||||
status_value(format!(" {} ", command)),
|
||||
];
|
||||
let status = Paragraph::new(status_text.iter());
|
||||
|
||||
@ -83,3 +78,17 @@ pub fn draw(
|
||||
fn get_time() -> String {
|
||||
Local::now().format("%b, %d %h %Y - %H:%M").to_string()
|
||||
}
|
||||
|
||||
fn status_label<'s, S>(text: S) -> Text<'s>
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Text::styled(text.into(), Style::default().modifier(Modifier::REVERSED))
|
||||
}
|
||||
|
||||
fn status_value<'s, S>(text: S) -> Text<'s>
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Text::raw(text.into())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user