From 75316c2a098032a4e70f16720cd1939048cb17d9 Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Thu, 8 Feb 2024 15:42:54 -0800 Subject: [PATCH] Add condensed text and image message views for a more compact timeline UI --- src/home/room_screen.rs | 230 ++++++++++++++++++---------------------- src/shared/avatar.rs | 2 +- src/sliding_sync.rs | 2 + 3 files changed, 107 insertions(+), 127 deletions(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index e317a2b1..96b257db 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -6,7 +6,6 @@ use std::{ops::DerefMut, sync::{Arc, Mutex}, collections::BTreeMap}; use imbl::Vector; use makepad_widgets::*; use matrix_sdk::ruma::{ - MilliSecondsSinceUnixEpoch, events::{ AnySyncTimelineEvent, AnySyncMessageLikeEvent, @@ -17,8 +16,7 @@ use matrix_sdk::ruma::{ join_rules::JoinRule, message::{MessageType, RoomMessageEventContent}, MediaSource, }, SyncMessageLikeEvent, - }, - OwnedRoomId, + }, uint, MilliSecondsSinceUnixEpoch, OwnedRoomId, }; use matrix_sdk_ui::timeline::{ self, @@ -232,6 +230,7 @@ live_design! { draw_text: { text_style: {}, color: (COLOR_META_TEXT) + wrap: Ellipsis, } text: "" } @@ -246,119 +245,75 @@ live_design! { text: "" } - { - margin: {top: 13.0, bottom: 5.0} - } + // { + // margin: {top: 13.0, bottom: 5.0} + // } {} } } } - // The view used for each static image-based message event in a room's timeline. - // This excludes stickers and other animated GIFs, video clips, audio clips, etc. - ImageMessage = { - width: Fill, - height: Fit, - margin: 0.0 - flow: Down, - padding: 0.0, - spacing: 0.0 - - body = { - width: Fill, - height: Fit - flow: Right, - padding: 10.0, - spacing: 10.0 - + // The view used for a condensed message that came right after another message + // from the same sender, and thus doesn't need to display the sender's profile again. + CondensedMessage = { + body = { + padding: { top: 5.0, bottom: 5.0, left: 10.0, right: 10.0 }, profile = { align: {x: 0.5, y: 0.0} // centered horizontally, top aligned width: 65.0, height: Fit, - margin: {top: 7.5} flow: Down, - avatar = { - width: 50., - height: 50. - // draw_bg: { - // fn pixel(self) -> vec4 { - // let sdf = Sdf2d::viewport(self.pos * self.rect_size); - // let c = self.rect_size * 0.5; - // sdf.circle(c.x, c.y, c.x - 2.) - // sdf.fill_keep(self.get_color()); - // sdf.stroke((COLOR_PROFILE_CIRCLE), 1); - // return sdf.result - // } - // } - } - timestamp = { } - datestamp = { - padding: { top: 5.0 } - } + timestamp = { padding: {top: 3.0} } } content = { width: Fill, - height: Fit + height: Fit, flow: Down, - padding: 0.0 - username =