55 lines
1.7 KiB
Rust
55 lines
1.7 KiB
Rust
//! Status bar widget.
|
|
|
|
use ratatui::layout::Rect;
|
|
use ratatui::style::{Color, Style};
|
|
use ratatui::text::{Line, Span};
|
|
use ratatui::widgets::Paragraph;
|
|
use ratatui::Frame;
|
|
|
|
use crate::media::MediaState;
|
|
use super::InputMode;
|
|
|
|
pub fn render(
|
|
frame: &mut Frame,
|
|
area: Rect,
|
|
media: &MediaState,
|
|
our_name: &str,
|
|
our_id_short: &str,
|
|
connected: bool,
|
|
input_mode: &InputMode,
|
|
) {
|
|
let conn_status = if connected {
|
|
Span::styled("● Connected", Style::default().fg(Color::Green))
|
|
} else {
|
|
Span::styled("○ Waiting for peers", Style::default().fg(Color::Yellow))
|
|
};
|
|
|
|
let mode_span = match input_mode {
|
|
InputMode::Normal => Span::styled(" NORMAL ", Style::default().fg(Color::Black).bg(Color::Blue)),
|
|
InputMode::Editing => Span::styled(" INSERT ", Style::default().fg(Color::Black).bg(Color::Green)),
|
|
InputMode::FilePrompt => Span::styled(" FILE ", Style::default().fg(Color::Black).bg(Color::Yellow)),
|
|
InputMode::MicSelect => Span::styled(" MIC ", Style::default().fg(Color::Black).bg(Color::Magenta)),
|
|
InputMode::SpeakerSelect => Span::styled(" SPKR ", Style::default().fg(Color::Black).bg(Color::Cyan)),
|
|
};
|
|
|
|
let line = Line::from(vec![
|
|
Span::raw(" "),
|
|
mode_span,
|
|
Span::raw(" "),
|
|
conn_status,
|
|
Span::styled(
|
|
format!(" │ {} ({})", our_name, our_id_short),
|
|
Style::default().fg(Color::Cyan),
|
|
),
|
|
Span::styled(
|
|
format!(" │ {}", media.status_line()),
|
|
Style::default().fg(Color::DarkGray),
|
|
),
|
|
]);
|
|
|
|
let paragraph = Paragraph::new(line)
|
|
.style(Style::default().bg(Color::Rgb(30, 30, 40)));
|
|
|
|
frame.render_widget(paragraph, area);
|
|
}
|