From 80524e515406007915cb9978f403407a98c44e1e Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Fri, 11 Apr 2025 15:10:25 +0100 Subject: feat: icons --- Cargo.lock | 139 ++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 6 +- assets/icons/addcontact24.svg | 5 ++ assets/icons/attachment24.svg | 3 + assets/icons/away16.svg | 10 +++ assets/icons/away16color.svg | 10 +++ assets/icons/bubble16.svg | 3 + assets/icons/bubble16color.svg | 3 + assets/icons/bubble24.svg | 3 + assets/icons/contact24.svg | 4 ++ assets/icons/delivered16.svg | 4 ++ assets/icons/dnd16.svg | 3 + assets/icons/dnd16color.svg | 3 + assets/icons/error16color.svg | 10 +++ assets/icons/forward24.svg | 10 +++ assets/icons/heart24.svg | 3 + assets/icons/newbubble24.svg | 4 ++ assets/icons/reply24.svg | 10 +++ assets/icons/sending16.svg | 5 ++ assets/icons/sent16.svg | 3 + icons.md | 24 +++++++ src/icons.rs | 127 +++++++++++++++++++++++++++++++++++++ src/main.rs | 87 +++++++++++++++----------- src/message_view.rs | 4 +- 24 files changed, 433 insertions(+), 50 deletions(-) create mode 100644 assets/icons/addcontact24.svg create mode 100644 assets/icons/attachment24.svg create mode 100644 assets/icons/away16.svg create mode 100644 assets/icons/away16color.svg create mode 100644 assets/icons/bubble16.svg create mode 100644 assets/icons/bubble16color.svg create mode 100644 assets/icons/bubble24.svg create mode 100644 assets/icons/contact24.svg create mode 100644 assets/icons/delivered16.svg create mode 100644 assets/icons/dnd16.svg create mode 100644 assets/icons/dnd16color.svg create mode 100644 assets/icons/error16color.svg create mode 100644 assets/icons/forward24.svg create mode 100644 assets/icons/heart24.svg create mode 100644 assets/icons/newbubble24.svg create mode 100644 assets/icons/reply24.svg create mode 100644 assets/icons/sending16.svg create mode 100644 assets/icons/sent16.svg create mode 100644 icons.md create mode 100644 src/icons.rs diff --git a/Cargo.lock b/Cargo.lock index 2e2d829..c8b13ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,7 +834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59fd57d82eb4bfe7ffa9b1cec0c05e2fd378155b47f255a67983cb4afe0e80c2" dependencies = [ "bitflags 2.9.0", - "fontdb", + "fontdb 0.16.2", "log", "rangemap", "rayon", @@ -978,6 +978,12 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + [[package]] name = "dbus" version = "0.9.7" @@ -1348,7 +1354,6 @@ dependencies = [ [[package]] name = "filamento" version = "0.1.0" -source = "git+https://bunny.garden/luz#15faa6b95ffb5c64a56e212cf386c29fef56efc8" dependencies = [ "base64", "chrono", @@ -1378,6 +1383,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + [[package]] name = "flume" version = "0.11.1" @@ -1427,6 +1438,20 @@ dependencies = [ "ttf-parser 0.20.0", ] +[[package]] +name = "fontdb" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e32eac81c1135c1df01d4e6d4233c47ba11f6a6d07f33e0bba09d18797077770" +dependencies = [ + "fontconfig-parser", + "log", + "memmap2", + "slotmap", + "tinyvec", + "ttf-parser 0.21.1", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -2033,8 +2058,9 @@ dependencies = [ "bytemuck", "cosmic-text", "iced_graphics", - "kurbo", + "kurbo 0.10.4", "log", + "resvg", "rustc-hash 2.1.1", "softbuffer", "tiny-skia", @@ -2055,6 +2081,7 @@ dependencies = [ "iced_graphics", "log", "once_cell", + "resvg", "rustc-hash 2.1.1", "thiserror 1.0.69", "wgpu", @@ -2296,6 +2323,12 @@ dependencies = [ "quick-error", ] +[[package]] +name = "imagesize" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" + [[package]] name = "imgref" version = "1.11.0" @@ -2368,7 +2401,6 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jid" version = "0.1.0" -source = "git+https://bunny.garden/luz#15faa6b95ffb5c64a56e212cf386c29fef56efc8" dependencies = [ "sqlx", ] @@ -2483,10 +2515,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "kurbo" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f" +dependencies = [ + "arrayvec", + "smallvec", +] + [[package]] name = "lampada" version = "0.1.0" -source = "git+https://bunny.garden/luz#15faa6b95ffb5c64a56e212cf386c29fef56efc8" dependencies = [ "futures", "jid", @@ -2659,7 +2700,6 @@ dependencies = [ [[package]] name = "luz" version = "0.1.0" -source = "git+https://bunny.garden/luz#15faa6b95ffb5c64a56e212cf386c29fef56efc8" dependencies = [ "async-recursion", "async-trait", @@ -3571,6 +3611,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.1.10" @@ -3952,11 +3998,30 @@ dependencies = [ "hostname", ] +[[package]] +name = "resvg" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944d052815156ac8fa77eaac055220e95ba0b01fa8887108ca710c03805d9051" +dependencies = [ + "gif", + "jpeg-decoder", + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", +] + [[package]] name = "rgb" version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" +dependencies = [ + "bytemuck", +] [[package]] name = "roxmltree" @@ -4315,6 +4380,15 @@ dependencies = [ "quote", ] +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + [[package]] name = "siphasher" version = "1.0.1" @@ -4677,7 +4751,6 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stanza" version = "0.1.0" -source = "git+https://bunny.garden/luz#15faa6b95ffb5c64a56e212cf386c29fef56efc8" dependencies = [ "chrono", "jid", @@ -4696,6 +4769,9 @@ name = "strict-num" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] [[package]] name = "stringprep" @@ -4720,6 +4796,16 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce5d813d71d82c4cbc1742135004e4a79fd870214c155443451c139c9470a0aa" +[[package]] +name = "svgtypes" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" +dependencies = [ + "kurbo 0.11.1", + "siphasher", +] + [[package]] name = "swash" version = "0.1.19" @@ -5230,6 +5316,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + [[package]] name = "unicode-width" version = "0.1.14" @@ -5253,6 +5345,33 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "usvg" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84ea542ae85c715f07b082438a4231c3760539d902e11d093847a0b22963032" +dependencies = [ + "base64", + "data-url", + "flate2", + "fontdb 0.18.0", + "imagesize", + "kurbo 0.11.1", + "log", + "pico-args", + "roxmltree", + "rustybuzz", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "xmlwriter", +] + [[package]] name = "utf16_iter" version = "1.0.5" @@ -6195,6 +6314,12 @@ version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + [[package]] name = "yazi" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 8a324c9..85f4378 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ version = "0.1.0" edition = "2021" [dependencies] -iced = { version = "0.13.0", features = ["tokio", "image"] } -filamento = { version = "0.1.0", git = "https://bunny.garden/luz" } -jid = { version = "0.1.0", git = "https://bunny.garden/luz" } +iced = { version = "0.13.0", features = ["tokio", "image", "svg"] } +filamento = { version = "0.1.0", path = "../luz/filamento" } +jid = { version = "0.1.0", path = "../luz/jid" } tokio = "1.43.0" tokio-stream = "0.1.17" tracing-subscriber = "0.3.19" diff --git a/assets/icons/addcontact24.svg b/assets/icons/addcontact24.svg new file mode 100644 index 0000000..3324996 --- /dev/null +++ b/assets/icons/addcontact24.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/attachment24.svg b/assets/icons/attachment24.svg new file mode 100644 index 0000000..ee808e6 --- /dev/null +++ b/assets/icons/attachment24.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/away16.svg b/assets/icons/away16.svg new file mode 100644 index 0000000..5d78da1 --- /dev/null +++ b/assets/icons/away16.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/icons/away16color.svg b/assets/icons/away16color.svg new file mode 100644 index 0000000..e35da57 --- /dev/null +++ b/assets/icons/away16color.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/icons/bubble16.svg b/assets/icons/bubble16.svg new file mode 100644 index 0000000..8775127 --- /dev/null +++ b/assets/icons/bubble16.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/bubble16color.svg b/assets/icons/bubble16color.svg new file mode 100644 index 0000000..c3c01d8 --- /dev/null +++ b/assets/icons/bubble16color.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/bubble24.svg b/assets/icons/bubble24.svg new file mode 100644 index 0000000..b9e9414 --- /dev/null +++ b/assets/icons/bubble24.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/contact24.svg b/assets/icons/contact24.svg new file mode 100644 index 0000000..da03215 --- /dev/null +++ b/assets/icons/contact24.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/delivered16.svg b/assets/icons/delivered16.svg new file mode 100644 index 0000000..feec0c2 --- /dev/null +++ b/assets/icons/delivered16.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/dnd16.svg b/assets/icons/dnd16.svg new file mode 100644 index 0000000..d13d54b --- /dev/null +++ b/assets/icons/dnd16.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/dnd16color.svg b/assets/icons/dnd16color.svg new file mode 100644 index 0000000..e69cbe3 --- /dev/null +++ b/assets/icons/dnd16color.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/error16color.svg b/assets/icons/error16color.svg new file mode 100644 index 0000000..21e28fc --- /dev/null +++ b/assets/icons/error16color.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/icons/forward24.svg b/assets/icons/forward24.svg new file mode 100644 index 0000000..a2fdaba --- /dev/null +++ b/assets/icons/forward24.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/icons/heart24.svg b/assets/icons/heart24.svg new file mode 100644 index 0000000..dd63532 --- /dev/null +++ b/assets/icons/heart24.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/newbubble24.svg b/assets/icons/newbubble24.svg new file mode 100644 index 0000000..b1d72fd --- /dev/null +++ b/assets/icons/newbubble24.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/reply24.svg b/assets/icons/reply24.svg new file mode 100644 index 0000000..7136614 --- /dev/null +++ b/assets/icons/reply24.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/icons/sending16.svg b/assets/icons/sending16.svg new file mode 100644 index 0000000..a74179a --- /dev/null +++ b/assets/icons/sending16.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/sent16.svg b/assets/icons/sent16.svg new file mode 100644 index 0000000..5b7f3fa --- /dev/null +++ b/assets/icons/sent16.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons.md b/icons.md new file mode 100644 index 0000000..9c3dd89 --- /dev/null +++ b/icons.md @@ -0,0 +1,24 @@ +# icons + +- [x] online +- [x] away +- [x] dnd +- [x] xa +- [x] person +- [ ] settings +- [x] sending +- [x] failure +- [x] sent tick +- [x] delivered two ticks +- [x] new message +- [x] heart +- [x] message bubble +- [x] reply +- [x] forward +- [x] attachment +- [ ] (re)send (up arrow) +- [ ] mobile phone +- [ ] default avatar +- [ ] call + +- [ ] add diff --git a/src/icons.rs b/src/icons.rs new file mode 100644 index 0000000..934a0c8 --- /dev/null +++ b/src/icons.rs @@ -0,0 +1,127 @@ +use iced::widget::svg; +use iced::widget::{svg::Handle, Svg}; +use iced::Element; + +pub enum Icon { + AddContact24, + Attachment24, + Away16, + Away16Color, + Bubble16, + Bubble16Color, + Bubble24, + Contact24, + Delivered16, + Dnd16, + Dnd16Color, + Error16Color, + Forward24, + Heart24, + NewBubble24, + Reply24, + Sending16, + Sent16, +} + +impl From for Svg<'_> { + fn from(value: Icon) -> Self { + match value { + Icon::AddContact24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/addcontact24.svg" + ))) + .width(24) + .height(24), + Icon::Attachment24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/attachment24.svg" + ))) + .width(24) + .height(24), + Icon::Away16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/away16.svg" + ))) + .width(16) + .height(16), + Icon::Away16Color => svg(Handle::from_memory(include_bytes!( + "../assets/icons/away16color.svg" + ))) + .width(16) + .height(16), + Icon::Bubble16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/bubble16.svg" + ))) + .width(16) + .height(16), + Icon::Bubble16Color => svg(Handle::from_memory(include_bytes!( + "../assets/icons/bubble16color.svg" + ))) + .width(16) + .height(16), + Icon::Bubble24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/bubble24.svg" + ))) + .width(24) + .height(24), + Icon::Contact24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/contact24.svg" + ))) + .width(24) + .height(24), + Icon::Delivered16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/delivered16.svg" + ))) + .width(16) + .height(16), + Icon::Dnd16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/dnd16.svg" + ))) + .width(16) + .height(16), + Icon::Dnd16Color => svg(Handle::from_memory(include_bytes!( + "../assets/icons/dnd16color.svg" + ))) + .width(16) + .height(16), + Icon::Error16Color => svg(Handle::from_memory(include_bytes!( + "../assets/icons/error16color.svg" + ))) + .width(16) + .height(16), + Icon::Forward24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/forward24.svg" + ))) + .width(24) + .height(24), + Icon::Heart24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/heart24.svg" + ))) + .width(24) + .height(24), + Icon::NewBubble24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/newbubble24.svg" + ))) + .width(24) + .height(24), + Icon::Reply24 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/reply24.svg" + ))) + .width(24) + .height(24), + Icon::Sending16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/sending16.svg" + ))) + .width(16) + .height(16), + Icon::Sent16 => svg(Handle::from_memory(include_bytes!( + "../assets/icons/sent16.svg" + ))) + .width(16) + .height(16), + } + } +} + +impl From for Element<'_, Message> { + fn from(value: Icon) -> Self { + Into::::into(value).into() + } +} diff --git a/src/main.rs b/src/main.rs index 0b8b3b8..106df79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,10 +23,11 @@ use iced::widget::button::Status; use iced::widget::text::{Fragment, IntoFragment, Wrapping}; use iced::widget::{ button, center, checkbox, column, container, horizontal_space, image, mouse_area, opaque, row, - scrollable, stack, text, text_input, toggler, Column, Text, Toggler, + scrollable, stack, text, text_input, toggler, Column, Svg, Text, Toggler, }; use iced::Length::{self, Fill, Shrink}; use iced::{color, stream, Color, Element, Subscription, Task, Theme}; +use icons::Icon; use indexmap::{indexmap, IndexMap}; use jid::JID; use keyring::Entry; @@ -37,9 +38,10 @@ use thiserror::Error; use tokio::sync::mpsc::Sender; use tokio::sync::{mpsc, oneshot}; use tokio_stream::wrappers::ReceiverStream; -use tracing::{error, info}; +use tracing::{debug, error, info}; use uuid::Uuid; +mod icons; mod login_modal; mod message_view; @@ -488,6 +490,7 @@ async fn main() -> iced::Result { Task::stream(stream), ]) } else { + debug!("no auto connect"); Task::batch([ Task::perform( async move { luz_handle1.get_roster_with_users().await }, @@ -524,7 +527,7 @@ async fn main() -> iced::Result { }; iced::application("Macaw", Macaw::update, Macaw::view) .subscription(subscription) - .theme(Macaw::theme) + // .theme(Macaw::theme) .run_with(|| { ( Macaw::new( @@ -698,7 +701,8 @@ impl Macaw { } UpdateMessage::Presence { from, presence } => { // TODO: presence handling - self.presences.insert(from, presence); + info!("got presence from {:?} {:?}", from, presence); + self.presences.insert(from.as_bare(), presence); Task::none() } UpdateMessage::Message { to, message, from } => { @@ -886,7 +890,7 @@ impl Macaw { client.connection_state = ConnectionState::Connecting; let client = client.client.clone(); Task::future(async move { - client.connect().await; + client.connect().await.unwrap(); }) .discard() } @@ -896,7 +900,7 @@ impl Macaw { Account::LoggedIn(client) => { let client = client.client.clone(); Task::future(async move { - client.disconnect(Offline::default()).await; + client.disconnect(Offline::default()).await.unwrap(); }) .discard() } @@ -1105,8 +1109,13 @@ impl Macaw { open = true; } } - let chat_list_item = - chat_list_item(&self.roster, client.files_root(), chat, open); + let chat_list_item = chat_list_item( + &self.presences, + &self.roster, + client.files_root(), + chat, + open, + ); chats_list = chats_list.push(chat_list_item); } } @@ -1288,6 +1297,7 @@ where } fn chat_list_item<'a>( + presences: &HashMap, roster: &HashMap, file_root: &'a Path, chat_list_item: &'a ChatListItem, @@ -1339,36 +1349,37 @@ fn chat_list_item<'a>( latest_message_text = None; } - let avatar_image = if let Some(avatar) = avatar { + let mut avatar_stack = stack([]); + if let Some(avatar) = avatar { let mut path = file_root.join(avatar); path.set_extension("jpg"); info!("got avatar: {:?}", path); - Some(image(path).width(48).height(48)) - } else { - None - }; - let content: Element = if let Some(avatar_image) = avatar_image { - if let Some((message, time)) = latest_message_text { - row![ - avatar_image, - column![ - text(name), - row![ - container(text(message).wrapping(Wrapping::None)) - .clip(true) - .width(Fill), - text(time) - ] - .spacing(8) - .width(Fill) - ] - ] - .into() - } else { - row![avatar_image, text(name)].into() + avatar_stack = avatar_stack.push(image(path).width(48).height(48)); + } + let mut status_icon: Option = None; + if let Some(presence) = presences.get(&chat_list_item.user.jid) { + debug!("found a presence"); + match &presence.presence { + PresenceType::Online(online) => match online.show { + Some(s) => match s { + filamento::presence::Show::Away => status_icon = Some(Icon::Away16Color), + filamento::presence::Show::Chat => status_icon = Some(Icon::Bubble16Color), + filamento::presence::Show::DoNotDisturb => status_icon = Some(Icon::Dnd16Color), + filamento::presence::Show::ExtendedAway => { + status_icon = Some(Icon::Away16Color) + } + }, + None => status_icon = Some(Icon::Bubble16Color), + }, + PresenceType::Offline(offline) => {} } - } else { - if let Some((message, time)) = latest_message_text { + } + if let Some(status_icon) = status_icon { + avatar_stack = avatar_stack.push(Into::::into(status_icon)); + } + let content: Element = if let Some((message, time)) = latest_message_text { + row![ + avatar_stack, column![ text(name), row![ @@ -1380,10 +1391,10 @@ fn chat_list_item<'a>( .spacing(8) .width(Fill) ] - .into() - } else { - text(name).into() - } + ] + .into() + } else { + row![avatar_stack, text(name)].into() }; let mut button = button(content).on_press(Message::ToggleChat(chat_list_item.correspondent().clone())); diff --git a/src/message_view.rs b/src/message_view.rs index e936b69..fdb1a59 100644 --- a/src/message_view.rs +++ b/src/message_view.rs @@ -10,7 +10,7 @@ use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{MacawChat, MacawMessage}; +use crate::{icons::Icon, MacawChat, MacawMessage}; pub struct MessageView { // references chats, users @@ -152,7 +152,7 @@ impl MessageView { .wrapping(text::Wrapping::WordOrGlyph); let message_send_input = row![ text_editor, - button("send").on_press(Message::SendMessage(self.new_message.text())) + button(Icon::NewBubble24).on_press(Message::SendMessage(self.new_message.text())) ] .padding(8); column![ -- cgit