diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-06-12 18:13:05 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-06-12 18:13:05 +0530 |
| commit | 65f76181d3cbee48096ebe0424869d4c78bac89b (patch) | |
| tree | 6f2a6c54062f8111b0c7f88fdb4e947112ce72c7 /src/ui.rs | |
| parent | 8a8176e97b0b2e78b5c87573aa9598a79984af13 (diff) | |
new feature: add to new playlist
Diffstat (limited to 'src/ui.rs')
| -rwxr-xr-x | src/ui.rs | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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), |
