Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

refactor: replace custom spinner animations with a consistent dot-based loading indicator

Samir Hossains3dbfc246bb1a
diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rs
index 8864ceb..97c66ba 100644
--- a/src/tui/screens/details.rs
+++ b/src/tui/screens/details.rs
@@ -96,12 +96,11 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
let details_json = match &state.selected_details {
Some(d) => d,
None => {
- let spinner = if state.basic_terminal {
- let frames = ['-', '\\', '|', '/'];
- frames[(state.tick_count as usize) % frames.len()]
- } else {
- let frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
- frames[(state.tick_count as usize) % frames.len()]
+ let dots = match (state.tick_count / 4) % 4 {
+ 0 => "",
+ 1 => ".",
+ 2 => "..",
+ _ => "...",
};
let vertical_chunks = Layout::default()
@@ -113,7 +112,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
])
.split(area);
- let loading_p = Paragraph::new(format!("{} Loading details...", spinner))
+ let loading_p = Paragraph::new(format!("Loading details{dots}"))
.alignment(ratatui::layout::Alignment::Center)
.style(theme.text_dim);
@@ -268,12 +267,11 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
}
}
} else {
- let current_spinner = if state.basic_terminal {
- let frames = ['-', '\\', '|', '/'];
- frames[(state.tick_count as usize) % frames.len()]
- } else {
- let frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
- frames[(state.tick_count as usize) % frames.len()]
+ let dots = match (state.tick_count / 4) % 4 {
+ 0 => "",
+ 1 => ".",
+ 2 => "..",
+ _ => "...",
};
let placeholder_block = Block::default()
@@ -284,7 +282,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
let (pad, msg) = if state.is_loading {
let p = "\n".repeat((inner.height.saturating_sub(1) / 2) as usize);
- (p, format!("{}\nLoading Art", current_spinner))
+ (p, format!("Loading Art{dots}"))
} else {
let p = "\n".repeat((inner.height.saturating_sub(1) / 2) as usize);
(p, title.to_string())
@@ -972,14 +970,13 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
} else if let Some(error) = &state.stream_error {
format!("{error} — press r to retry.")
} else {
- let spinner = if state.basic_terminal {
- let frames = ['-', '\\', '|', '/'];
- frames[(state.tick_count as usize) % frames.len()]
- } else {
- let frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
- frames[(state.tick_count as usize) % frames.len()]
+ let dots = match (state.tick_count / 4) % 4 {
+ 0 => "",
+ 1 => ".",
+ 2 => "..",
+ _ => "...",
};
- format!("{} Loading streams...", spinner)
+ format!("Loading streams{dots}")
};
let style = if has_error {
diff --git a/src/tui/screens/startup.rs b/src/tui/screens/startup.rs
index 8ac5673..7464e6c 100644
--- a/src/tui/screens/startup.rs
+++ b/src/tui/screens/startup.rs
@@ -25,33 +25,27 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
let rows = Layout::default()
.direction(Direction::Vertical)
.constraints([
- Constraint::Length(1),
- Constraint::Length(1),
- Constraint::Length(1),
+ Constraint::Min(0),
Constraint::Length(1),
Constraint::Min(0),
])
.split(inner);
- let status_text = "Checking GitHub for a newer release…";
-
- let spinner_frames = ['◐', '◓', '◑', '◒'];
- let spinner = spinner_frames[(state.tick_count as usize / 3) % spinner_frames.len()];
+ let dots = match (state.tick_count / 4) % 4 {
+ 0 => "",
+ 1 => ".",
+ 2 => "..",
+ _ => "...",
+ };
frame.render_widget(
Paragraph::new(Line::from(vec![
- Span::styled(format!("{spinner} "), theme.accent),
- Span::styled(status_text, theme.text),
+ Span::styled(format!("Checking GitHub for a newer release{dots}"), theme.text),
]))
.alignment(Alignment::Center),
rows[1],
);
- let pulse = ["● · ·", "· ● ·", "· · ●", "· ● ·"][(state.tick_count as usize / 4) % 4];
- frame.render_widget(
- Paragraph::new(Span::styled(pulse, theme.accent)).alignment(Alignment::Center),
- rows[3],
- );
let footer = Rect {
x: panel.x,