Skip to content

Commit

Permalink
feat: add overview in itempage
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukinaha committed Mar 28, 2024
1 parent b0d8239 commit d81bd8f
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 7 deletions.
5 changes: 4 additions & 1 deletion resources/ui/history.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Continue Watching</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<property name="halign">start</property>
<property name="margin-start">12</property>
</object>
Expand Down
86 changes: 85 additions & 1 deletion resources/ui/item.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<property name="valign">fill</property>
<property name="content-fit">cover</property>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<property name="height-request">700</property>
</object>
</child>
<child type="overlay">
Expand Down Expand Up @@ -91,6 +91,7 @@
</child>
<child>
<object class="GtkRevealer" id="itemrevealer">
<property name="transition-type">crossfade</property>
<property name="transition-duration">700</property>
<property name="reveal-child">False</property>
<child>
Expand All @@ -107,6 +108,89 @@
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="overviewrevealer">
<property name="transition-type">crossfade</property>
<property name="transition-duration">700</property>
<property name="reveal-child">False</property>
<child>
<object class="GtkExpander">
<property name="expanded">True</property>
<child type="label">
<object class="GtkLabel" id="expander-label">
<property name="label" translatable="yes">Overview</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<property name="use-markup">True</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">6</property>
<child>
<object class="AdwBin">
<child>
<object class="GtkBox">
<property name="hexpand">true</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<property name="halign">start</property>
<property name="label">Season</property>
<property name="use-markup">True</property>
</object>
</child>
<child>
<object class="GtkInscription" id="itemoverview">
<property name="min-lines">8</property>
<property name="yalign">0.00</property>
<property name="hexpand">true</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwBin">
<child>
<object class="GtkBox">
<property name="hexpand">true</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<property name="halign">start</property>
<property name="label">Episode</property>
<property name="use-markup">True</property>
</object>
</child>
<child>
<object class="GtkInscription" id="selecteditemoverview">
<property name="min-lines">8</property>
<property name="yalign">0.00</property>
<property name="hexpand">true</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ pub async fn get_item_overview(id: String) -> Result<String, Error> {
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 = [
Expand Down
10 changes: 10 additions & 0 deletions src/ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 32 additions & 4 deletions src/ui/widgets/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ mod imp {
pub logobox: TemplateChild<gtk::Box>,
#[template_child]
pub seasonlist: TemplateChild<gtk::DropDown>,
#[template_child]
pub overviewrevealer: TemplateChild<gtk::Revealer>,
#[template_child]
pub itemoverview: TemplateChild<gtk::Inscription>,
#[template_child]
pub selecteditemoverview: TemplateChild<gtk::Inscription>,
pub selection: gtk::SingleSelection,
pub seasonselection: gtk::SingleSelection,
}
Expand Down Expand Up @@ -171,7 +177,7 @@ mod imp {
UserData: info.UserData.clone(),
Overview: info.Overview.clone(),
};
obj.requestdropdown(seriesinfo.clone());
obj.selectepisode(seriesinfo.clone());
}
}
}
Expand All @@ -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::<gtk::ListItem>().unwrap();
Expand Down Expand Up @@ -254,7 +260,7 @@ mod imp {
.and_downcast::<glib::BoxedAnyObject>()
.unwrap();
let seriesinfo: Ref<network::SeriesInfo> = item.borrow();
obj.requestdropdown(seriesinfo.clone());
obj.selectepisode(seriesinfo.clone());
}));
}
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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::<String>(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);
}
});
}
}

0 comments on commit d81bd8f

Please sign in to comment.