2 Commits

Author SHA1 Message Date
94d0ea1cc8 💄 Make all the ChatsWindow main div usable 2023-08-16 22:38:31 +02:00
60f2466411 🎨 Refactor App + add an empty ChatsWindow in a dedicated window 2023-08-16 21:06:28 +02:00
5 changed files with 58 additions and 12 deletions

View File

@@ -0,0 +1,8 @@
use dioxus::prelude::*;
pub fn ChatsWindow(cx: Scope) -> Element {
cx.render(rsx! {
div {
}
})
}

View File

@@ -0,0 +1 @@
pub mod chats_window;

View File

@@ -0,0 +1,22 @@
use dioxus::prelude::*;
use dioxus_std::utils::rw::use_rw;
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());
let is_logged = rw_store.read().unwrap().is_logged;
cx.render(rsx! {
if is_logged {
rsx!(ContactsWindow {rw_store: rw_store})
}
else {
rsx!(Login {rw_store: rw_store})
}
})
}

View File

@@ -1,4 +1,6 @@
pub mod avatar_selector; pub mod avatar_selector;
pub mod chats_window;
pub mod contacts_window; pub mod contacts_window;
pub mod header; pub mod header;
pub mod login; pub mod login;
pub mod main_window;

View File

@@ -2,31 +2,44 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_desktop::Config; use dioxus_desktop::Config;
use dioxus_std::utils::rw::use_rw;
pub mod components; pub mod components;
pub mod matrix_client; pub mod matrix_client;
use crate::base::{AppSettings, Store}; use crate::base::AppSettings;
use crate::components::contacts_window::contacts_window::ContactsWindow; use crate::components::chats_window::chats_window::ChatsWindow;
use crate::components::login::Login; use crate::components::main_window::MainWindow;
mod base; mod base;
fn App(cx: Scope<AppSettings>) -> Element { fn App(cx: Scope<AppSettings>) -> Element {
println!("App rendering");
use_shared_state_provider(cx, || cx.props.clone()); use_shared_state_provider(cx, || cx.props.clone());
let rw_store = use_rw(cx, || Store::new()); 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%;
width: 100%;
let is_logged = rw_store.read().unwrap().is_logged; margin: 0;
}
#main, #bodywrap {
height: 100%;
width: 100%;
}
</style>
"#
.to_owned(),
);
chats_window.new_window(chats_dom, window_cfg);
cx.render(rsx! { cx.render(rsx! {
if is_logged { MainWindow {}
rsx!(ContactsWindow {rw_store: rw_store})
}
else {
rsx!(Login {rw_store: rw_store})
}
}) })
} }