Intial things
This commit is contained in:
		
							parent
							
								
									5bd9375d3a
								
							
						
					
					
						commit
						675b788f81
					
				
					 4 changed files with 100 additions and 0 deletions
				
			
		
							
								
								
									
										7
									
								
								src/main.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/main.rs
									
										
									
									
									
										Normal 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
									
								
							
							
						
						
									
										77
									
								
								src/ui.rs
									
										
									
									
									
										Normal 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(), | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue