diff --git a/resources/icon_jump_to_top.svg b/resources/icon_jump_to_top.svg new file mode 100644 index 00000000..c14e3a1a --- /dev/null +++ b/resources/icon_jump_to_top.svg @@ -0,0 +1,38 @@ + + + + + + diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 360b528c..b1ee0688 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -50,6 +50,7 @@ live_design! { import crate::shared::avatar::Avatar; import crate::shared::text_or_image::TextOrImage; import crate::shared::html_or_plaintext::*; + import crate::shared::icon_button::*; import crate::profile::user_profile::UserProfileSlidingPane; import crate::shared::typing_animation::TypingAnimation; import crate::shared::icon_button::RobrixIconButton; @@ -649,15 +650,16 @@ 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}, + margin: {right: 15.0, bottom: 0}, visible: false, - - jump_to_bottom_button = { + jump_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} } + padding: 15, + margin: {bottom : 20} + icon_walk: {width: 20, height: 10, margin: {top: 0, right: 100} } // draw a circular background for the button draw_bg: { instance background_color: #edededee, @@ -668,6 +670,79 @@ live_design! { sdf.fill_keep(self.background_color); return sdf.result } + + } + draw_icon: { + instance color: #000 + instance color_hover: #000 + // 180.0: point upwards + uniform rotation_angle: 180.0, + } + animator: { + jump_button = { + default: down + down = { + redraw: true, + from: { all: Forward {duration: 2.0} } + ease: ExpDecay {d1: 0.80, d2: 0.97} + apply: { draw_icon: {rotation_angle: 0.0} } + } + up = { + redraw: true, + from: { all: Forward {duration: 0.5} } + ease: ExpDecay {d1: 0.80, d2: 0.97} + apply: { draw_icon: {rotation_angle: 180.0} } + } + } + } + } + // Badge overlay for unread messages + unread_notification_badge = { + width: 12, height: 12, + abs_pos: vec2(-20.0, 15.0) + visible: true, + show_bg: true, + draw_bg: { + instance background_color: (#58DC6C) + + 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; + } + } + } + // Badge overlay for unread messages + unread_message_badge = { + width: 20, height: 20, + abs_pos: vec2(-15.0, 72.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 =