Skip to content

Commit

Permalink
fix: update project
Browse files Browse the repository at this point in the history
  • Loading branch information
brynblack committed Jun 29, 2024
1 parent d1070c5 commit fe7e929
Show file tree
Hide file tree
Showing 8 changed files with 2,824 additions and 1,655 deletions.
4,271 changes: 2,663 additions & 1,608 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ strip = true
lto = true

[dependencies]
anyhow = "1.0.74"
chrono = "0.4.24"
env_logger = "0.10.0"
iced = { version = "0.8.0", features = ["svg", "tokio"] }
log = "0.4.20"
matrix-sdk = "0.6.2"
once_cell = "1.17.1"
tokio = { version = "1.31.0", features = ["macros", "rt-multi-thread"] }
anyhow = "1.0.86"
chrono = "0.4.38"
env_logger = "0.11.3"
iced = { version = "0.12.1", features = ["svg", "tokio"] }
log = "0.4.22"
matrix-sdk = "0.7.1"
once_cell = "1.19.0"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# ReoChat
A blazingly fast modern Matrix client written in pure Rust.
# reochat
A blazingly fast modern Matrix client written in Rust.

## Contents
* [Installation](#installation)
* [License](#license)

## Installation
Building/running the package:

```sh
cargo build
cargo run
```

Installing to system:
```sh
cargo install
```


## License
The source code for this project is licensed under the MIT license. You may find the conditions of the license [here](LICENSE.md).
61 changes: 61 additions & 0 deletions flake.lock

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

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default = with pkgs; mkShell {
nativeBuildInputs = [
pkg-config
openssl
sqlite
];
};
});
}
55 changes: 26 additions & 29 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use iced::{
};
use log::warn;
use once_cell::sync::Lazy;
use std::{env, process};
use std::{env, process, sync::Arc};

#[derive(Default)]
struct Flags {
Expand Down Expand Up @@ -139,28 +139,21 @@ impl Application for Client {
}
}

fn view(&self) -> iced::Element<'_, Self::Message, iced::Renderer<Self::Theme>> {
fn view(&self) -> iced::Element<'_, Self::Message, Self::Theme, iced::Renderer> {
let messages = Container::new(
Scrollable::new(
column(
self.messages
.clone()
.into_iter()
.map(|msg| {
column![
row![
Text::new(msg.sender),
Text::new(format!("{}", msg.timestamp.format("%H:%M")))
.size(12)
]
.align_items(iced::Alignment::Center)
.spacing(8),
Text::new(msg.contents)
]
.into()
})
.collect(),
)
column(self.messages.clone().into_iter().map(|msg| {
column![
row![
Text::new(msg.sender),
Text::new(format!("{}", msg.timestamp.format("%H:%M"))).size(12)
]
.align_items(iced::Alignment::Center)
.spacing(8),
Text::new(msg.contents)
]
.into()
}))
.spacing(8)
.padding(Padding::from([0, 20, 0, 0]))
.width(Length::Fill),
Expand All @@ -173,7 +166,8 @@ impl Application for Client {

let composer = Container::new(
row![
TextInput::new("Message", &self.compose_value, ClientMessage::ComposerTyped)
TextInput::new("Message", &self.compose_value)
.on_input(ClientMessage::ComposerTyped)
.style(theme::TextInput::Custom(Box::new(style::TextInputComposer)))
.on_submit(ClientMessage::MessageSubmitted)
.padding(Padding {
Expand Down Expand Up @@ -218,12 +212,15 @@ impl Application for Client {
}

fn theme(&self) -> Self::Theme {
Theme::Custom(Box::new(Custom::new(theme::Palette {
background: Color::BLACK,
text: Color::WHITE,
primary: color!(0x2c6bee),
success: Color::TRANSPARENT,
danger: Color::TRANSPARENT,
})))
Theme::Custom(Arc::new(Custom::new(
"default".to_string(),
theme::Palette {
background: Color::BLACK,
text: Color::WHITE,
primary: color!(0x2c6bee),
success: Color::TRANSPARENT,
danger: Color::TRANSPARENT,
},
)))
}
}
3 changes: 2 additions & 1 deletion src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ pub async fn login(
.await?;

client
.matrix_auth()
.login_username(&username, &password)
.initial_device_display_name("ReoChat")
.initial_device_display_name(env!("CARGO_PKG_NAME"))
.send()
.await?;

Expand Down
25 changes: 18 additions & 7 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ impl button::StyleSheet for ButtonComposerSend {

fn active(&self, style: &Self::Style) -> button::Appearance {
button::Appearance {
background: style.palette().primary.into(),
border_radius: 24.0,
background: iced::Background::Color(style.palette().primary).into(),
border: iced::Border::with_radius(24.0),
..Default::default()
}
}

fn hovered(&self, _style: &Self::Style) -> button::Appearance {
button::Appearance {
background: color!(0x004fee).into(),
border_radius: 24.0,
background: iced::Background::Color(color!(0x004fee)).into(),
border: iced::Border::with_radius(24.0),
..Default::default()
}
}
Expand All @@ -34,9 +34,8 @@ impl text_input::StyleSheet for TextInputComposer {
fn active(&self, _style: &Self::Style) -> text_input::Appearance {
text_input::Appearance {
background: Background::Color(color!(0x4c4c4c)),
border_radius: 24.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: iced::Border::with_radius(24.0),
icon_color: Color::TRANSPARENT,
}
}

Expand All @@ -57,4 +56,16 @@ impl text_input::StyleSheet for TextInputComposer {
fn selection_color(&self, _style: &Self::Style) -> iced::Color {
color!(0x0000ff)
}

fn disabled_color(&self, _style: &Self::Style) -> Color {
color!(0x969696)
}

fn disabled(&self, _style: &Self::Style) -> text_input::Appearance {
text_input::Appearance {
background: Background::Color(color!(0x4c4c4c)),
border: iced::Border::with_radius(24.0),
icon_color: Color::TRANSPARENT,
}
}
}

0 comments on commit fe7e929

Please sign in to comment.