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
Add basic view
Pressing `B` will take you to a "basic view", which is just a centered
playbar.

Closes #320
  • Loading branch information
Rigellute committed Mar 17, 2020
commit a94513ea22ff9a4919c22386cc7bc5d174c8a0a6
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub enum ActiveBlock {
TrackTable,
MadeForYou,
Artists,
BasicView,
}

#[derive(Clone, PartialEq, Debug)]
Expand All @@ -139,6 +140,7 @@ pub enum RouteId {
AlbumTracks,
AlbumList,
Artist,
BasicView,
Error,
Home,
RecentlyPlayed,
Expand Down
7 changes: 7 additions & 0 deletions src/handlers/basic_view.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::{app::App, event::Key};

pub fn handler(key: Key, _app: &mut App) {
match key {
_ => {}
};
}
1 change: 1 addition & 0 deletions src/handlers/common_key_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub fn handle_right_event(app: &mut App) {
RouteId::SelectedDevice => {}
RouteId::Error => {}
RouteId::Analysis => {}
RouteId::BasicView => {}
},
_ => {}
};
Expand Down
7 changes: 7 additions & 0 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod album_tracks;
mod analysis;
mod artist;
mod artists;
mod basic_view;
mod common_key_events;
mod empty;
mod error_screen;
Expand Down Expand Up @@ -84,6 +85,9 @@ pub fn handle_app(key: Key, app: &mut App) {
_ if key == app.user_config.keys.audio_analysis => {
app.get_audio_analysis();
}
_ if key == app.user_config.keys.basic_view => {
app.push_navigation_stack(RouteId::BasicView, ActiveBlock::BasicView);
}
_ => handle_block_events(key, app),
}
}
Expand Down Expand Up @@ -149,6 +153,9 @@ fn handle_block_events(key: Key, app: &mut App) {
ActiveBlock::PlayBar => {
playbar::handler(key, app);
}
ActiveBlock::BasicView => {
basic_view::handler(key, app);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ async fn start_ui(user_config: UserConfig, app: &Arc<Mutex<App>>) -> Result<(),
ActiveBlock::Analysis => {
ui::audio_analysis::draw(&mut f, &app);
}
ActiveBlock::BasicView => {
ui::draw_basic_view(&mut f, &app);
}
_ => {
ui::draw_main_layout(&mut f, &app);
}
Expand Down
21 changes: 21 additions & 0 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ where
RouteId::Error => {} // This is handled as a "full screen" route in main.rs
RouteId::SelectedDevice => {} // This is handled as a "full screen" route in main.rs
RouteId::Analysis => {} // This is handled as a "full screen" route in main.rs
RouteId::BasicView => {} // This is handled as a "full screen" route in main.rs
};
}

Expand Down Expand Up @@ -728,6 +729,26 @@ where
)
}

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());

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

pub fn draw_playbar<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
where
B: Backend,
Expand Down
4 changes: 4 additions & 0 deletions src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pub struct KeyBindingsString {
copy_song_url: Option<String>,
copy_album_url: Option<String>,
audio_analysis: Option<String>,
basic_view: Option<String>,
}

#[derive(Clone)]
Expand All @@ -186,6 +187,7 @@ pub struct KeyBindings {
pub copy_song_url: Key,
pub copy_album_url: Key,
pub audio_analysis: Key,
pub basic_view: Key,
}

#[derive(Default, Clone, Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -240,6 +242,7 @@ impl UserConfig {
copy_song_url: Key::Char('c'),
copy_album_url: Key::Char('C'),
audio_analysis: Key::Char('v'),
basic_view: Key::Char('B'),
},
behavior: BehaviorConfig {
seek_milliseconds: 5 * 1000,
Expand Down Expand Up @@ -305,6 +308,7 @@ impl UserConfig {
to_keys!(copy_song_url);
to_keys!(copy_album_url);
to_keys!(audio_analysis);
to_keys!(basic_view);

Ok(())
}
Expand Down