From bff777226caa6d85f825af36670ea763d8569a0d Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Fri, 10 Jan 2025 01:39:47 -0800 Subject: [PATCH 1/5] WIP added login status modal, but it's mispositioned, and the login screen's width padding is missing --- Cargo.lock | 52 ++-- Cargo.toml | 3 +- src/app.rs | 23 +- src/login/login_screen.rs | 494 +++++++++++++++++--------------- src/login/login_status_modal.rs | 170 +++++++++++ src/login/mod.rs | 2 + src/persistent_state.rs | 15 +- src/sliding_sync.rs | 77 +++-- 8 files changed, 536 insertions(+), 300 deletions(-) create mode 100644 src/login/login_status_modal.rs diff --git a/Cargo.lock b/Cargo.lock index a92678a6..0757d838 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1981,7 +1981,7 @@ dependencies = [ [[package]] name = "makepad-derive-live" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "makepad-derive-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-micro-proc-macro", ] @@ -1998,7 +1998,7 @@ dependencies = [ [[package]] name = "makepad-derive-widget" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", "makepad-micro-proc-macro", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "makepad-draw" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "ab_glyph_rasterizer", "fxhash", @@ -2024,17 +2024,17 @@ dependencies = [ [[package]] name = "makepad-futures" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-futures-legacy" version = "0.7.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-html" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", ] @@ -2042,7 +2042,7 @@ dependencies = [ [[package]] name = "makepad-http" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-jni-sys" @@ -2053,7 +2053,7 @@ checksum = "9775cbec5fa0647500c3e5de7c850280a88335d1d2d770e5aa2332b801ba7064" [[package]] name = "makepad-live-compiler" version = "0.5.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-derive-live", "makepad-live-tokenizer", @@ -2063,7 +2063,7 @@ dependencies = [ [[package]] name = "makepad-live-id" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id-macros", ] @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "makepad-live-id-macros" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-micro-proc-macro", ] @@ -2079,7 +2079,7 @@ dependencies = [ [[package]] name = "makepad-live-tokenizer" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", "makepad-math", @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "makepad-markdown" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", ] @@ -2097,17 +2097,17 @@ dependencies = [ [[package]] name = "makepad-math" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-micro-proc-macro" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-micro-serde" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-id", "makepad-micro-serde-derive", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "makepad-micro-serde-derive" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-micro-proc-macro", ] @@ -2124,12 +2124,12 @@ dependencies = [ [[package]] name = "makepad-objc-sys" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "makepad-platform" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "hilog-sys", "makepad-android-state", @@ -2152,7 +2152,7 @@ dependencies = [ [[package]] name = "makepad-rustybuzz" version = "0.8.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2167,7 +2167,7 @@ dependencies = [ [[package]] name = "makepad-shader-compiler" version = "0.5.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-live-compiler", ] @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "makepad-vector" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "resvg", "ttf-parser", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "makepad-wasm-bridge" version = "0.4.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-derive-wasm-bridge", "makepad-live-id", @@ -2193,7 +2193,7 @@ dependencies = [ [[package]] name = "makepad-widgets" version = "0.6.0" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "makepad-derive-widget", "makepad-draw", @@ -2207,7 +2207,7 @@ dependencies = [ [[package]] name = "makepad-zune-png" version = "0.4.10" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" dependencies = [ "zune-core", "zune-inflate", @@ -4324,7 +4324,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttf-parser" version = "0.21.1" -source = "git+https://github.com/kevinaboos/makepad?branch=textflow_pub_states#b97dfcbc2046bcc9707c57ea9c7a5a810bc54489" +source = "git+https://github.com/makepad/makepad?branch=rik#77fbf5fc3c56f435aa2cd887a3f815fdd29c149b" [[package]] name = "typenum" diff --git a/Cargo.toml b/Cargo.toml index 3d679f7f..101be9ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,7 @@ version = "0.0.1-pre-alpha" metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q=" [dependencies] -# makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" } -makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "textflow_pub_states" } +makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" } ## Including this crate automatically configures all `robius-*` crates to work with Makepad. robius-use-makepad = "0.1.1" diff --git a/src/app.rs b/src/app.rs index e4d97aab..edadaf14 100644 --- a/src/app.rs +++ b/src/app.rs @@ -160,19 +160,19 @@ impl LiveRegister for App { } impl LiveHook for App { - fn after_update_from_doc(&mut self, _cx:&mut Cx) { - self.update_login_visibility(); + fn after_update_from_doc(&mut self, cx: &mut Cx) { + self.update_login_visibility(cx); } } impl MatchEvent for App { - fn handle_startup(&mut self, _cx: &mut Cx) { + fn handle_startup(&mut self, cx: &mut Cx) { // Initialize the project directory here from the main UI thread // such that background threads/tasks will be able to can access it. let _app_data_dir = crate::app_data_dir(); log!("App::handle_startup(): app_data_dir: {:?}", _app_data_dir); - self.update_login_visibility(); + self.update_login_visibility(cx); log!("App::handle_startup(): starting matrix sdk loop"); crate::sliding_sync::start_matrix_tokio().unwrap(); @@ -183,7 +183,7 @@ impl MatchEvent for App { if let Some(LoginAction::LoginSuccess) = action.downcast_ref() { log!("Received LoginAction::LoginSuccess, hiding login view."); self.app_state.logged_in = true; - self.update_login_visibility(); + self.update_login_visibility(cx); self.ui.redraw(cx); } @@ -276,10 +276,15 @@ impl AppMain for App { } impl App { - fn update_login_visibility(&self) { - let login_visible = !self.app_state.logged_in; - self.ui.view(id!(login_screen_view)).set_visible(login_visible); - self.ui.view(id!(home_screen_view)).set_visible(!login_visible); + fn update_login_visibility(&self, cx: &mut Cx) { + let show_login = !self.app_state.logged_in; + self.ui.view(id!(login_screen_view)).set_visible(show_login); + self.ui.view(id!(home_screen_view)).set_visible(!show_login); + if !show_login { + self.ui + .modal(id!(login_screen_view.login_screen.login_status_modal)) + .close(cx); + } } } diff --git a/src/login/login_screen.rs b/src/login/login_screen.rs index 1542a99d..24f89266 100644 --- a/src/login/login_screen.rs +++ b/src/login/login_screen.rs @@ -5,6 +5,8 @@ use matrix_sdk::ruma::api::client::session::get_login_types::v3::IdentityProvide use crate::sliding_sync::{submit_async_request, LoginByPassword, LoginRequest, MatrixRequest}; +use super::login_status_modal::{LoginStatusModalAction, LoginStatusModalWidgetExt}; + live_design! { use link::theme::*; use link::shaders::*; @@ -13,6 +15,7 @@ live_design! { use crate::shared::helpers::*; use crate::shared::styles::*; use crate::shared::icon_button::*; + use crate::login::login_status_modal::*; IMG_APP_LOGO = dep("crate://self/resources/robrix_logo_alpha.png") ICON_SEARCH = dep("crate://self/resources/icons/search.svg") @@ -44,6 +47,7 @@ live_design! { } } + pub LoginScreen = {{LoginScreen}} { width: Fill, height: Fill show_bg: true, @@ -53,210 +57,229 @@ live_design! { // Note: *do NOT* vertically center this, it will break scrolling. align: {x: 0.5} - { - width: Fit, height: Fit - flow: Down - align: {x: 0.5, y: 0.5} - padding: 30 - margin: 40 - spacing: 15.0 - - show_bg: true, - draw_bg: { - color: (COLOR_SECONDARY) - } - - logo_image = { - fit: Smallest, - width: 80 - source: (IMG_APP_LOGO), - } + { + width: 250, height: Fit, + align: {x: 0.5} + flow: Overlay, - title =