A collection movie's overview renders in a popup that does not scroll, so a long overview overflows with no way to read the rest. The popup now scrolls. The popup owns its own ScrollableText, built from the selected collection movie's overview when it opens and torn down on Esc so a reopened popup starts at the top. Scrolling mutates only that owned state. The background renders the Collection record's overview and the movies table, neither of which carries a scroll offset, so they cannot scroll along with the popup. The popup also gains the loading and absent fallbacks the rest of the tree already has. Give the collection movie fixture an overview distinct from its collection's, and a multi-paragraph one, so the snapshots can tell the two records apart and a scrolled popup is distinguishable from an unscrolled one.
103 lines
2.2 KiB
Rust
103 lines
2.2 KiB
Rust
use crate::app::App;
|
|
use crate::event::Key;
|
|
use crate::handlers::KeyEventHandler;
|
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
|
use crate::models::{Route, Scrollable, ScrollableText};
|
|
|
|
#[cfg(test)]
|
|
#[path = "movie_overview_handler_tests.rs"]
|
|
mod movie_overview_handler_tests;
|
|
|
|
pub(super) struct MovieOverviewHandler<'a, 'b> {
|
|
key: Key,
|
|
app: &'a mut App<'b>,
|
|
_active_radarr_block: ActiveRadarrBlock,
|
|
_context: Option<ActiveRadarrBlock>,
|
|
}
|
|
|
|
impl MovieOverviewHandler<'_, '_> {
|
|
fn overview(&mut self) -> &mut ScrollableText {
|
|
&mut self
|
|
.app
|
|
.data
|
|
.radarr_data
|
|
.movie_overview_modal
|
|
.as_mut()
|
|
.expect("Movie overview modal is undefined")
|
|
.overview
|
|
}
|
|
}
|
|
|
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieOverviewHandler<'a, 'b> {
|
|
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
|
active_block == ActiveRadarrBlock::ViewMovieOverview
|
|
}
|
|
|
|
fn ignore_special_keys(&self) -> bool {
|
|
self.app.ignore_special_keys_for_textbox_input
|
|
}
|
|
|
|
fn new(
|
|
key: Key,
|
|
app: &'a mut App<'b>,
|
|
active_block: ActiveRadarrBlock,
|
|
_context: Option<ActiveRadarrBlock>,
|
|
) -> MovieOverviewHandler<'a, 'b> {
|
|
MovieOverviewHandler {
|
|
key,
|
|
app,
|
|
_active_radarr_block: active_block,
|
|
_context,
|
|
}
|
|
}
|
|
|
|
fn get_key(&self) -> Key {
|
|
self.key
|
|
}
|
|
|
|
fn is_ready(&self) -> bool {
|
|
if self.app.is_loading {
|
|
return false;
|
|
}
|
|
|
|
self.app.data.radarr_data.movie_overview_modal.is_some()
|
|
}
|
|
|
|
fn handle_scroll_up(&mut self) {
|
|
self.overview().scroll_up();
|
|
}
|
|
|
|
fn handle_scroll_down(&mut self) {
|
|
self.overview().scroll_down();
|
|
}
|
|
|
|
fn handle_home(&mut self) {
|
|
self.overview().scroll_to_top();
|
|
}
|
|
|
|
fn handle_end(&mut self) {
|
|
self.overview().scroll_to_bottom();
|
|
}
|
|
|
|
fn handle_delete(&mut self) {}
|
|
|
|
fn handle_left_right_action(&mut self) {}
|
|
|
|
fn handle_submit(&mut self) {}
|
|
|
|
fn handle_esc(&mut self) {
|
|
self.app.pop_navigation_stack();
|
|
self.app.data.radarr_data.movie_overview_modal = None;
|
|
}
|
|
|
|
fn handle_char_key_event(&mut self) {}
|
|
|
|
fn app_mut(&mut self) -> &mut App<'b> {
|
|
self.app
|
|
}
|
|
|
|
fn current_route(&self) -> Route {
|
|
self.app.get_current_route()
|
|
}
|
|
}
|