Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tui::{
use util::{
create_artist_string, display_track_progress, get_artist_highlight_state, get_color,
get_percentage_width, get_search_results_highlight_state, get_track_progress_percentage,
millis_to_minutes, SMALL_TERMINAL_WIDTH,
millis_to_minutes, BASIC_VIEW_HEIGHT, SMALL_TERMINAL_WIDTH,
};

pub enum TableId {
Expand Down Expand Up @@ -831,20 +831,23 @@ pub fn draw_basic_view<B>(f: &mut Frame<B>, app: &App)
where
B: Backend,
{
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints(
[
Constraint::Percentage(44),
Constraint::Min(6),
Constraint::Percentage(44),
]
.as_ref(),
)
.margin(4)
.split(f.size());
// If space is negative, do nothing because the widget would not fit
if let Some(s) = app.size.height.checked_sub(BASIC_VIEW_HEIGHT) {
let space = s / 2;
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints(
[
Constraint::Length(space),
Constraint::Length(BASIC_VIEW_HEIGHT),
Constraint::Length(space),
]
.as_ref(),
)
.split(f.size());

draw_playbar(f, app, chunks[1]);
draw_playbar(f, app, chunks[1]);
}
}

pub fn draw_playbar<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
Expand Down
1 change: 1 addition & 0 deletions src/ui/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::user_config::Theme;
use rspotify::model::artist::SimplifiedArtist;
use tui::style::Style;

pub const BASIC_VIEW_HEIGHT: u16 = 6;
pub const SMALL_TERMINAL_WIDTH: u16 = 150;
pub const SMALL_TERMINAL_HEIGHT: u16 = 45;

Expand Down