Skip to content

Commit

Permalink
Merge branch 'main' into typing_notice_animation#155
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoon committed Oct 12, 2024
2 parents 5c10893 + 18237da commit 177d323
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`):
Expand Down Expand Up @@ -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.

Expand All @@ -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
Expand Down
52 changes: 32 additions & 20 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,8 @@ 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 = {
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")}
}
ICO_LOCATION_PERSON = dep("crate://self/resources/icons/location-person.svg")

COLOR_BG = #xfff8ee
COLOR_BRAND = #x5
Expand Down Expand Up @@ -746,6 +735,8 @@ live_design! {
}

send_location_button = <RobrixIconButton> {
// disabled by default; will be enabled upon receiving valid location update.
enabled: false,
padding: {left: 15, right: 15}
draw_icon: {
svg_file: (ICO_SEND)
Expand Down Expand Up @@ -1036,13 +1027,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 {
Expand Down Expand Up @@ -1276,6 +1267,8 @@ impl Widget for RoomScreen {
}
}

// 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);

Expand Down Expand Up @@ -1548,6 +1541,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 };

Expand Down Expand Up @@ -1633,14 +1627,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 {
Expand Down Expand Up @@ -1686,8 +1680,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());
Expand Down Expand Up @@ -1847,7 +1840,7 @@ impl RoomScreen {
if first_time_showing_room {
self.process_timeline_updates(cx);
}

self.redraw(cx);
}

Expand Down Expand Up @@ -1937,6 +1930,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});
}

}
/// Start Typing Notice animation that fades away
pub fn start_typing_notice_animation(&mut self, cx: &mut Cx) {
self.animator_play(cx, id!(typing_notice.collapse));
Expand Down
28 changes: 11 additions & 17 deletions src/shared/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@ 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 = <THEME_FONT_REGULAR>{
font_size: (13),
font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")}
}

REGULAR_TEXT = {
REGULAR_TEXT = <THEME_FONT_REGULAR>{
font_size: (10),
font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")}
}

TEXT_SUB = {
font_size: (8),
height_factor: 1.5,
font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-Text.ttf")}
TEXT_SUB = <THEME_FONT_REGULAR>{
font_size: (10),
}

USERNAME_FONT_SIZE = 11
USERNAME_TEXT_COLOR = #x2
USERNAME_TEXT_STYLE = {
font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-SemiBold.ttf")}
USERNAME_TEXT_STYLE = <THEME_FONT_BOLD>{
font_size: (USERNAME_FONT_SIZE),
// height_factor: 1.5,
}


TYPING_NOTICE_TEXT_COLOR = #121570

MESSAGE_FONT_SIZE = 11
Expand All @@ -39,8 +36,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 = <THEME_FONT_REGULAR>{
font_size: (MESSAGE_FONT_SIZE),
height_factor: (MESSAGE_TEXT_HEIGHT_FACTOR),
line_spacing: (MESSAGE_TEXT_LINE_SPACING),
Expand All @@ -50,16 +46,14 @@ 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")}
SMALL_STATE_TEXT_STYLE = <THEME_FONT_REGULAR>{
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 = <THEME_FONT_REGULAR>{
font_size: (TIMESTAMP_FONT_SIZE),
}

Expand Down

0 comments on commit 177d323

Please sign in to comment.