From d81bd8f7a22bcd638456746fae9f806c61ac37c0 Mon Sep 17 00:00:00 2001 From: Inaha Date: Thu, 28 Mar 2024 19:25:00 +0800 Subject: [PATCH] feat: add overview in itempage --- resources/ui/history.ui | 5 ++- resources/ui/item.ui | 86 ++++++++++++++++++++++++++++++++++++++++- src/ui/network.rs | 2 +- src/ui/style.css | 10 +++++ src/ui/widgets/item.rs | 36 +++++++++++++++-- 5 files changed, 132 insertions(+), 7 deletions(-) diff --git a/resources/ui/history.ui b/resources/ui/history.ui index 471cc8d9..cd7cac90 100644 --- a/resources/ui/history.ui +++ b/resources/ui/history.ui @@ -11,10 +11,13 @@ vertical - 18 + 6 Continue Watching + + + start 12 diff --git a/resources/ui/item.ui b/resources/ui/item.ui index 9cff20c8..1c04c739 100644 --- a/resources/ui/item.ui +++ b/resources/ui/item.ui @@ -19,7 +19,7 @@ fill cover true - true + 700 @@ -91,6 +91,7 @@ + crossfade 700 False @@ -107,6 +108,89 @@ + + + crossfade + 700 + False + + + True + + + Overview + + + + True + + + + + horizontal + 6 + + + + + true + vertical + 6 + + + + + + start + Season + True + + + + + 8 + 0.00 + true + + + + + + + + + + + true + vertical + 6 + + + + + + start + Episode + True + + + + + 8 + 0.00 + true + + + + + + + + + + + + diff --git a/src/ui/network.rs b/src/ui/network.rs index f7c45dd5..6a78bf0c 100644 --- a/src/ui/network.rs +++ b/src/ui/network.rs @@ -321,7 +321,7 @@ pub async fn get_item_overview(id: String) -> Result { let server_info = get_server_info(); let client = reqwest::Client::new(); let url = format!( - "{}:{}/emby/Users/{}/{}", + "{}:{}/emby/Users/{}/Items/{}", server_info.domain, server_info.port, server_info.user_id, id ); let params = [ diff --git a/src/ui/style.css b/src/ui/style.css index 7327df07..3a858349 100644 --- a/src/ui/style.css +++ b/src/ui/style.css @@ -54,6 +54,16 @@ box > overlay > image { margin:3px; color: #FFFFFF; } + +revealer > expander-widget > box > box > widget { + background-color:rgba(1,1,1,0.3); + border-radius:10px; + margin:5px; +} + +revealer > expander-widget > box > box > widget > box{ + margin:15px; +} /* Generated with Gradience diff --git a/src/ui/widgets/item.rs b/src/ui/widgets/item.rs index fafdaa47..19ad7b54 100644 --- a/src/ui/widgets/item.rs +++ b/src/ui/widgets/item.rs @@ -37,6 +37,12 @@ mod imp { pub logobox: TemplateChild, #[template_child] pub seasonlist: TemplateChild, + #[template_child] + pub overviewrevealer: TemplateChild, + #[template_child] + pub itemoverview: TemplateChild, + #[template_child] + pub selecteditemoverview: TemplateChild, pub selection: gtk::SingleSelection, pub seasonselection: gtk::SingleSelection, } @@ -171,7 +177,7 @@ mod imp { UserData: info.UserData.clone(), Overview: info.Overview.clone(), }; - obj.requestdropdown(seriesinfo.clone()); + obj.selectepisode(seriesinfo.clone()); } } } @@ -195,7 +201,7 @@ mod imp { }); itemrevealer.set_reveal_child(true); })); - + obj.setoverview(); let factory = gtk::SignalListItemFactory::new(); factory.connect_bind(|_, item| { let listitem = item.downcast_ref::().unwrap(); @@ -254,7 +260,7 @@ mod imp { .and_downcast::() .unwrap(); let seriesinfo: Ref = item.borrow(); - obj.requestdropdown(seriesinfo.clone()); + obj.selectepisode(seriesinfo.clone()); })); } } @@ -333,7 +339,7 @@ impl ItemPage { imp.itemlist.last_child().unwrap().activate(); } - pub fn requestdropdown(&self, seriesinfo: SeriesInfo) { + pub fn selectepisode(&self, seriesinfo: SeriesInfo) { let info = seriesinfo.clone(); let imp = self.imp(); let osdbox = imp.osdbox.get(); @@ -367,5 +373,27 @@ impl ItemPage { } }), ); + + if let Some(overview) = seriesinfo.Overview { + imp.selecteditemoverview.set_text(Some(&overview)); + } + } + + pub fn setoverview(&self) { + let imp = self.imp(); + let id = imp.id.get().unwrap().clone(); + let itemoverview = imp.itemoverview.get(); + let overviewrevealer = imp.overviewrevealer.get(); + let (sender, receiver) = async_channel::bounded::(1); + crate::ui::network::runtime().spawn(async move { + let overview = crate::ui::network::get_item_overview(id.to_string()).await.expect("msg"); + sender.send(overview).await.expect("msg"); + }); + glib::spawn_future_local(async move { + while let Ok(overview) = receiver.recv().await { + itemoverview.set_text(Some(&overview)); + overviewrevealer.set_reveal_child(true); + } + }); } }