From 24be468fb95b5254994be9471c24eceb474f059a Mon Sep 17 00:00:00 2001 From: alanpoon Date: Thu, 10 Oct 2024 23:37:07 +0800 Subject: [PATCH 1/4] added unread_message_badge --- src/home/room_screen.rs | 64 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 37aaa5fd..73293a22 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -656,26 +656,56 @@ live_design! { flow: Down, align: {x: 1.0, y: 1.0}, margin: {right: 15.0, bottom: 15.0}, - visible: false, + visible: true, jump_to_bottom_button = { 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 + icon_walk: {width: 20, height: 20, margin: {top: 10, right: 4.5} }, draw_bg: { instance background_color: #edededee, 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 } } } - } + // Badge overlay for unread messages + unread_message_badge = { + width: 20, height: 20, + margin: {top: -10.0, right: 15.0}, + visible: true, + show_bg: true, + draw_bg: { + instance background_color: (#5D5E5E) + + 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.background_color); + return sdf.result; + } + } + + // Text to display the unread message count + label =