🎨 Refactor App + add an empty ChatsWindow in a dedicated window
This commit is contained in:
8
src/components/chats_window/chats_window.rs
Normal file
8
src/components/chats_window/chats_window.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
pub fn ChatsWindow(cx: Scope) -> Element {
|
||||||
|
cx.render(rsx! {
|
||||||
|
div {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
1
src/components/chats_window/mod.rs
Normal file
1
src/components/chats_window/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod chats_window;
|
22
src/components/main_window.rs
Normal file
22
src/components/main_window.rs
Normal 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})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@@ -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;
|
||||||
|
22
src/main.rs
22
src/main.rs
@@ -2,31 +2,27 @@
|
|||||||
|
|
||||||
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 is_logged = rw_store.read().unwrap().is_logged;
|
chats_window.new_window(chats_dom, Default::default());
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
if is_logged {
|
MainWindow {}
|
||||||
rsx!(ContactsWindow {rw_store: rw_store})
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rsx!(Login {rw_store: rw_store})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user