Set title based on CLI Mode

This commit is contained in:
2Shirt 2024-12-01 16:49:59 -08:00
parent 6938960f3e
commit 783e31a582
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -21,17 +21,25 @@ use ratatui::{
use tokio::sync::mpsc::UnboundedSender;
use super::Component;
use crate::{action::Action, config::Config};
use crate::{action::Action, cli, config::Config};
#[derive(Default)]
pub struct Title {
command_tx: Option<UnboundedSender<Action>>,
config: Config,
title_text: String,
}
impl Title {
pub fn new() -> Self {
Self::default()
pub fn new(cli_cmd: cli::Command) -> Self {
let title_text = match cli_cmd {
cli::Command::Clone => String::from("Deja-Vu: Clone"),
cli::Command::Diagnose => String::from("Deja-Vu: Diagnostics"),
};
Self {
title_text,
..Default::default()
}
}
}
@ -55,7 +63,7 @@ impl Component for Title {
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
// Title Block
let title_text = Span::styled("WizardKit: Deja-Vu", Style::default().fg(Color::LightCyan));
let title_text = Span::styled(&self.title_text, Style::default().fg(Color::LightCyan));
let title = Paragraph::new(Line::from(title_text).centered())
.block(Block::default().borders(Borders::ALL));
frame.render_widget(title, area);