fix: minor formatting tweaks

This commit is contained in:
talwat 2025-11-17 17:15:17 +01:00
parent bd525b0813
commit 9439866f52
4 changed files with 17 additions and 19 deletions

View File

@ -88,7 +88,7 @@ impl Handle {
Ok(queued) => Output::Queued(queued), Ok(queued) => Output::Queued(queued),
Err(_) => { Err(_) => {
PROGRESS.store(0, atomic::Ordering::Relaxed); PROGRESS.store(0, atomic::Ordering::Relaxed);
Output::Loading(&PROGRESS) Output::Loading(progress())
} }
} }
} }

View File

@ -21,7 +21,6 @@ pub enum Current {
} }
pub struct Player { pub struct Player {
ui: ui::Handle,
downloader: download::Handle, downloader: download::Handle,
volume: PersistentVolume, volume: PersistentVolume,
bookmarks: Bookmarks, bookmarks: Bookmarks,
@ -29,6 +28,7 @@ pub struct Player {
rx: Receiver<crate::Message>, rx: Receiver<crate::Message>,
broadcast: broadcast::Sender<ui::Update>, broadcast: broadcast::Sender<ui::Update>,
current: Current, current: Current,
_ui: ui::Handle,
_tx: Sender<crate::Message>, _tx: Sender<crate::Message>,
_stream: rodio::OutputStream, _stream: rodio::OutputStream,
} }
@ -84,12 +84,12 @@ impl Player {
Ok(Self { Ok(Self {
current, current,
downloader, downloader,
ui,
broadcast: utx, broadcast: utx,
rx, rx,
sink, sink,
bookmarks, bookmarks,
volume, volume,
_ui: ui,
_stream: stream, _stream: stream,
_tx: tx, _tx: tx,
}) })

View File

@ -8,6 +8,7 @@ use crate::{
use tokio::{ use tokio::{
sync::{broadcast, mpsc::Sender}, sync::{broadcast, mpsc::Sender},
task::JoinHandle, task::JoinHandle,
time::Instant,
}; };
mod components; mod components;
mod environment; mod environment;
@ -39,6 +40,7 @@ pub struct State {
pub sink: Arc<rodio::Sink>, pub sink: Arc<rodio::Sink>,
pub current: Current, pub current: Current,
pub bookmarked: bool, pub bookmarked: bool,
timer: Option<Instant>,
width: usize, width: usize,
} }
@ -50,6 +52,7 @@ impl State {
sink, sink,
current, current,
bookmarked: false, bookmarked: false,
timer: None,
} }
} }
} }
@ -90,7 +93,7 @@ impl Handle {
let mut window = Window::new(state.width, params.borderless); let mut window = Window::new(state.width, params.borderless);
loop { loop {
interface::draw(&state, &mut window, params).await?; interface::draw(&mut state, &mut window, params).await?;
if let Ok(message) = rx.try_recv() { if let Ok(message) = rx.try_recv() {
match message { match message {

View File

@ -28,28 +28,23 @@ impl From<&Args> for Params {
/// The code for the terminal interface itself. /// The code for the terminal interface itself.
/// ///
/// * `minimalist` - All this does is hide the bottom control bar. /// * `minimalist` - All this does is hide the bottom control bar.
pub async fn draw(state: &ui::State, window: &mut Window, params: Params) -> super::Result<()> { pub async fn draw(state: &mut ui::State, window: &mut Window, params: Params) -> super::Result<()> {
let action = components::action(&state, state.width); let action = components::action(&state, state.width);
let volume = state.sink.volume(); let volume = state.sink.volume();
let percentage = format!("{}%", (volume * 100.0).round().abs()); let percentage = format!("{}%", (volume * 100.0).round().abs());
// let timer = VOLUME_TIMER.load(Ordering::Relaxed); let middle = match state.timer {
// let middle = match timer { Some(timer) => {
let middle = components::progress_bar(&state, state.width - 16); if timer.elapsed() > Duration::from_secs(3) {
// _ => components::audio_bar(volume, &percentage, width - 17), state.timer = None;
// }; };
components::progress_bar(&state, state.width - 16)
// if timer > 0 && timer <= AUDIO_BAR_DURATION { }
// // We'll keep increasing the timer until it eventually hits `AUDIO_BAR_DURATION`. None => components::audio_bar(state.width - 17, volume, &percentage),
// VOLUME_TIMER.fetch_add(1, Ordering::Relaxed); };
// } else {
// // If enough time has passed, we'll reset it back to 0.
// VOLUME_TIMER.store(0, Ordering::Relaxed);
// }
let controls = components::controls(state.width); let controls = components::controls(state.width);
let menu = match (params.minimalist, &state.current) { let menu = match (params.minimalist, &state.current) {
(true, _) => vec![action, middle], (true, _) => vec![action, middle],
// (false, Some(x)) => vec![x.path.clone(), action, middle, controls], // (false, Some(x)) => vec![x.path.clone(), action, middle, controls],