Intial things

main
Amanda Graven 2020-11-23 07:52:07 +01:00
parent 5bd9375d3a
commit 675b788f81
Signed by: amanda
GPG Key ID: 45C461CDC9286390
4 changed files with 100 additions and 0 deletions

5
.gitignore vendored
View File

@ -10,3 +10,8 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# Added by cargo
/target

11
Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "retrix"
version = "0.1.0"
authors = ["Amanda Graven <amanda@amandag.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
iced = "0.1"
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "27c6f30" }

7
src/main.rs Normal file
View File

@ -0,0 +1,7 @@
use iced::Sandbox;
pub mod ui;
fn main() {
ui::Retrix::run(iced::Settings::default())
}

77
src/ui.rs Normal file
View File

@ -0,0 +1,77 @@
use iced::{
text_input::{self, TextInput},
Column, Container, Element, Row, Sandbox, Settings, Text,
};
#[derive(Debug, Clone)]
pub enum Retrix {
Prompt {
user_input: text_input::State,
user: String,
password_input: text_input::State,
password: String,
server_input: text_input::State,
server: String,
},
LoggedIn,
}
#[derive(Debug, Clone)]
pub enum Message {
SetUser(String),
SetPassword(String),
SetServer(String),
}
impl Sandbox for Retrix {
type Message = Message;
fn new() -> Self {
Retrix::Prompt {
user_input: text_input::State::new(),
user: String::new(),
password_input: text_input::State::new(),
password: String::new(),
server_input: text_input::State::new(),
server: String::new(),
}
}
fn title(&self) -> String {
String::from("Retrix matrix client")
}
fn update(&mut self, message: Self::Message) {}
fn view(&mut self) -> Element<Self::Message> {
match *self {
Retrix::Prompt {
ref mut user_input,
ref user,
ref mut password_input,
ref password,
ref mut server_input,
ref server,
} => {
let content = Column::new()
.push(Text::new("Username"))
.push(TextInput::new(user_input, "Username", user, |val| {
Message::SetUser(val)
}))
.push(Text::new("Password"))
.push(TextInput::new(
password_input,
"Password",
password,
|val| Message::SetPassword(val),
))
.push(Text::new("Homeserver"))
.push(TextInput::new(server_input, "Server", server, |val| {
Message::SetServer(val)
}));
content.into()
}
_ => Text::new("Beep").into(),
}
}
}