Finished splashscreen and main navigation with bottom nav bar

This commit is contained in:
Franklin 2023-03-01 17:18:11 -04:00
parent ae6694bba6
commit 36438e1e3b
9 changed files with 67 additions and 13 deletions

14
Cargo.lock generated
View File

@ -715,6 +715,19 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "dev-communicators"
version = "0.1.0"
source = "git+https://git.franklinblanco.dev/franklinblanco/dev-communicators.git#16f9b31a7099caf86abe4c0ce1859b2ed714d9e6"
dependencies = [
"actix-web-utils",
"dev-dtos",
"err",
"reqwest",
"serde",
"tokio",
]
[[package]] [[package]]
name = "dev-dtos" name = "dev-dtos"
version = "0.1.0" version = "0.1.0"
@ -1370,6 +1383,7 @@ dependencies = [
"chat-types", "chat-types",
"chrono", "chrono",
"chrono-tz", "chrono-tz",
"dev-communicators",
"dev-dtos", "dev-dtos",
"err", "err",
"futures", "futures",

View File

@ -31,7 +31,10 @@ futures-util = "0.3.26"
# internal deps # internal deps
err = { git = "https://git.franklinblanco.dev/franklinblanco/err.git" } err = { git = "https://git.franklinblanco.dev/franklinblanco/err.git" }
league-types = { git = "https://git.franklinblanco.dev/franklinblanco/league-types.git" } league-types = { git = "https://git.franklinblanco.dev/franklinblanco/league-types.git" }
dev-dtos = { git = "https://git.franklinblanco.dev/franklinblanco/user-svc-dtos-rust.git" } dev-dtos = { git = "https://git.franklinblanco.dev/franklinblanco/user-svc-dtos-rust.git" }
dev-communicators = { git = "https://git.franklinblanco.dev/franklinblanco/dev-communicators.git" }
chat-types = { git = "https://git.franklinblanco.dev/franklinblanco/chat-types.git" } chat-types = { git = "https://git.franklinblanco.dev/franklinblanco/chat-types.git" }
chat-communicators = { git = "https://git.franklinblanco.dev/franklinblanco/chat-communicators.git" } chat-communicators = { git = "https://git.franklinblanco.dev/franklinblanco/chat-communicators.git" }

View File

@ -1,11 +1,11 @@
use std::sync::{Arc}; use std::{sync::{Arc}, thread, time::Duration};
use chat_types::{dto::server_in::ServerMessageIn, domain::chat_message::{ChatMessageSender, ChatMessageContent}}; use chat_types::{dto::server_in::ServerMessageIn, domain::chat_message::{ChatMessageSender, ChatMessageContent}};
use dev_dtos::dtos::user::user_dtos::UserForAuthenticationDto; use dev_dtos::dtos::user::user_dtos::UserForAuthenticationDto;
use tokio::{runtime::Runtime, sync::RwLock}; use tokio::{runtime::Runtime, sync::RwLock};
use crate::{utils::storage, ForeignError, client::chat::init_client_connection}; use crate::{utils::storage, ForeignError, client::chat::init_client_connection, RustError};
pub enum ClientError { pub enum ClientError {
One, Two, Three One, Two, Three
@ -38,7 +38,14 @@ impl<'a> WebsocketCaller {
pub fn init_ws_connection(&'a self, websocket_ffi: Box<dyn WebsocketFfi>) { pub fn init_ws_connection(&'a self, websocket_ffi: Box<dyn WebsocketFfi>) {
let ws_ffi_rwlock = Arc::new(websocket_ffi); let ws_ffi_rwlock = Arc::new(websocket_ffi);
let user: UserForAuthenticationDto = storage::read("user".into()).unwrap(); //TODO: Remove unwrap let mut user_result: Result<UserForAuthenticationDto, RustError> = storage::read("user".into());
while let Err(error) = user_result {
println!("Couldn't read stored user. Error: {error}");
thread::sleep(Duration::from_millis(500));
user_result = storage::read("user".into());
}
let user: UserForAuthenticationDto = user_result.unwrap();
let rt = Runtime::new().unwrap(); let rt = Runtime::new().unwrap();
let _ = rt.block_on( let _ = rt.block_on(

View File

@ -5,13 +5,14 @@ use reqwest::Method;
use crate::{client::base::perform_request_without_client_sync as perform_request, RustError}; use crate::{client::base::perform_request_without_client_sync as perform_request, RustError};
pub const BASE_URL: &str = "http://backend.blancoinfante.com/"; const BASE_URL: &str = "http://backend.blancoinfante.com/";
// ############# // #############
// SPORT ROUTES // SPORT ROUTES
// ############# // #############
pub fn get_all_sports() -> Result<Vec<Sport>, RustError> { pub fn get_all_sports() -> Result<Vec<Sport>, RustError> {
perform_request::<(), Vec<Sport>>(BASE_URL.to_string(), Method::GET, "league/sport".into(), None, 200, vec![]) perform_request::<(), Vec<Sport>>(BASE_URL.to_string(), Method::GET, "league/sport".into(), None, 200, vec![])
//perform_request::<(), Vec<Sport>>("https://google.com/".into(), Method::GET, "".into(), None, 200, vec![])
} }
// ############# // #############

View File

@ -1,3 +1,4 @@
pub mod league; pub mod league;
pub mod base; pub mod base;
pub mod chat; pub mod chat;
pub mod user;

20
src/client/user/mod.rs Normal file
View File

@ -0,0 +1,20 @@
use dev_communicators::middleware::user_svc::user_service::authenticate_user_with_token;
use dev_dtos::{dtos::user::user_dtos::{UserForAuthenticationDto}};
use reqwest::{Client};
use tokio::runtime::Runtime;
use crate::{RustError};
//const BASE_URL: &str = "http://backend.blancoinfante.com/";
pub fn authenticate_user(user: UserForAuthenticationDto) -> Result<(), RustError> {
let rt = Runtime::new().unwrap();
let client = Client::new();
match rt.block_on(
authenticate_user_with_token(&client, &user)
) {
Ok(_) => Ok(()),
Err(error) => Err(error.into()),
}
}

View File

@ -5,22 +5,21 @@ pub mod client;
pub mod utils; pub mod utils;
pub mod callbacks; pub mod callbacks;
use utils::storage;
pub use chat_types::client_types::chat_room::ChatRoom; pub use chat_types::client_types::chat_room::ChatRoom;
pub use chat_types::dto::chat::ChatRoomParticipants; pub use chat_types::dto::chat::ChatRoomParticipants;
pub use dev_dtos::dtos::user::user_dtos::UserForAuthenticationDto; pub use dev_dtos::dtos::user::user_dtos::{UserForAuthenticationDto};
use utils::storage;
pub use utils::storage::*; pub use utils::storage::*;
pub use callbacks::chat::*; pub use callbacks::chat::*;
pub use league_types::domain::sport::Sport; pub use league_types::domain::sport::Sport;
pub use types::error::*; pub use types::error::*;
pub use client::chat::http::*; pub use client::chat::http::*;
pub use client::league::*;
pub use client::user::*;
pub use chat_types::client_types::chat_message::*; pub use chat_types::client_types::chat_message::*;
pub fn get_all_sports() -> Result<Vec<Sport>, RustError> {
client::league::get_all_sports()
}
pub fn get_me() -> Result<UserForAuthenticationDto, RustError> { pub fn get_me() -> Result<UserForAuthenticationDto, RustError> {
storage::read("user".into()) storage::read("user".into())
} }

View File

@ -93,4 +93,6 @@ namespace network {
void init_storage(string path); void init_storage(string path);
[Throws=RustError] [Throws=RustError]
ChatRoom create_new_chat_room(UserForAuthenticationDto user, ChatRoomParticipants participants, string title); ChatRoom create_new_chat_room(UserForAuthenticationDto user, ChatRoomParticipants participants, string title);
[Throws=RustError]
void authenticate_user(UserForAuthenticationDto user);
}; };

View File

@ -12,9 +12,10 @@ pub fn init_storage(path: String) {
let mut write = STORAGE_PATH.write().expect("FATAL ERROR. FAILED TO SECURE A RWLOCK CORRECTLY. STORAGE WON'T WORK NOW."); let mut write = STORAGE_PATH.write().expect("FATAL ERROR. FAILED TO SECURE A RWLOCK CORRECTLY. STORAGE WON'T WORK NOW.");
*write = path; *write = path;
drop(write); drop(write);
// TESTING PURPOSES // TESTING PURPOSES
store(UserForAuthenticationDto{ app: "".into(), id: "3".into(), token: "/2uuNJG3Z2bT9VVd64xBeACPxg64GicloiXtG9uO87as5q5g46TtNu0sAVTACyR8R8uMVXoTBlBP4Q3JhcGB2Q==".to_string() }, "user".into()).unwrap(); //TODO: Remove this line in prod
println!("Wrote shit"); //store(UserForAuthenticationDto{ app: "".into(), id: "3".into(), token: "/2uuNJG3Z2bT9VVd64xBeACPxg64GicloiXtG9uO87as5q5g46TtNu0sAVTACyR8R8uMVXoTBlBP4Q3JhcGB2Q==".to_string() }, "user".into()).unwrap();
} }
// These functions won't be exposed to the clients, just used by the functions they call internally // These functions won't be exposed to the clients, just used by the functions they call internally
@ -39,3 +40,9 @@ pub fn read<T: DeserializeOwned>(path: String) -> Result<T, RustError> {
Err(e) => return Err(RustError::SerdeError { error: MessageResource { key: "STORAGE.OBJECT_DESERIALIZATION".into(), message: Some(e.to_string()) }, serde_error_str: None }), Err(e) => return Err(RustError::SerdeError { error: MessageResource { key: "STORAGE.OBJECT_DESERIALIZATION".into(), message: Some(e.to_string()) }, serde_error_str: None }),
} }
} }
pub fn delete(path: String) -> Result<(), RustError> {
match fs::remove_file(format!("{}/{}", STORAGE_PATH.read().unwrap(), path)) {
Ok(_) => Ok(()),
Err(e) => return Err(RustError::IO { error: MessageResource { key:"STORAGE.OBJECT_DELETING".into(), message: Some(e.to_string())} }),
}
}