Replace single data model with data management struct and views
This commit is contained in:
parent
c14d2ab6f1
commit
7610b291a4
6 changed files with 88 additions and 96 deletions
|
|
@ -9,21 +9,21 @@ use {
|
|||
std :: { cell :: * , iter :: * , path :: Path } ,
|
||||
} ;
|
||||
|
||||
use crate :: { collection :: * , ui :: { collatable_container :: * , component :: * } } ;
|
||||
use crate :: ui :: { collatable_container :: * , component :: * } ;
|
||||
|
||||
|
||||
|
||||
pub struct CollatedFilmsGrid {
|
||||
film_widget_pairs : RefCell < Vec < ( Film , Box ) > > ,
|
||||
film_widget_pairs : RefCell < Vec < ( FilmOverview , Box ) > > ,
|
||||
grid_widget : FlowBox ,
|
||||
}
|
||||
pub struct CollatedSeriesGrid {
|
||||
series_widget_pairs : RefCell < Vec < ( Series , Box ) > > ,
|
||||
series_widget_pairs : RefCell < Vec < ( SeriesOverview , Box ) > > ,
|
||||
grid_widget : FlowBox ,
|
||||
}
|
||||
|
||||
impl CollatedFilmsGrid {
|
||||
pub fn new ( films : Vec <Film> , sorting : FilmsSorting ) -> Self {
|
||||
pub fn new ( films : Vec <FilmOverview> , sorting : FilmsSorting ) -> Self {
|
||||
let grid_widget = flow_box ! (
|
||||
@ orientation : Horizontal ;
|
||||
@ homogeneous : true ;
|
||||
|
|
@ -37,7 +37,7 @@ impl CollatedFilmsGrid {
|
|||
component
|
||||
}
|
||||
|
||||
pub fn set_films ( & self , films : Vec <Film> , sorting : FilmsSorting ) {
|
||||
pub fn set_films ( & self , films : Vec <FilmOverview> , sorting : FilmsSorting ) {
|
||||
let widgets = films . iter ()
|
||||
. map (create_film_entry)
|
||||
. collect :: < Vec <_> > () ;
|
||||
|
|
@ -57,7 +57,7 @@ impl CollatedFilmsGrid {
|
|||
}
|
||||
}
|
||||
|
||||
fn sort_film_widget_pairs ( & self , sorting : FilmsSorting ) -> Vec < ( Film , Box ) > {
|
||||
fn sort_film_widget_pairs ( & self , sorting : FilmsSorting ) -> Vec < ( FilmOverview , Box ) > {
|
||||
let mut sorted = Vec :: from (
|
||||
self . film_widget_pairs . borrow () . as_slice () ) ;
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ impl CollatedFilmsGrid {
|
|||
}
|
||||
}
|
||||
impl CollatedSeriesGrid {
|
||||
pub fn new ( series : Vec <Series> , sorting : SeriesSorting ) -> Self {
|
||||
pub fn new ( series : Vec <SeriesOverview> , sorting : SeriesSorting ) -> Self {
|
||||
let grid_widget = flow_box ! (
|
||||
@ orientation : Horizontal ;
|
||||
@ homogeneous : true ;
|
||||
|
|
@ -90,7 +90,7 @@ impl CollatedSeriesGrid {
|
|||
component
|
||||
}
|
||||
|
||||
pub fn set_series ( & self , series : Vec <Series> , sorting : SeriesSorting ) {
|
||||
pub fn set_series ( & self , series : Vec <SeriesOverview> , sorting : SeriesSorting ) {
|
||||
let widgets = series . iter ()
|
||||
. map (create_series_entry)
|
||||
. collect :: < Vec <_> > () ;
|
||||
|
|
@ -110,7 +110,7 @@ impl CollatedSeriesGrid {
|
|||
}
|
||||
}
|
||||
|
||||
fn sort_series_widget_pairs ( & self , sorting : SeriesSorting ) -> Vec < ( Series , Box ) > {
|
||||
fn sort_series_widget_pairs ( & self , sorting : SeriesSorting ) -> Vec < ( SeriesOverview , Box ) > {
|
||||
let mut sorted = Vec :: from (
|
||||
self . series_widget_pairs . borrow () . as_slice () ) ;
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ impl Component <FlowBox> for CollatedSeriesGrid {
|
|||
fn get_widget ( & self ) -> & FlowBox { & self . grid_widget }
|
||||
}
|
||||
|
||||
pub fn create_film_entry ( film : & Film ) -> Box {
|
||||
pub fn create_film_entry ( film : & FilmOverview ) -> Box {
|
||||
create_collection_item (
|
||||
film . name . as_str () ,
|
||||
film . original_name . as_deref () ,
|
||||
|
|
@ -142,7 +142,7 @@ pub fn create_film_entry ( film : & Film ) -> Box {
|
|||
& create_film_details (film) ,
|
||||
)
|
||||
}
|
||||
pub fn create_series_entry ( series : & Series ) -> Box {
|
||||
pub fn create_series_entry ( series : & SeriesOverview ) -> Box {
|
||||
create_collection_item (
|
||||
series . name . as_str () ,
|
||||
series . original_name . as_deref () ,
|
||||
|
|
@ -201,7 +201,7 @@ fn create_collection_item (
|
|||
container
|
||||
}
|
||||
|
||||
fn create_film_details ( film : & Film ) -> Box {
|
||||
fn create_film_details ( film : & FilmOverview ) -> Box {
|
||||
g_box ! (
|
||||
@ orientation : Horizontal ;
|
||||
@ halign : Center ;
|
||||
|
|
@ -210,12 +210,11 @@ fn create_film_details ( film : & Film ) -> Box {
|
|||
label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
|
||||
)
|
||||
}
|
||||
fn create_series_details ( series : & Series ) -> Box {
|
||||
fn create_series_details ( series : & SeriesOverview ) -> Box {
|
||||
g_box ! (
|
||||
@ orientation : Horizontal ;
|
||||
@ halign : Center ;
|
||||
@ spacing : 20 ;
|
||||
// TODO
|
||||
label ! ("????") ,
|
||||
label ! ( series . first_release_date . as_str () ) ,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue