From 65f76181d3cbee48096ebe0424869d4c78bac89b Mon Sep 17 00:00:00 2001 From: krolxon Date: Wed, 12 Jun 2024 18:13:05 +0530 Subject: new feature: add to new playlist --- src/ui.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/ui.rs') diff --git a/src/ui.rs b/src/ui.rs index adf9d43..bd21e08 100755 --- a/src/ui.rs +++ b/src/ui.rs @@ -14,6 +14,7 @@ pub enum InputMode { Editing, Normal, PlaylistRename, + NewPlaylist, } /// Renders the user interface widgets @@ -40,6 +41,9 @@ pub fn render(app: &mut App, frame: &mut Frame) { InputMode::PlaylistRename => { draw_rename_playlist(frame, app, layout[1]); } + InputMode::NewPlaylist => { + draw_new_playlist(frame, app, layout[1]); + } } if app.playlist_popup { @@ -453,6 +457,26 @@ fn draw_rename_playlist(frame: &mut Frame, app: &mut App, area: Rect) { frame.render_widget(input, area); } +fn draw_new_playlist(frame: &mut Frame, app: &mut App, area: Rect) { + #[allow(clippy::cast_possible_truncation)] + frame.set_cursor( + // Draw the cursor at the current position in the input field. + // This position is can be controlled via the left and right arrow key + area.x + app.pl_new_pl_cursor_pos as u16 + 2, + // Move one line down, from the border to the input line + area.y + 1, + ); + + let input = Paragraph::new("/".to_string() + &app.pl_new_pl_input) + .style(Style::default()) + .block( + Block::default() + .borders(Borders::ALL) + .title("Enter New Playlist's Name: ".bold().green()), + ); + frame.render_widget(input, area); +} + fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect { let popup_layout = Layout::vertical([ Constraint::Percentage((100 - percent_y) / 2), -- cgit v1.2.3