blob: 11c5f6ac944ca2dbbe4133ebad2ee5273bc4d1ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()
}
}
|