zoodex/src/ui/mod.rs

62 lines
1.6 KiB
Rust
Raw Normal View History

mod application_header_bar ;
mod collatable_container ;
mod collection_view_stack ;
mod component ;
2024-11-20 16:32:37 +01:00
mod utility ;
use {
gtk4 :: { Orientation :: * , prelude :: * } ,
libadwaita :: * ,
} ;
2024-11-20 16:32:37 +01:00
use crate :: {
2025-02-05 00:03:26 +01:00
data_manager :: * ,
ui :: {
application_header_bar :: * ,
collatable_container :: * ,
collection_view_stack :: * ,
component :: * ,
2025-01-31 18:11:06 +01:00
utility :: * ,
} ,
} ;
2024-11-20 16:32:37 +01:00
pub struct UI {
window : ApplicationWindow ,
films_component : CollatableFilmsContainer ,
series_component : CollatableSeriesContainer ,
2024-11-20 16:32:37 +01:00
}
impl UI {
pub fn new ( application : & Application ) -> UI {
2025-02-05 13:51:22 +01:00
let films_component = CollatableFilmsContainer :: new () ;
let series_component = CollatableSeriesContainer :: new () ;
let switch_component = CollectionViewStack :: new (
& films_component , & series_component ) ;
let header_bar = ApplicationHeaderBar :: new ( & switch_component ) ;
2025-01-31 18:11:06 +01:00
let window = application_window ! (
@ application : application ;
@ title : "Zoödex" ;
2025-01-31 18:11:06 +01:00
g_box ! (
@ orientation : Vertical ;
2025-01-31 18:11:06 +01:00
* header_bar . get_widget () ,
* switch_component . get_widget () ,
) ,
2024-11-20 16:32:37 +01:00
) ;
UI { window , films_component , series_component }
2024-11-20 16:32:37 +01:00
}
pub fn show_window ( & self ) { self . window . set_visible (true) }
2024-11-29 21:06:14 +01:00
pub fn close_window ( & self ) { self . window . close () }
2025-02-05 13:51:22 +01:00
pub async fn render_collection_overview ( & self , collection : CollectionOverview ) {
// TODO: Find a way to await these futures concurrently
self . films_component . set_films ( collection . films ) . await ;
self . series_component . set_series ( collection . series ) . await ;
2024-11-20 16:32:37 +01:00
}
}