Compare commits
2 Commits
2159c6adeb
...
94d0ea1cc8
Author | SHA1 | Date | |
---|---|---|---|
94d0ea1cc8
|
|||
60f2466411
|
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 chats_window;
|
||||
pub mod contacts_window;
|
||||
pub mod header;
|
||||
pub mod login;
|
||||
pub mod main_window;
|
||||
|
37
src/main.rs
37
src/main.rs
@@ -2,31 +2,44 @@
|
||||
|
||||
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<AppSettings>) -> Element {
|
||||
println!("App rendering");
|
||||
|
||||
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! {
|
||||
if is_logged {
|
||||
rsx!(ContactsWindow {rw_store: rw_store})
|
||||
}
|
||||
else {
|
||||
rsx!(Login {rw_store: rw_store})
|
||||
}
|
||||
MainWindow {}
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user