2 Commits

Author SHA1 Message Date
4988054dae 💄 Display ChatsWindow only once the user logged 2023-08-21 21:43:42 +02:00
f79bf329a5 🐛 Fix AvatarSelector shift (Login) 2023-08-21 21:29:09 +02:00
4 changed files with 25 additions and 16 deletions

View File

@@ -75,7 +75,7 @@ pub fn Login<'a>(cx: Scope, rw_store: &'a UseRw<Store>) -> Element {
div {
class: ClassName::BODY,
div {
class: ClassName::AVATAR_SELECTOR,
class: ClassName::AVATAR_SELECTOR_CONTAINER,
AvatarSelector {},
},

View File

@@ -33,9 +33,11 @@
border-color: red;
}
.avatarSelector {
.avatar-selector-container {
height: 30%;
width: 100%;
padding-left: 25%;
}

View File

@@ -1,14 +1,12 @@
use dioxus::prelude::*;
use dioxus_std::utils::rw::use_rw;
use dioxus_std::utils::rw::UseRw;
use crate::base::Store;
use crate::components::contacts_window::contacts_window::ContactsWindow;
use crate::components::login::Login;
#[inline_props]
pub fn MainWindow(cx: Scope) -> Element {
let rw_store = use_rw(cx, || Store::new());
pub fn MainWindow<'a>(cx: Scope, rw_store: &'a UseRw<Store>) -> Element {
let is_logged = rw_store.read().unwrap().is_logged;
cx.render(rsx! {

View File

@@ -2,25 +2,32 @@
use dioxus::prelude::*;
use dioxus_desktop::Config;
use dioxus_std::utils::rw::use_rw;
pub mod components;
pub mod matrix_client;
use crate::base::AppSettings;
use crate::base::Store;
use crate::components::chats_window::chats_window::ChatsWindow;
use crate::components::main_window::MainWindow;
mod base;
fn App(cx: Scope<AppSettings>) -> Element {
println!("App rendering");
use_shared_state_provider(cx, || cx.props.clone());
let chats_window = dioxus_desktop::use_window(cx);
let chats_dom = VirtualDom::new(ChatsWindow);
let window_cfg = Config::default().with_custom_head(
r#"
let rw_store = use_rw(cx, || Store::new());
let is_logged = rw_store.read().unwrap().is_logged;
let chats_win_state = use_state(cx, || None);
if is_logged && chats_win_state.is_none() {
let chats_window = dioxus_desktop::use_window(cx);
let chats_dom = VirtualDom::new(ChatsWindow);
let window_cfg = Config::default().with_custom_head(
r#"
<style type="text/css">
html, body {
height: 100%;
@@ -34,12 +41,14 @@ fn App(cx: Scope<AppSettings>) -> Element {
}
</style>
"#
.to_owned(),
);
chats_window.new_window(chats_dom, window_cfg);
.to_owned(),
);
let chats_window_desktop_service = chats_window.new_window(chats_dom, window_cfg);
chats_win_state.set(Some(chats_window_desktop_service));
}
cx.render(rsx! {
MainWindow {}
MainWindow {rw_store: rw_store}
})
}