Implement watched filtering on FilmGridItem level
This commit is contained in:
parent
3554cdb148
commit
311d78bcc8
2 changed files with 21 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ use relm4::factory::FactoryVecDeque;
|
|||
use relm4::{Component, ComponentParts, ComponentSender, component};
|
||||
|
||||
use crate::persist::data_manager::{DataManager, DataManagerError};
|
||||
use crate::ui::components::media_grid_item::FilmGridItem;
|
||||
use crate::ui::components::media_grid_item::{FilmGridItem, FilmGridItemInput};
|
||||
use crate::ui::factory_sorting::sort_factory_vec;
|
||||
use crate::ui::filtering::WatchedFilter;
|
||||
use crate::ui::sorting::{
|
||||
|
|
@ -98,7 +98,11 @@ impl Component for FilmGrid {
|
|||
}
|
||||
});
|
||||
}
|
||||
FilmGridInput::ApplyWatchedFilter(_watched_filter) => {}
|
||||
FilmGridInput::ApplyWatchedFilter(watched_filter) => {
|
||||
self
|
||||
.items
|
||||
.broadcast(FilmGridItemInput::ApplyWatchedFilter(watched_filter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use relm4::{Component, ComponentController, Controller, FactorySender, RelmWidge
|
|||
|
||||
use crate::persist::data_manager::{DataManager, DataManagerError};
|
||||
use crate::ui::components::media_details::{FilmDetails, FilmDetailsOutput};
|
||||
use crate::ui::filtering::WatchedFilter;
|
||||
use crate::ui::widget_extensions::{AttrListExt, CondDialogExt, CondLabelExt};
|
||||
use crate::views::overview::FilmOverview;
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ pub struct FilmGridItem {
|
|||
film: FilmOverview,
|
||||
poster: Option<Texture>,
|
||||
details: Option<Controller<FilmDetails>>,
|
||||
watched_filter: Option<WatchedFilter>,
|
||||
}
|
||||
|
||||
impl FilmGridItem {
|
||||
|
|
@ -34,11 +36,12 @@ pub enum FilmGridItemCmdOutput {
|
|||
PosterFailed(DataManagerError),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum FilmGridItemInput {
|
||||
ItemClicked,
|
||||
DetailsClosed,
|
||||
WatchedStatusChanged(bool),
|
||||
ApplyWatchedFilter(Option<WatchedFilter>),
|
||||
}
|
||||
|
||||
#[factory(pub)]
|
||||
|
|
@ -53,6 +56,13 @@ impl FactoryComponent for FilmGridItem {
|
|||
#[root]
|
||||
root = FlowBoxChild {
|
||||
set_focusable: false,
|
||||
#[watch]
|
||||
set_visible: match self.watched_filter {
|
||||
Some(WatchedFilter::OnlyWatched) => self.film.watched,
|
||||
Some(WatchedFilter::OnlyUnwatched) => !self.film.watched,
|
||||
None => true,
|
||||
},
|
||||
|
||||
Button {
|
||||
connect_clicked => FilmGridItemInput::ItemClicked,
|
||||
set_css_classes: &["flat", "media-grid-item"],
|
||||
|
|
@ -159,6 +169,7 @@ impl FactoryComponent for FilmGridItem {
|
|||
film,
|
||||
poster: None,
|
||||
details: None,
|
||||
watched_filter: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +195,9 @@ impl FactoryComponent for FilmGridItem {
|
|||
FilmGridItemInput::WatchedStatusChanged(watched) => {
|
||||
self.film.watched = watched;
|
||||
}
|
||||
FilmGridItemInput::ApplyWatchedFilter(watched_filter) => {
|
||||
self.watched_filter = watched_filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue