🎨 Isolate infra and ui components

The src/base.rs is still to be reworked.
This commit is contained in:
2024-04-04 14:27:58 +02:00
parent 92bf860101
commit 0ce0764204
67 changed files with 64 additions and 59 deletions

View File

@@ -14,7 +14,7 @@ fn main() {
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
let style_src_path = PathBuf::from("src/_base.scss"); let style_src_path = PathBuf::from("src/ui/_base.scss");
let style_dst_path = Path::new(&out_dir).join("style_vars.rs"); let style_dst_path = Path::new(&out_dir).join("style_vars.rs");
export_color_variables(&style_src_path, &style_dst_path) export_color_variables(&style_src_path, &style_dst_path)

View File

@@ -6,9 +6,9 @@ use futures_util::stream::StreamExt;
use std::cell::RefCell; use std::cell::RefCell;
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use crate::matrix_interface::client::{Client, RoomEvent}; use crate::infrastructure::messaging::matrix::client::{Client, RoomEvent};
use crate::matrix_interface::requester::{Receivers, Requester}; use crate::infrastructure::messaging::matrix::requester::{Receivers, Requester};
use crate::matrix_interface::worker_tasks::LoginStyle; use crate::infrastructure::messaging::matrix::worker_tasks::LoginStyle;
use dioxus::prelude::*; use dioxus::prelude::*;
use matrix_sdk::{ use matrix_sdk::{
room::{Room as MatrixRoom, RoomMember}, room::{Room as MatrixRoom, RoomMember},
@@ -17,7 +17,7 @@ use matrix_sdk::{
use tokio::select; use tokio::select;
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use crate::components::chats_window::interface::Interface as ChatsWinInterface; use crate::ui::components::chats_window::interface::Interface as ChatsWinInterface;
// #[derive(Clone, Debug)] // #[derive(Clone, Debug)]
// pub struct UserInfo { // pub struct UserInfo {

View File

@@ -1,13 +0,0 @@
pub mod avatar_selector;
pub mod button;
pub mod chats_window;
pub mod contacts_window;
pub mod header;
pub mod icons;
pub mod loading;
pub mod login;
pub mod main_window;
pub mod modal;
pub mod spinner;
pub mod text_input;
pub mod wallpaper;

View File

@@ -1 +0,0 @@
pub(crate) mod datasources;

View File

@@ -0,0 +1,3 @@
pub(crate) mod client;
pub(crate) mod requester;
pub(crate) mod worker_tasks;

View File

@@ -0,0 +1 @@
pub(crate) mod matrix;

View File

@@ -0,0 +1,2 @@
pub(crate) mod messaging;
pub(crate) mod services;

View File

@@ -1,8 +1,7 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
mod components; mod infrastructure;
mod data; mod ui;
mod matrix_interface;
mod utils; mod utils;
use dioxus::prelude::*; use dioxus::prelude::*;
@@ -11,9 +10,9 @@ use tracing::{debug, Level};
use crate::base::{login, sync_rooms}; use crate::base::{login, sync_rooms};
use crate::base::{APP_SETTINGS, ROOMS, SESSION}; use crate::base::{APP_SETTINGS, ROOMS, SESSION};
use crate::components::loading::LoadingPage; use crate::ui::components::loading::LoadingPage;
use crate::components::login::Login; use crate::ui::components::login::Login;
use crate::components::main_window::MainWindow; use crate::ui::components::main_window::MainWindow;
mod base; mod base;

View File

@@ -1,3 +0,0 @@
pub mod client;
pub mod requester;
pub mod worker_tasks;

View File

@@ -1,6 +1,6 @@
use dioxus::prelude::*; use dioxus::prelude::*;
turf::style_sheet!("src/components/avatar_selector.scss"); turf::style_sheet!("src/ui/components/avatar_selector.scss");
pub fn AvatarSelector() -> Element { pub fn AvatarSelector() -> Element {
rsx! { rsx! {

View File

@@ -1,7 +1,7 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_free_icons::{Icon, IconShape}; use dioxus_free_icons::{Icon, IconShape};
turf::style_sheet!("src/components/button.scss"); turf::style_sheet!("src/ui/components/button.scss");
#[derive(PartialEq, Clone, Props)] #[derive(PartialEq, Clone, Props)]
struct _ButtonProps { struct _ButtonProps {

View File

@@ -4,10 +4,10 @@ use tracing::error;
use super::edit_section::EditSection; use super::edit_section::EditSection;
use crate::base::{sync_messages, ROOMS}; use crate::base::{sync_messages, ROOMS};
use crate::components::avatar_selector::AvatarSelector; use crate::ui::components::avatar_selector::AvatarSelector;
use crate::components::icons::DownArrowIcon; use crate::ui::components::icons::DownArrowIcon;
turf::style_sheet!("src/components/chats_window/conversation.scss"); turf::style_sheet!("src/ui/components/chats_window/conversation.scss");
#[component] #[component]
pub(super) fn Conversation(room_id: OwnedRoomId) -> Element { pub(super) fn Conversation(room_id: OwnedRoomId) -> Element {

View File

@@ -1,6 +1,6 @@
use dioxus::prelude::*; use dioxus::prelude::*;
turf::style_sheet!("src/components/chats_window/edit_section.scss"); turf::style_sheet!("src/ui/components/chats_window/edit_section.scss");
pub fn EditSection() -> Element { pub fn EditSection() -> Element {
rsx! { rsx! {

View File

@@ -1,8 +1,9 @@
mod conversation; mod conversation;
mod edit_section; mod edit_section;
pub mod interface;
mod navbar; mod navbar;
pub(crate) mod interface;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@@ -12,13 +13,13 @@ use tokio::sync::broadcast::Receiver;
use tracing::{debug, error}; use tracing::{debug, error};
use crate::base::{sync_rooms, Room, ROOMS}; use crate::base::{sync_rooms, Room, ROOMS};
use crate::matrix_interface::requester::Receivers; use crate::infrastructure::messaging::matrix::requester::Receivers;
use conversation::Conversation; use conversation::Conversation;
use navbar::Navbar; use navbar::Navbar;
use interface::{Interface, Tasks}; use interface::{Interface, Tasks};
turf::style_sheet!("src/components/chats_window/chats_window.scss"); turf::style_sheet!("src/ui/components/chats_window/chats_window.scss");
#[derive(Props, Clone, PartialEq)] #[derive(Props, Clone, PartialEq)]
pub struct ChatsWindowProps { pub struct ChatsWindowProps {

View File

@@ -1,7 +1,7 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use tracing::debug; use tracing::debug;
turf::style_sheet!("src/components/chats_window/navbar.scss"); turf::style_sheet!("src/ui/components/chats_window/navbar.scss");
pub fn Navbar() -> Element { pub fn Navbar() -> Element {
debug!("Navbar rendering"); debug!("Navbar rendering");

View File

@@ -3,11 +3,11 @@ use std::rc::Rc;
use dioxus::prelude::*; use dioxus::prelude::*;
use tracing::debug; use tracing::debug;
use crate::components::contacts_window::contacts_section::{ use crate::ui::components::contacts_window::contacts_section::{
filter_people_conversations, filter_room_conversations, ContactsSection, filter_people_conversations, filter_room_conversations, ContactsSection,
}; };
turf::style_sheet!("src/components/contacts_window/contacts.scss"); turf::style_sheet!("src/ui/components/contacts_window/contacts.scss");
pub fn Contacts() -> Element { pub fn Contacts() -> Element {
debug!("Contacts rendering"); debug!("Contacts rendering");

View File

@@ -8,9 +8,9 @@ use matrix_sdk::{ruma::OwnedRoomId, RoomState};
use tracing::debug; use tracing::debug;
use crate::base::{ByIdRooms, Room, CHATS_WIN_INTERFACE, ROOMS}; use crate::base::{ByIdRooms, Room, CHATS_WIN_INTERFACE, ROOMS};
use crate::components::chats_window::interface::Interface as ChatsWindowInterface; use crate::ui::components::chats_window::interface::Interface as ChatsWindowInterface;
turf::style_sheet!("src/components/contacts_window/contacts_section.scss"); turf::style_sheet!("src/ui/components/contacts_window/contacts_section.scss");
fn ContactsArrow() -> Element { fn ContactsArrow() -> Element {
rsx! { rsx! {

View File

@@ -5,10 +5,10 @@ mod user_infos;
use dioxus::prelude::*; use dioxus::prelude::*;
use tracing::debug; use tracing::debug;
use crate::components::contacts_window::contacts::Contacts; use crate::ui::components::contacts_window::contacts::Contacts;
use crate::components::contacts_window::user_infos::UserInfos; use crate::ui::components::contacts_window::user_infos::UserInfos;
turf::style_sheet!("src/components/contacts_window/contacts_window.scss"); turf::style_sheet!("src/ui/components/contacts_window/contacts_window.scss");
pub fn ContactsWindow() -> Element { pub fn ContactsWindow() -> Element {
debug!("ContactsWindow rendering"); debug!("ContactsWindow rendering");

View File

@@ -1,10 +1,10 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use tracing::debug; use tracing::debug;
use crate::components::avatar_selector::AvatarSelector; use crate::ui::components::avatar_selector::AvatarSelector;
use crate::components::icons::DownArrowIcon; use crate::ui::components::icons::DownArrowIcon;
turf::style_sheet!("src/components/contacts_window/user_infos.scss"); turf::style_sheet!("src/ui/components/contacts_window/user_infos.scss");
static MESSAGE_PLACEHOLDER: &str = "<Enter a personal message>"; static MESSAGE_PLACEHOLDER: &str = "<Enter a personal message>";

View File

@@ -1,6 +1,6 @@
use dioxus::prelude::*; use dioxus::prelude::*;
turf::style_sheet!("src/components/header.scss"); turf::style_sheet!("src/ui/components/header.scss");
pub fn Header() -> Element { pub fn Header() -> Element {
rsx! { rsx! {

View File

@@ -2,7 +2,7 @@ use dioxus::prelude::*;
use dioxus_free_icons::icons::md_navigation_icons::MdArrowDropDown; use dioxus_free_icons::icons::md_navigation_icons::MdArrowDropDown;
use dioxus_free_icons::{Icon, IconShape}; use dioxus_free_icons::{Icon, IconShape};
turf::style_sheet!("src/components/icons.scss"); turf::style_sheet!("src/ui/components/icons.scss");
include!(concat!(env!("OUT_DIR"), "/style_vars.rs")); include!(concat!(env!("OUT_DIR"), "/style_vars.rs"));

View File

@@ -4,7 +4,7 @@ use tracing::debug;
use super::spinner::Spinner; use super::spinner::Spinner;
use super::wallpaper::Wallpaper; use super::wallpaper::Wallpaper;
turf::style_sheet!("src/components/loading.scss"); turf::style_sheet!("src/ui/components/loading.scss");
pub fn LoadingPage() -> Element { pub fn LoadingPage() -> Element {
debug!("LoadingPage rendering"); debug!("LoadingPage rendering");

View File

@@ -10,7 +10,9 @@ use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, Validati
use zxcvbn::zxcvbn; use zxcvbn::zxcvbn;
use crate::base::{Session, SESSION}; use crate::base::{Session, SESSION};
use crate::data::datasources::random_svg_generators::{generate_random_svg_shape, ShapeConfig}; use crate::infrastructure::services::random_svg_generators::{
generate_random_svg_shape, ShapeConfig,
};
use super::button::{LoginButton, RegisterButton}; use super::button::{LoginButton, RegisterButton};
use super::modal::{Modal, Severity}; use super::modal::{Modal, Severity};
@@ -29,7 +31,7 @@ use style::{
COLOR_TERNARY_150, COLOR_TERNARY_80, COLOR_TERNARY_90, COLOR_TERNARY_150, COLOR_TERNARY_80, COLOR_TERNARY_90,
}; };
turf::style_sheet!("src/components/login.scss"); turf::style_sheet!("src/ui/components/login.scss");
const BACKGROUND_COLORS_STR: &str = formatcp!( const BACKGROUND_COLORS_STR: &str = formatcp!(
"{COLOR_PRIMARY_150},{COLOR_PRIMARY_140},\ "{COLOR_PRIMARY_150},{COLOR_PRIMARY_140},\

View File

@@ -2,7 +2,7 @@ use dioxus::prelude::*;
use tracing::debug; use tracing::debug;
use crate::base::SESSION; use crate::base::SESSION;
use crate::components::contacts_window::ContactsWindow; use crate::ui::components::contacts_window::ContactsWindow;
pub fn MainWindow() -> Element { pub fn MainWindow() -> Element {
debug!("MainWindow rendering"); debug!("MainWindow rendering");

13
src/ui/components/mod.rs Normal file
View File

@@ -0,0 +1,13 @@
pub(crate) mod avatar_selector;
pub(crate) mod button;
pub(crate) mod chats_window;
pub(crate) mod contacts_window;
pub(crate) mod header;
pub(crate) mod icons;
pub(crate) mod loading;
pub(crate) mod login;
pub(crate) mod main_window;
pub(crate) mod modal;
pub(crate) mod spinner;
pub(crate) mod text_input;
pub(crate) mod wallpaper;

View File

@@ -5,7 +5,7 @@ use dioxus::prelude::*;
use super::button::{ErrorButton, SuccessButton, WarningButton}; use super::button::{ErrorButton, SuccessButton, WarningButton};
use crate::data::datasources::random_svg_generators::{ use crate::infrastructure::services::random_svg_generators::{
generate_random_svg_avatar, AvatarConfig, AvatarFeeling, generate_random_svg_avatar, AvatarConfig, AvatarFeeling,
}; };
@@ -13,7 +13,7 @@ include!(concat!(env!("OUT_DIR"), "/style_vars.rs"));
use style::{COLOR_CRITICAL_100, COLOR_SUCCESS_100, COLOR_WARNING_100}; use style::{COLOR_CRITICAL_100, COLOR_SUCCESS_100, COLOR_WARNING_100};
turf::style_sheet!("src/components/modal.scss"); turf::style_sheet!("src/ui/components/modal.scss");
#[derive(Clone, Copy, Eq, PartialEq, Hash)] #[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub enum Severity { pub enum Severity {

View File

@@ -1,7 +1,7 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_free_icons::{Icon, IconShape}; use dioxus_free_icons::{Icon, IconShape};
turf::style_sheet!("src/components/spinner.scss"); turf::style_sheet!("src/ui/components/spinner.scss");
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
struct _Spinner; struct _Spinner;

View File

@@ -5,7 +5,7 @@ use dioxus_free_icons::Icon;
use super::icons::Pyramid; use super::icons::Pyramid;
turf::style_sheet!("src/components/text_input.scss"); turf::style_sheet!("src/ui/components/text_input.scss");
pub trait InputPropsData {} pub trait InputPropsData {}

View File

@@ -1,6 +1,6 @@
use dioxus::prelude::*; use dioxus::prelude::*;
turf::style_sheet!("src/components/wallpaper.scss"); turf::style_sheet!("src/ui/components/wallpaper.scss");
pub fn Wallpaper() -> Element { pub fn Wallpaper() -> Element {
rsx! { rsx! {

1
src/ui/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub(crate) mod components;