diff --git a/src/components/chats_window/chats_window.rs b/src/components/chats_window/chats_window.rs new file mode 100644 index 0000000..e542ab2 --- /dev/null +++ b/src/components/chats_window/chats_window.rs @@ -0,0 +1,8 @@ +use dioxus::prelude::*; + +pub fn ChatsWindow(cx: Scope) -> Element { + cx.render(rsx! { + div { + } + }) +} diff --git a/src/components/chats_window/mod.rs b/src/components/chats_window/mod.rs new file mode 100644 index 0000000..42160ea --- /dev/null +++ b/src/components/chats_window/mod.rs @@ -0,0 +1 @@ +pub mod chats_window; diff --git a/src/components/main_window.rs b/src/components/main_window.rs new file mode 100644 index 0000000..fb04127 --- /dev/null +++ b/src/components/main_window.rs @@ -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}) + } + }) +} diff --git a/src/components/mod.rs b/src/components/mod.rs index 3b346fc..0f37658 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,4 +1,6 @@ pub mod avatar_selector; +pub mod chats_window; pub mod contacts_window; pub mod header; pub mod login; +pub mod main_window; diff --git a/src/main.rs b/src/main.rs index e702e7c..4a62dc5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,31 +2,27 @@ 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, Store}; -use crate::components::contacts_window::contacts_window::ContactsWindow; -use crate::components::login::Login; +use crate::base::AppSettings; +use crate::components::chats_window::chats_window::ChatsWindow; +use crate::components::main_window::MainWindow; mod base; fn App(cx: Scope) -> Element { + println!("App rendering"); + use_shared_state_provider(cx, || cx.props.clone()); - let rw_store = use_rw(cx, || Store::new()); - - let is_logged = rw_store.read().unwrap().is_logged; + let chats_window = dioxus_desktop::use_window(cx); + let chats_dom = VirtualDom::new(ChatsWindow); + chats_window.new_window(chats_dom, Default::default()); cx.render(rsx! { - if is_logged { - rsx!(ContactsWindow {rw_store: rw_store}) - } - else { - rsx!(Login {rw_store: rw_store}) - } + MainWindow {} }) }