diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-10 19:33:38 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-10 19:33:38 +0100 |
commit | c5a9d938e087e7f037f5667c0af32f97b3cd00cf (patch) | |
tree | bebef44091ce6a12b132257ec01f914d0b0d1e90 | |
parent | a2118de80db35b01690d802fb375e9b8bfafb4fa (diff) |
Add timeline types
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | gui/Cargo.toml | 1 | ||||
-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 |
4 files changed, 58 insertions, 0 deletions
diff --git a/gui/Cargo.toml b/gui/Cargo.toml index e3699a8..539d59a 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -27,6 +27,7 @@ getset = "0.1" xdg = "2.4" tracing = "0.1" ctrlc = "3.2" +mime = "0.3" [dependencies.ipfs] git = "https://github.com/rs-ipfs/rust-ipfs/" 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() + } +} |