diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-18 17:32:41 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-18 17:32:41 +0100 |
commit | 1c90ee16661006c8cbfd628a93608566a9bc6b76 (patch) | |
tree | a6ac58c5013df6b7e663f533c8ae8f0cbf4b112e /gui/src/post.rs | |
parent | aa5c1f79dcdfae35f10835ea43bac6f451d7149d (diff) | |
parent | 19ea5662c661d5a7ab3eeeafa1f7a7846ea4f762 (diff) |
Merge branch 'gui-timeline'
Diffstat (limited to 'gui/src/post.rs')
-rw-r--r-- | gui/src/post.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gui/src/post.rs b/gui/src/post.rs new file mode 100644 index 0000000..11c5f6a --- /dev/null +++ b/gui/src/post.rs @@ -0,0 +1,47 @@ +use crate::app::Message; +use distrox_lib::types::Payload; + +#[derive(Clone, Debug)] +pub struct Post { + payload: Payload, + content: String, +} + +impl Post { + pub fn new(payload: Payload, content: String) -> Self { + Self { payload, content } + } + + pub fn view(&self) -> iced::Element<Message> { + iced::Column::new() + .push({ + iced::Row::new() + .height(iced::Length::Shrink) + .width(iced::Length::Fill) + .push({ + iced::Column::new() + .width(iced::Length::Fill) + .align_items(iced::Alignment::Start) + .push({ + iced::Text::new(self.payload.timestamp().inner().to_string()) + .size(10) + }) + }) + .push({ + iced::Column::new() + .width(iced::Length::Fill) + .align_items(iced::Alignment::End) + .push({ + iced::Text::new(self.payload.content().to_string()) + .size(10) + }) + }) + }) + .push(iced::rule::Rule::horizontal(10)) + .push({ + iced::Text::new(self.content.clone()).size(12) + }) + .push(iced::rule::Rule::horizontal(10)) + .into() + } +} |