From a11884ef2c1ed30d4aef08cc9773f1d0d341f70d Mon Sep 17 00:00:00 2001 From: alanpoon Date: Fri, 11 Oct 2024 15:03:50 +0800 Subject: [PATCH 1/6] added send_pagination_request_based_on_scroll_pos --- src/home/room_screen.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 904f86c9..74cc8a51 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -1269,6 +1269,7 @@ impl Widget for RoomScreen { } // Handle sending any read receipts for the current logged-in user. + self.send_pagination_request_based_on_scroll_pos(cx, actions); self.send_user_read_receipts_based_on_scroll_pos(cx, actions); // Handle the cancel reply button being clicked. @@ -1529,6 +1530,7 @@ impl RoomScreen { /// Redraws this RoomScreen view if any updates were applied. fn process_timeline_updates(&mut self, cx: &mut Cx) { let portal_list = self.portal_list(id!(list)); + let top_space = self.view(id!(top_space)); let curr_first_id = portal_list.first_id(); let Some(tl) = self.tl_state.as_mut() else { return }; @@ -1613,14 +1615,14 @@ impl RoomScreen { // log!("Timeline::handle_event(): changed_indices: {changed_indices:?}, items len: {}\ncontent drawn: {:#?}\nprofile drawn: {:#?}", items.len(), tl.content_drawn_since_last_update, tl.profile_drawn_since_last_update); } tl.items = new_items; + done_loading = true; } TimelineUpdate::TimelineStartReached => { log!("Timeline::handle_event(): timeline start reached for room {}", tl.room_id); tl.fully_paginated = true; - done_loading = true; } TimelineUpdate::PaginationIdle => { - done_loading = true; + top_space.set_visible(true); } TimelineUpdate::EventDetailsFetched {event_id, result } => { if let Err(_e) = result { @@ -1670,8 +1672,7 @@ impl RoomScreen { } if done_loading { - log!("TODO: hide topspace loading animation for room {}", tl.room_id); - // TODO FIXME: hide TopSpace loading animation, set it to invisible. + top_space.set_visible(false); } if num_updates > 0 { // log!("Applied {} timeline updates for room {}, redrawing with {} items...", num_updates, tl.room_id, tl.items.len()); @@ -1913,6 +1914,25 @@ impl RoomScreen { self.show_timeline(cx); self.label(id!(room_name)).set_text(&self.room_name); } + + /// Send Pagination Request when the scroll position is at the top + fn send_pagination_request_based_on_scroll_pos( + &mut self, + cx: &mut Cx, + actions: &ActionsBuf, + ) { + let portal_list = self.portal_list(id!(list)); + //stopped scrolling and when scroll position is at top + if portal_list.scrolled(actions) { + return; + } + + let Some(room_id) = self.room_id.as_ref() else { return }; + if portal_list.scroll_position() == 0.0 { + submit_async_request(MatrixRequest::PaginateRoomTimeline { room_id: room_id.clone(), num_events: 50, forwards: false}); + } + + } } impl RoomScreenRef { From bb93b3926637b9dd736e8487053eb2ddf8a2c742 Mon Sep 17 00:00:00 2001 From: alanpoon Date: Fri, 11 Oct 2024 15:12:09 +0800 Subject: [PATCH 2/6] cleanup --- src/home/room_screen.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 74cc8a51..4e675a13 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -1268,8 +1268,9 @@ impl Widget for RoomScreen { } } - // Handle sending any read receipts for the current logged-in user. + // Set visibility of loading message banner based of pagination logic self.send_pagination_request_based_on_scroll_pos(cx, actions); + // Handle sending any read receipts for the current logged-in user. self.send_user_read_receipts_based_on_scroll_pos(cx, actions); // Handle the cancel reply button being clicked. From c871da7d72379b9039d4d609efcbf3dad63a3dec Mon Sep 17 00:00:00 2001 From: Demolemon11 Date: Fri, 11 Oct 2024 17:24:14 +0800 Subject: [PATCH 3/6] Fix dependencies for apt --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a30550b3..f0b4ac9a 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,11 @@ The following table shows which host systems can currently be used to build Robr 2. If you're building on **Linux** or **WSL** on Windows, install the required dependencies. Otherwise, proceed to step 3. * `openssl`, `clang`/`libclang`, `binfmt`, `Xcursor`/`X11`, `asound`/`pulse`. - + On a Debian-like Linux distro (e.g., Ubuntu), run the following: ```sh sudo apt-get update - sudo apt-get install libssl-dev libsqlite3-dev pkg-config llvm clang libclang-dev binfmt-support libxcursor-dev libx11-dev libasound2-dev libpulse-dev + sudo apt-get install libssl-dev libsqlite3-dev pkg-config binfmt-support libxcursor-dev libx11-dev libasound2-dev libpulse-dev ``` 3. Then, build and run Robrix (you can optionally add `--release` after `run`): @@ -78,7 +78,7 @@ cargo run -- 'USERNAME' 'PASSWORD' ['HOMESERVER_URL'] * API version 33 or higher is required, which is Android 13 and up. -## Feature status tracker +## Feature status tracker These are generally sorted in order of priority. If you're interested in helping out with anything here, please reach out via a GitHub issue or on our Robius matrix channel. @@ -93,7 +93,7 @@ These are generally sorted in order of priority. If you're interested in helping - [ ] Loading animation while waiting for pagination request: https://github.com/project-robius/robrix/issues/109 - [x] Stable positioning of events during simple timeline update - [x] Stable positioning of events during complex/multi-part timeline update -- [ ] Re-spawn timeline as focused on an old event after a full timeline clear: https://github.com/project-robius/robrix/issues/103 +- [ ] Re-spawn timeline as focused on an old event after a full timeline clear: https://github.com/project-robius/robrix/issues/103 - [x] Display simple text-only messages - [x] Display image messages (PNG, JPEG) - [x] Rich text formatting for message bodies From f7b3de4626fb080f0ac9ccfe2e882a2a1b1fa648 Mon Sep 17 00:00:00 2001 From: ZhangHanDong Date: Fri, 11 Oct 2024 20:35:24 +0800 Subject: [PATCH 4/6] the fontfallthrough needs to be specified --- src/home/room_screen.rs | 19 ++++++------------- src/shared/styles.rs | 31 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 904f86c9..1bcad0e0 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -64,18 +64,11 @@ live_design! { ICO_ADD = dep("crate://self/resources/icon_add.svg") ICO_CLOSE = dep("crate://self/resources/icons/close.svg") ICO_JUMP_TO_BOTTOM = dep("crate://self/resources/icon_jump_to_bottom.svg") - + ICO_LOCATION_PERSON = dep("crate://self/resources/icons/location-person.svg") - TEXT_SUB = { + TEXT_SUB = { font_size: (10), - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} - } - - TEXT_P = { - font_size: (12), - height_factor: 1.65, - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} } COLOR_BG = #xfff8ee @@ -1028,13 +1021,13 @@ impl RoomScreen{ return; } let first_index = portal_list.first_id(); - + let Some(tl_state) = self.tl_state.as_mut() else { return }; let Some(room_id) = self.room_id.as_ref() else { return }; if let Some(ref mut index) = tl_state.prev_first_index { // to detect change of scroll when scroll ends - if *index != first_index { - // scroll changed + if *index != first_index { + // scroll changed self.fully_read_timer = cx.start_interval(5.0); let time_now = std::time::Instant::now(); if first_index > *index { @@ -1823,7 +1816,7 @@ impl RoomScreen { if first_time_showing_room { self.process_timeline_updates(cx); } - + self.redraw(cx); } diff --git a/src/shared/styles.rs b/src/shared/styles.rs index 43686f40..8546ec7f 100644 --- a/src/shared/styles.rs +++ b/src/shared/styles.rs @@ -2,35 +2,39 @@ use makepad_widgets::*; live_design! { + import makepad_widgets::theme_desktop_dark::*; ICON_BLOCK_USER = dep("crate://self/resources/icons/forbidden.svg") ICON_CHECKMARK = dep("crate://self/resources/icons/checkmark.svg") ICON_CLOSE = dep("crate://self/resources/icons/close.svg") - TITLE_TEXT = { + + TITLE_TEXT = { font_size: (13), - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} } - REGULAR_TEXT = { + REGULAR_TEXT = { font_size: (10), - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} } - TEXT_SUB = { + TEXT_SUB = { font_size: (8), height_factor: 1.5, - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} } + TEXT_P = { + font_size: (12), + height_factor: 1.65, + } + + USERNAME_FONT_SIZE = 11 USERNAME_TEXT_COLOR = #x2 - USERNAME_TEXT_STYLE = { - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-SemiBold.ttf")} + USERNAME_TEXT_STYLE = { font_size: (USERNAME_FONT_SIZE), - // height_factor: 1.5, } + TYPING_NOTICE_TEXT_COLOR = #121570 MESSAGE_FONT_SIZE = 11 @@ -39,8 +43,7 @@ live_design! { MESSAGE_TEXT_HEIGHT_FACTOR = 1.55 // This font should only be used for plaintext labels. Don't use this for Html content, // as the Html widget sets different fonts for different text styles (e.g., bold, italic). - MESSAGE_TEXT_STYLE = { - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} + MESSAGE_TEXT_STYLE = { font_size: (MESSAGE_FONT_SIZE), height_factor: (MESSAGE_TEXT_HEIGHT_FACTOR), line_spacing: (MESSAGE_TEXT_LINE_SPACING), @@ -51,15 +54,15 @@ live_design! { SMALL_STATE_FONT_SIZE = 9.0 SMALL_STATE_TEXT_COLOR = #x888 SMALL_STATE_TEXT_STYLE = { - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} + font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")}, + font2: { path: dep("crate://makepad-widgets/resources/LXGWWenKaiRegular.ttf") }, font_size: (SMALL_STATE_FONT_SIZE), height_factor: 1.3, } TIMESTAMP_FONT_SIZE = 8.5 TIMESTAMP_TEXT_COLOR = #x999 - TIMESTAMP_TEXT_STYLE = { - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")} + TIMESTAMP_TEXT_STYLE = { font_size: (TIMESTAMP_FONT_SIZE), } From afa94b83439a9cbd7cd1191003f74721fda67480 Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Fri, 11 Oct 2024 10:36:33 -0700 Subject: [PATCH 5/6] Ensure we always use Makepad's default font fallback --- src/home/room_screen.rs | 4 ---- src/shared/styles.rs | 13 ++----------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 1bcad0e0..fb0faa56 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -67,10 +67,6 @@ live_design! { ICO_LOCATION_PERSON = dep("crate://self/resources/icons/location-person.svg") - TEXT_SUB = { - font_size: (10), - } - COLOR_BG = #xfff8ee COLOR_BRAND = #x5 COLOR_BRAND_HOVER = #x3 diff --git a/src/shared/styles.rs b/src/shared/styles.rs index 8546ec7f..32dd470f 100644 --- a/src/shared/styles.rs +++ b/src/shared/styles.rs @@ -18,16 +18,9 @@ live_design! { } TEXT_SUB = { - font_size: (8), - height_factor: 1.5, - } - - TEXT_P = { - font_size: (12), - height_factor: 1.65, + font_size: (10), } - USERNAME_FONT_SIZE = 11 USERNAME_TEXT_COLOR = #x2 USERNAME_TEXT_STYLE = { @@ -53,9 +46,7 @@ live_design! { SMALL_STATE_FONT_SIZE = 9.0 SMALL_STATE_TEXT_COLOR = #x888 - SMALL_STATE_TEXT_STYLE = { - font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")}, - font2: { path: dep("crate://makepad-widgets/resources/LXGWWenKaiRegular.ttf") }, + SMALL_STATE_TEXT_STYLE = { font_size: (SMALL_STATE_FONT_SIZE), height_factor: 1.3, } From 3dd291c9d2e854b062dc7a9e0c05dbc0300550c6 Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Fri, 11 Oct 2024 15:28:05 -0700 Subject: [PATCH 6/6] Update to latest `robius-location` for linux build compat. Disable send location button by default; it will be enabled upon receiving a valid location update. --- Cargo.lock | 2 +- src/home/room_screen.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 00aa9dc8..19d146a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3096,7 +3096,7 @@ dependencies = [ [[package]] name = "robius-location" version = "0.1.0" -source = "git+https://github.com/project-robius/robius-location#d47bd115f50247b98787efc72236dc65ab9c53bc" +source = "git+https://github.com/project-robius/robius-location#befe4f9b1d0bde0ba210af3b94aed809fc51525f" dependencies = [ "android-build", "cfg-if", diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index fb0faa56..e1cd6206 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -734,6 +734,8 @@ live_design! { } send_location_button = { + // disabled by default; will be enabled upon receiving valid location update. + enabled: false, padding: {left: 15, right: 15} draw_icon: { svg_file: (ICO_SEND)