aboutsummaryrefslogtreecommitdiff
path: root/src/ui.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-23 19:16:42 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-23 19:16:42 +0530
commit05c4b17bc078df9c5694e450b72aecbed9fc5216 (patch)
tree4058d28fa9dc0fc9ae212758bce0579b858ea213 /src/ui.rs
parenta0582ead78fda02e4137a82e100963e88362f252 (diff)
damn
Diffstat (limited to 'src/ui.rs')
-rwxr-xr-xsrc/ui.rs46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 3f2eec8..b605747 100755
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -1,4 +1,4 @@
-use crate::{app::App, connection::Connection};
+use crate::app::App;
use ratatui::{prelude::*, widgets::*};
/// Renders the user interface widgets
@@ -9,7 +9,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
// - https://github.com/ratatui-org/ratatui/tree/master/examples
// List of songs
- let mut state = ListState::default();
+ let mut song_state = ListState::default();
let size = Rect::new(100, 0, frame.size().width, frame.size().height - 3);
let list = List::new(app.conn.songs_filenames.clone())
.block(Block::default().title("Song List").borders(Borders::ALL))
@@ -17,21 +17,49 @@ pub fn render(app: &mut App, frame: &mut Frame) {
.highlight_symbol(">>")
.repeat_highlight_symbol(true);
- state.select(Some(app.list.index));
- frame.render_stateful_widget(list, size, &mut state);
+ song_state.select(Some(app.song_list.index));
+ frame.render_stateful_widget(list, size, &mut song_state);
// Play Queue
+ let mut queue_state = ListState::default();
let size = Rect::new(0, 0, 100, frame.size().height - 25);
let list = List::new(app.play_deque.clone())
.block(Block::default().title("Play Queue").borders(Borders::ALL))
.highlight_style(Style::new().add_modifier(Modifier::REVERSED))
.highlight_symbol(">>")
.repeat_highlight_symbol(true);
- frame.render_widget(list, size);
+
+ app.update_queue();
+ frame.render_stateful_widget(list, size, &mut queue_state);
// Status
- let size = Rect::new(0, frame.size().height - 3, frame.size().width, 3);
- let status = Paragraph::new(app.conn.conn.status().unwrap().volume.to_string())
- .block(Block::default().title("Status").borders(Borders::ALL));
- frame.render_widget(status, size);
+ // let size = Rect::new(0, frame.size().height - 3, frame.size().width, 3);
+ // let song = app
+ // .conn
+ // .now_playing()
+ // .unwrap_or_else(|| "No Title Found".to_string());
+ //
+ // let (elapsed, total) = app.conn.conn.status().unwrap().time.unwrap();
+ //
+ // let mut lines = vec![];
+ // lines.push(Line::from(vec![
+ // Span::styled("Current: ", Style::default().fg(Color::Red)),
+ // Span::styled(song, Style::default().fg(Color::Yellow)),
+ // Span::styled(format!("[{}/{}]", elapsed.as_secs(), total.as_secs()), Style::default().fg(Color::Yellow)),
+ // ]));
+ // let status = Paragraph::new(Text::from(lines))
+ // .block(Block::default().title("Status").borders(Borders::ALL));
+ // frame.render_widget(status, size);
+
+ // Playlists
+ let mut state = ListState::default();
+ let size = Rect::new(0, 25, 100, frame.size().height - 25 - 3);
+ let list = List::new(app.pl_list.list.clone())
+ .block(Block::default().title("Playlists").borders(Borders::ALL))
+ .highlight_style(Style::new().add_modifier(Modifier::REVERSED))
+ .highlight_symbol(">>")
+ .repeat_highlight_symbol(true);
+
+ state.select(Some(app.pl_list.index));
+ frame.render_stateful_widget(list, size, &mut state);
}