mirror of
https://github.com/talwat/lowfi
synced 2025-11-28 13:29:20 +00:00
fix: minor formatting tweaks
This commit is contained in:
parent
bd525b0813
commit
9439866f52
@ -88,7 +88,7 @@ impl Handle {
|
||||
Ok(queued) => Output::Queued(queued),
|
||||
Err(_) => {
|
||||
PROGRESS.store(0, atomic::Ordering::Relaxed);
|
||||
Output::Loading(&PROGRESS)
|
||||
Output::Loading(progress())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ pub enum Current {
|
||||
}
|
||||
|
||||
pub struct Player {
|
||||
ui: ui::Handle,
|
||||
downloader: download::Handle,
|
||||
volume: PersistentVolume,
|
||||
bookmarks: Bookmarks,
|
||||
@ -29,6 +28,7 @@ pub struct Player {
|
||||
rx: Receiver<crate::Message>,
|
||||
broadcast: broadcast::Sender<ui::Update>,
|
||||
current: Current,
|
||||
_ui: ui::Handle,
|
||||
_tx: Sender<crate::Message>,
|
||||
_stream: rodio::OutputStream,
|
||||
}
|
||||
@ -84,12 +84,12 @@ impl Player {
|
||||
Ok(Self {
|
||||
current,
|
||||
downloader,
|
||||
ui,
|
||||
broadcast: utx,
|
||||
rx,
|
||||
sink,
|
||||
bookmarks,
|
||||
volume,
|
||||
_ui: ui,
|
||||
_stream: stream,
|
||||
_tx: tx,
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ use crate::{
|
||||
use tokio::{
|
||||
sync::{broadcast, mpsc::Sender},
|
||||
task::JoinHandle,
|
||||
time::Instant,
|
||||
};
|
||||
mod components;
|
||||
mod environment;
|
||||
@ -39,6 +40,7 @@ pub struct State {
|
||||
pub sink: Arc<rodio::Sink>,
|
||||
pub current: Current,
|
||||
pub bookmarked: bool,
|
||||
timer: Option<Instant>,
|
||||
width: usize,
|
||||
}
|
||||
|
||||
@ -50,6 +52,7 @@ impl State {
|
||||
sink,
|
||||
current,
|
||||
bookmarked: false,
|
||||
timer: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,7 +93,7 @@ impl Handle {
|
||||
let mut window = Window::new(state.width, params.borderless);
|
||||
|
||||
loop {
|
||||
interface::draw(&state, &mut window, params).await?;
|
||||
interface::draw(&mut state, &mut window, params).await?;
|
||||
|
||||
if let Ok(message) = rx.try_recv() {
|
||||
match message {
|
||||
|
||||
@ -28,28 +28,23 @@ impl From<&Args> for Params {
|
||||
/// The code for the terminal interface itself.
|
||||
///
|
||||
/// * `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 volume = state.sink.volume();
|
||||
let percentage = format!("{}%", (volume * 100.0).round().abs());
|
||||
|
||||
// let timer = VOLUME_TIMER.load(Ordering::Relaxed);
|
||||
// let middle = match timer {
|
||||
let middle = components::progress_bar(&state, state.width - 16);
|
||||
// _ => components::audio_bar(volume, &percentage, width - 17),
|
||||
// };
|
||||
|
||||
// if timer > 0 && timer <= AUDIO_BAR_DURATION {
|
||||
// // We'll keep increasing the timer until it eventually hits `AUDIO_BAR_DURATION`.
|
||||
// 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 middle = match state.timer {
|
||||
Some(timer) => {
|
||||
if timer.elapsed() > Duration::from_secs(3) {
|
||||
state.timer = None;
|
||||
};
|
||||
components::progress_bar(&state, state.width - 16)
|
||||
}
|
||||
None => components::audio_bar(state.width - 17, volume, &percentage),
|
||||
};
|
||||
|
||||
let controls = components::controls(state.width);
|
||||
|
||||
let menu = match (params.minimalist, &state.current) {
|
||||
(true, _) => vec![action, middle],
|
||||
// (false, Some(x)) => vec![x.path.clone(), action, middle, controls],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user