Skip to content

Commit

Permalink
Support sending markdown messages, plus other misc improvements.
Browse files Browse the repository at this point in the history
* README: add Robrix chat room link and table of supported host+target pairs.
* Disable useless log messages, e.g., app lifecycle events.
* Make text input in a room timeline view much nicer visually
  with better colors and default formatting.
  • Loading branch information
kevinaboos committed Apr 12, 2024
1 parent e90fa94 commit 60495e8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ eyeball-im = "0.4.2"
futures-util = "0.3"
imbl = { version = "2.0.0", features = ["serde"] } # same as matrix-sdk-ui
imghdr = "0.7.0"
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "experimental-sliding-sync", "e2e-encryption", "automatic-room-key-forwarding", "sqlite", "rustls-tls", "bundled-sqlite" ] }
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "experimental-sliding-sync", "e2e-encryption", "automatic-room-key-forwarding", "markdown", "sqlite", "rustls-tls", "bundled-sqlite" ] }
matrix-sdk-ui = { git = "https://github.com/matrix-org/matrix-rust-sdk", default-features = false, features = [ "e2e-encryption", "rustls-tls" ] }
rangemap = "1.5.0"
tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] }
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# Robrix: a Rust Matrix client built atop [Robius](https://github.com/project-robius)

[![Robrix Matrix Chat](https://img.shields.io/matrix/robius-robrix%3Amatrix.org?server_fqdn=matrix.org&style=flat&logo=matrix&label=Robrix Matrix%20Chat&color=B7410E)](https://matrix.to/#/#robius-robrix:matrix.org)

Robrix is a Matrix chat client written in Rust to demonstrate the functionality of the Robius, a framework for multi-platform application development in Rust.

> ⚠️ Robrix is just getting started and is not yet fully functional.
>
> It is currently based on the [Makepad WeChat example](https://github.com/project-robius/makepad_wechat); only the first "Rooms" tab is in use.

| Host OS | Target Platform | Builds? | Runs? |
| ------- | --------------- | ------- | ----- |
| macOS | macOS |||
| macOS | Android |||
| macOS | iOS |||
| Linux | Linux |||
| Linux | Android |||
| Windows | Windows |||
| Windows | Android |||



## Building and Running

First, [install Rust](https://www.rust-lang.org/tools/install).
Expand Down
3 changes: 3 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ impl MatchEvent for App {
log!("App::handle_startup(): starting matrix sdk loop");
crate::sliding_sync::start_matrix_tokio().unwrap();
}
/*
fn handle_shutdown(&mut self, _cx: &mut Cx) {
log!("App::handle_shutdown()");
}
Expand All @@ -287,6 +288,8 @@ impl MatchEvent for App {
fn handle_app_lost_focus(&mut self, _cx: &mut Cx) {
log!("App::handle_app_lost_focus()");
}
*/

fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
self.ui.radio_button_set(ids!(
mobile_modes.tab1,
Expand Down
25 changes: 19 additions & 6 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,28 @@ live_design! {
message_input = <TextInput> {
width: Fill, height: Fit, margin: 0
align: {y: 0.5}
empty_message: "Write a message..."
empty_message: "Write a message (in Markdown) ..."
draw_bg: {
color: #fff
color: #F9F9F9
}
draw_text: {
text_style:<MESSAGE_TEXT_STYLE>{},

color: (MESSAGE_TEXT_COLOR),
text_style: <MESSAGE_TEXT_STYLE>{},

fn get_color(self) -> vec4 {
return #ccc
return mix(
mix(
mix(
#xFFFFFF55,
#xFFFFFF88,
self.hover
),
self.color,
self.focus
),
#BBBBBB,
self.is_empty
)
}
}

Expand Down Expand Up @@ -553,7 +566,7 @@ impl Widget for RoomScreen {
log!("Sending message to room {}: {:?}", room_id, entered_text);
submit_async_request(MatrixRequest::SendMessage {
room_id,
message: RoomMessageEventContent::text_plain(entered_text),
message: RoomMessageEventContent::text_markdown(entered_text),
// TODO: support replies to specific messages, attaching mentions, rich text (html), etc.
});
}
Expand Down

0 comments on commit 60495e8

Please sign in to comment.