diff --git a/src/application.css b/src/application.css index 72679dd..fd5507b 100644 --- a/src/application.css +++ b/src/application.css @@ -10,3 +10,10 @@ .open-collection-item-button { font-weight : normal ; /* No bold text by default for this kind of button */ } + +.media-modal { + padding : 100px ; +} +.media-modal .top-padding { + padding-top : 40px ; +} diff --git a/src/ui/collatable_container/collated_grid.rs b/src/ui/collatable_container/collated_grid.rs index 8c69424..c231e78 100644 --- a/src/ui/collatable_container/collated_grid.rs +++ b/src/ui/collatable_container/collated_grid.rs @@ -87,28 +87,26 @@ impl < A : MediaAdapter > CollatedMediaGrid { media . get_name () . as_str () , ) ) , - match media . get_original_name () { - Some (original_name) => Some ( label ! ( - @ justify : Justification :: Center ; - @ wrap : true ; - @ max_width_chars : 1 ; // Not the actual limit, used instead to wrap more aggressively - original_name . as_str () , - ) ) , - None => None , - } . as_ref () , + media . get_original_name () . map ( |original_name| label ! ( + @ justify : Justification :: Center ; + @ wrap : true ; + @ max_width_chars : 1 ; // Not the actual limit, used instead to wrap more aggressively + original_name . as_str () , + ) ) . as_ref () , Some ( & g_box ! ( @ option_children ; @ orientation : Horizontal ; @ halign : Center ; @ spacing : 20 ; - Some ( & label ! ( media . get_release_date () . as_str () ) ) , - match media . get_runtime_minutes () { - Some (runtime_minutes) => Some ( - label ! ( format ! ( "{}m" , runtime_minutes ) . as_str () ) , - ) , - None => None , - } . as_ref () , + + Some ( & label ! ( + media . get_release_date () . split ('-') . next () . unwrap () , + ) ) , + + media . get_runtime_minutes () . map ( + |runtime_minutes| label ! ( format ! ( "{}m" , runtime_minutes ) . as_str () ) , + ) . as_ref () , ) ) , ) , ) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 737a244..4d93e8f 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -31,7 +31,27 @@ impl UI { ) ) ; let films_component = CollatableMediaContainer :: :: new ( - |film| dialog ! () . present ( Some (window) ) , + |film| dialog ! ( + & g_box ! ( + @ option_children ; + @ orientation : Vertical ; + @ css_classes : & [ "media-modal" ] ; + + Some ( label ! ( + @ css_classes : & [ "title-1" ] ; + film . name . as_str () , + ) ) . as_ref () , + + film . original_name . map ( + |original_name| label ! ( original_name . as_str () ) , + ) . as_ref () , + + Some ( label ! ( + @ css_classes : & [ "top-padding" ] ; + & format ! ( "Release date: {}" , film . release_date ) , + ) ) . as_ref () , + ) , + ) . present ( Some (window) ) , ) ; let series_component = CollatableMediaContainer :: :: new ( |series| dialog ! () . present ( Some (window) ) , diff --git a/src/ui/utility.rs b/src/ui/utility.rs index 942279e..53178b6 100644 --- a/src/ui/utility.rs +++ b/src/ui/utility.rs @@ -18,8 +18,13 @@ macro_rules ! button { ( button } } } -macro_rules ! dialog { () => { { +macro_rules ! dialog { ( + $ ( @ css_classes : $ css_classes : expr ; ) ? + $ ( $ child : expr $ (,) ? ) ? +) => { { let widget = libadwaita :: Dialog :: new () ; + $ ( widget . set_css_classes ( $ css_classes ) ; ) ? + $ ( widget . set_child ( Some ( $ child ) ) ; ) ? widget } } } @@ -118,6 +123,7 @@ macro_rules ! label { ( $ ( @ wrap : $ wrap : expr ; ) ? $ ( @ max_width_chars : $ max_width_chars : expr ; ) ? $ ( @ attributes : $ attributes : expr ; ) ? + $ ( @ css_classes : $ css_classes : expr ; ) ? $ ( $ label : expr ) ? $ (,) ? ) => { { let label = gtk4 :: Label :: builder () . build () ; @@ -129,6 +135,7 @@ macro_rules ! label { ( $ ( label . set_justify ( $ justify ) ; ) ? $ ( label . set_max_width_chars ( $ max_width_chars ) ; ) ? $ ( label . set_attributes ( Some ( $ attributes ) ) ; ) ? + $ ( label . set_css_classes ( $ css_classes ) ; ) ? $ ( label . set_wrap ( $ wrap ) ; ) ? label } } }