diff options
Diffstat (limited to 'gui/src')
-rw-r--r-- | gui/src/main.rs | 2 | ||||
-rw-r--r-- | gui/src/timeline.rs | 26 | ||||
-rw-r--r-- | gui/src/timeline_post.rs | 29 |
3 files changed, 57 insertions, 0 deletions
diff --git a/gui/src/main.rs b/gui/src/main.rs index 32d6d61..581877b 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -2,6 +2,8 @@ use anyhow::Result; mod app; mod cli; +mod timeline; +mod timeline_post; fn main() -> Result<()> { let _ = env_logger::try_init()?; diff --git a/gui/src/timeline.rs b/gui/src/timeline.rs new file mode 100644 index 0000000..82c8da1 --- /dev/null +++ b/gui/src/timeline.rs @@ -0,0 +1,26 @@ +use crate::timeline_post::TimelinePost; + +#[derive(Debug)] +pub struct Timeline { + posts: Vec<TimelinePost> +} + +impl Timeline { + pub fn new() -> Self { + Self { + posts: Vec::with_capacity(100), + } + } + + pub fn update(&mut self) { + self.posts.iter_mut().for_each(|mut post| post.update()); + } + + pub fn view(&self) -> iced::Column<crate::app::Message> { + self.posts + .iter() + .fold(iced::Column::new(), |c, post| { + c.push(post.view()) + }) + } +} diff --git a/gui/src/timeline_post.rs b/gui/src/timeline_post.rs new file mode 100644 index 0000000..8b53898 --- /dev/null +++ b/gui/src/timeline_post.rs @@ -0,0 +1,29 @@ +#[derive(Debug)] +pub struct TimelinePost { + mime: mime::Mime, + content: PostContent, +} + +#[derive(Debug)] +pub enum PostContent { + Text(String) +} + +impl TimelinePost { + pub fn update(&mut self) { + () + } + + pub fn view(&self) -> iced::Row<crate::app::Message> { + iced::Row::new() + .push({ + iced::Text::new(self.mime.as_ref().to_string()) + }) + .push({ + match self.content { + PostContent::Text(ref txt) => iced::Text::new(txt.clone()), + } + }) + .into() + } +} |