Show preview of post thumbnail(closes #9)
This commit is contained in:
parent
8298bac336
commit
3ce4fc0c3f
|
@ -13,6 +13,7 @@ pub struct PostRow {
|
||||||
post: PostView,
|
post: PostView,
|
||||||
author_image: Controller<WebImage>,
|
author_image: Controller<WebImage>,
|
||||||
community_image: Controller<WebImage>,
|
community_image: Controller<WebImage>,
|
||||||
|
thumbnail: Controller<WebImage>,
|
||||||
voting_row: Controller<VotingRowModel>,
|
voting_row: Controller<VotingRowModel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,16 +39,34 @@ impl FactoryComponent for PostRow {
|
||||||
view! {
|
view! {
|
||||||
root = gtk::Box {
|
root = gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Vertical,
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
set_spacing: 10,
|
|
||||||
set_margin_end: 10,
|
set_margin_end: 10,
|
||||||
set_margin_start: 10,
|
set_margin_start: 10,
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
|
set_spacing: 10,
|
||||||
|
|
||||||
|
#[local_ref]
|
||||||
|
thumbnail -> gtk::Box {
|
||||||
|
set_visible: self.post.post.thumbnail_url.is_some(),
|
||||||
|
set_size_request: (180, 180),
|
||||||
|
set_margin_start: 10,
|
||||||
|
set_margin_end: 10,
|
||||||
|
set_hexpand: false,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_spacing: 10,
|
||||||
|
set_hexpand: true,
|
||||||
|
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
set_margin_top: 10,
|
set_margin_top: 10,
|
||||||
set_spacing: 10,
|
set_spacing: 10,
|
||||||
set_vexpand: false,
|
set_vexpand: false,
|
||||||
set_hexpand: true,
|
|
||||||
|
|
||||||
#[local_ref]
|
#[local_ref]
|
||||||
community_image -> gtk::Box {
|
community_image -> gtk::Box {
|
||||||
|
@ -116,6 +135,8 @@ impl FactoryComponent for PostRow {
|
||||||
set_visible: self.post.creator.id.0 == settings::get_current_account().id,
|
set_visible: self.post.creator.id.0 == settings::get_current_account().id,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
gtk::Separator {
|
gtk::Separator {
|
||||||
set_margin_top: 10,
|
set_margin_top: 10,
|
||||||
|
@ -128,6 +149,9 @@ impl FactoryComponent for PostRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_model(value: Self::Init, _index: &DynamicIndex, _sender: FactorySender<Self>) -> Self {
|
fn init_model(value: Self::Init, _index: &DynamicIndex, _sender: FactorySender<Self>) -> Self {
|
||||||
|
let thumbnail = WebImage::builder()
|
||||||
|
.launch(get_web_image_url(value.post.thumbnail_url.clone()))
|
||||||
|
.detach();
|
||||||
let author_image = WebImage::builder()
|
let author_image = WebImage::builder()
|
||||||
.launch(get_web_image_url(value.creator.avatar.clone()))
|
.launch(get_web_image_url(value.creator.avatar.clone()))
|
||||||
.detach();
|
.detach();
|
||||||
|
@ -143,6 +167,7 @@ impl FactoryComponent for PostRow {
|
||||||
author_image,
|
author_image,
|
||||||
community_image,
|
community_image,
|
||||||
voting_row,
|
voting_row,
|
||||||
|
thumbnail,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +178,7 @@ impl FactoryComponent for PostRow {
|
||||||
_returned_widget: &<Self::ParentWidget as relm4::factory::FactoryView>::ReturnedWidget,
|
_returned_widget: &<Self::ParentWidget as relm4::factory::FactoryView>::ReturnedWidget,
|
||||||
sender: FactorySender<Self>,
|
sender: FactorySender<Self>,
|
||||||
) -> Self::Widgets {
|
) -> Self::Widgets {
|
||||||
|
let thumbnail = self.thumbnail.widget();
|
||||||
let author_image = self.author_image.widget();
|
let author_image = self.author_image.widget();
|
||||||
let community_image = self.community_image.widget();
|
let community_image = self.community_image.widget();
|
||||||
let voting_row = self.voting_row.widget();
|
let voting_row = self.voting_row.widget();
|
||||||
|
|
Loading…
Reference in New Issue