From 7bc190eabb728f8d83a948992f796477cc262337 Mon Sep 17 00:00:00 2001 From: greysoh Date: Sun, 28 Apr 2024 21:22:30 -0400 Subject: [PATCH] chore: Changes UI design. --- gui/src/components/log_in.rs | 14 +++----------- gui/src/main.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/gui/src/components/log_in.rs b/gui/src/components/log_in.rs index 1f7c986..d488001 100644 --- a/gui/src/components/log_in.rs +++ b/gui/src/components/log_in.rs @@ -6,7 +6,8 @@ use crate::ApplicationState; pub fn main(state: &mut ApplicationState, api: &api::NextAPIClient, ctx: &eframe::egui::Context) { egui::Window::new("Log In").show(ctx, move |ui| { - ui.heading("Login"); + ui.set_max_width(275.0); + ui.horizontal(|ui| { ui.label("Email: "); ui.text_edit_singleline(&mut state.username); @@ -24,7 +25,7 @@ pub fn main(state: &mut ApplicationState, api: &api::NextAPIClient, ctx: &eframe match res.token { Some(x) => { let mut token = token_clone.lock().unwrap(); - *token = x; + *token = x; }, None => { let mut token = token_clone.lock().unwrap(); @@ -33,14 +34,5 @@ pub fn main(state: &mut ApplicationState, api: &api::NextAPIClient, ctx: &eframe } })); } - - match state.token.lock() { - Ok(x) => { - ui.label(format!("Token: {:?}", *x)); - }, - Err(_) => { - ui.label(format!("No token.")); - } - } }); } \ No newline at end of file diff --git a/gui/src/main.rs b/gui/src/main.rs index c8bbcb5..abc8a7f 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -32,7 +32,14 @@ fn main() -> Result<(), eframe::Error> { eframe::run_simple_native("NextNet GUI", options, move |ctx, _frame| { egui::CentralPanel::default().show(ctx, |_ui| { - components::log_in::main(&mut app_state, &api, ctx); + let token_clone = Arc::clone(&app_state.token); + let token = token_clone.lock().unwrap(); + + if *token == "".to_string() { + components::log_in::main(&mut app_state, &api, ctx); + } else { + // ... + } }); }) } \ No newline at end of file