diff --git a/.gitignore b/.gitignore index 62bd1a4..211d5d3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,8 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + + +# Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..41ce9d7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "retrix" +version = "0.1.0" +authors = ["Amanda Graven "] +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" } diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3a97d8f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +use iced::Sandbox; + +pub mod ui; + +fn main() { + ui::Retrix::run(iced::Settings::default()) +} diff --git a/src/ui.rs b/src/ui.rs new file mode 100644 index 0000000..7c327b7 --- /dev/null +++ b/src/ui.rs @@ -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 { + 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(), + } + } +}