From 7086884ee47462add4fd21a36d16267d1afd6479 Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Fri, 8 Nov 2024 18:18:56 -0800 Subject: [PATCH] Show JTB button with unread message badge upon new out-of-view messages When new messages are received in the currently-displayed room timeline, it can be hard for the user to tell/know when a new message has arrived. This commit provides a subtle visual cue that shows a small dot on the jump to bottom button, indicating that new unread messages have arrived beneath the current viewport range. In the future, we'll also add a label with the exact count of unread messages below the current viewport. --- Cargo.lock | 29 ------------------ Cargo.toml | 3 +- src/home/room_screen.rs | 65 ++++++++++++++++++++++++++++++++++++----- src/home/rooms_list.rs | 1 + src/shared/styles.rs | 2 ++ src/sliding_sync.rs | 14 +++++++-- 6 files changed, 74 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 202981ac..6ffca98f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1919,7 +1919,6 @@ dependencies = [ [[package]] name = "makepad-derive-live" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -1928,7 +1927,6 @@ dependencies = [ [[package]] name = "makepad-derive-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-micro-proc-macro", ] @@ -1936,7 +1934,6 @@ dependencies = [ [[package]] name = "makepad-derive-widget" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -1945,7 +1942,6 @@ dependencies = [ [[package]] name = "makepad-draw" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "ab_glyph_rasterizer", "fxhash", @@ -1962,17 +1958,14 @@ dependencies = [ [[package]] name = "makepad-futures" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-futures-legacy" version = "0.7.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-html" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", ] @@ -1980,7 +1973,6 @@ dependencies = [ [[package]] name = "makepad-http" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-jni-sys" @@ -1991,7 +1983,6 @@ checksum = "9775cbec5fa0647500c3e5de7c850280a88335d1d2d770e5aa2332b801ba7064" [[package]] name = "makepad-live-compiler" version = "0.5.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-derive-live", "makepad-live-tokenizer", @@ -2001,7 +1992,6 @@ dependencies = [ [[package]] name = "makepad-live-id" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id-macros", ] @@ -2009,7 +1999,6 @@ dependencies = [ [[package]] name = "makepad-live-id-macros" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-micro-proc-macro", ] @@ -2017,7 +2006,6 @@ dependencies = [ [[package]] name = "makepad-live-tokenizer" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", "makepad-math", @@ -2027,7 +2015,6 @@ dependencies = [ [[package]] name = "makepad-markdown" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", ] @@ -2035,17 +2022,14 @@ dependencies = [ [[package]] name = "makepad-math" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-micro-proc-macro" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-micro-serde" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-id", "makepad-micro-serde-derive", @@ -2054,7 +2038,6 @@ dependencies = [ [[package]] name = "makepad-micro-serde-derive" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-micro-proc-macro", ] @@ -2062,12 +2045,10 @@ dependencies = [ [[package]] name = "makepad-objc-sys" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "makepad-platform" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "hilog-sys", "makepad-android-state", @@ -2090,7 +2071,6 @@ dependencies = [ [[package]] name = "makepad-rustybuzz" version = "0.8.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2105,7 +2085,6 @@ dependencies = [ [[package]] name = "makepad-shader-compiler" version = "0.5.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-live-compiler", ] @@ -2113,7 +2092,6 @@ dependencies = [ [[package]] name = "makepad-vector" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "resvg", "ttf-parser", @@ -2122,7 +2100,6 @@ dependencies = [ [[package]] name = "makepad-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-derive-wasm-bridge", "makepad-live-id", @@ -2131,7 +2108,6 @@ dependencies = [ [[package]] name = "makepad-widgets" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-derive-widget", "makepad-draw", @@ -2145,7 +2121,6 @@ dependencies = [ [[package]] name = "makepad-zune-core" version = "0.2.14" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "bitflags 2.6.0", ] @@ -2153,7 +2128,6 @@ dependencies = [ [[package]] name = "makepad-zune-inflate" version = "0.2.54" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "simd-adler32", ] @@ -2161,7 +2135,6 @@ dependencies = [ [[package]] name = "makepad-zune-jpeg" version = "0.3.17" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-zune-core", ] @@ -2169,7 +2142,6 @@ dependencies = [ [[package]] name = "makepad-zune-png" version = "0.2.1" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" dependencies = [ "makepad-zune-core", "makepad-zune-inflate", @@ -4195,7 +4167,6 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttf-parser" version = "0.21.1" -source = "git+https://github.com/kevinaboos/makepad?branch=widget_uid_hashable#92a3af42107b070b7a52f3cb85112ab14bb57c19" [[package]] name = "typenum" diff --git a/Cargo.toml b/Cargo.toml index 5c1cb07b..611883e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,8 @@ version = "0.0.1-pre-alpha" metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q=" [dependencies] -makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "widget_uid_hashable" } +# makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "widget_uid_hashable" } +makepad-widgets = { path = "../makepad/widgets" } ## Including this crate automatically configures all `robius-*` crates to work with Makepad. robius-use-makepad = "0.1.1" diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 784513d1..cb5d4776 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -668,29 +668,59 @@ live_design! { jump_to_bottom_view = { width: Fill, height: Fill, - flow: Down, + flow: Overlay, align: {x: 1.0, y: 1.0}, - margin: {right: 15.0, bottom: 15.0}, visible: false, jump_to_bottom_button = { + margin: {right: 15.0, bottom: 15.0}, width: 50, height: 50, draw_icon: {svg_file: (ICO_JUMP_TO_BOTTOM)}, icon_walk: {width: 20, height: 20, margin: {top: 10, right: 4.5} } // draw a circular background for the button draw_bg: { - instance background_color: #edededee, + instance background_color: #edededce, 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.x, c.x) + sdf.circle(c.x, c.x, c.x); sdf.fill_keep(self.background_color); return sdf.result } } } - } + // A badge overlay on the jump to bottom button showing unread messages + unread_message_badge = { + width: 12, height: 12, + margin: {right: 33.0, bottom: 11.0}, + visible: false, + + show_bg: true, + draw_bg: { + color: (COLOR_UNREAD_MESSAGE_BADGE) + 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.x, c.x); + sdf.fill_keep(self.color); + return sdf.result; + } + } + + // // Label that displays the unread message count + // unread_messages_count =