Splash Screens (#2657)

* progress: loading splash screen

* feat: loading screen plash

* feat: splash screens

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Miles MurgawandJonathan Kelley authored and GitHub committed 2024-07-23 10:22:49 -07:00
1 parent 8b5ad5d925
commit 856fadc9d6
6 files changed
+458 -119

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ use tracing::Level;
use super::BuildRequest;
#[derive(Default, Debug, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Default, Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy)]
pub enum Stage {
#[default]
Initializing = 0,
+2 -1
View File
@@ -106,8 +106,9 @@ pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
// We also can check the status of the builds here in case we have multiple ongoing builds
match application {
Ok(BuilderUpdate::Progress { platform, update }) => {
let update_stage = update.stage;
screen.new_build_logs(platform, update);
server.update_build_status(screen.build_progress.progress()).await;
server.update_build_status(screen.build_progress.progress(), update_stage.to_string()).await;
}
Ok(BuilderUpdate::Ready { results }) => {
if !results.is_empty() {
+36 -8
View File
@@ -46,8 +46,17 @@ use tower_http::{
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", content = "data")]
enum Status {
Building { progress: f64 },
BuildError { error: String },
ClientInit {
application_name: String,
platform: String,
},
Building {
progress: f64,
build_message: String,
},
BuildError {
error: String,
},
Ready,
}
@@ -77,14 +86,21 @@ pub(crate) struct Server {
_server_task: JoinHandle<Result<()>>,
/// We proxy (not hot reloading) fullstack requests to this port
pub fullstack_port: Option<u16>,
build_status: SharedStatus,
application_name: String,
platform: String,
}
impl Server {
pub fn start(serve: &Serve, cfg: &DioxusCrate) -> Self {
let (hot_reload_sockets_tx, hot_reload_sockets_rx) = futures_channel::mpsc::unbounded();
let (build_status_sockets_tx, build_status_sockets_rx) = futures_channel::mpsc::unbounded();
let build_status = SharedStatus::new(Status::Building { progress: 0.0 });
let build_status = SharedStatus::new(Status::Building {
progress: 0.0,
build_message: "Starting the build...".to_string(),
});
let addr = serve.server_arguments.address.address();
let start_browser = serve.server_arguments.open.unwrap_or_default();
@@ -151,7 +167,10 @@ impl Server {
_server_task,
ip: addr,
fullstack_port,
build_status,
application_name: cfg.dioxus_config.application.name.clone(),
platform: serve.build_arguments.platform().to_string(),
}
}
@@ -171,15 +190,21 @@ impl Server {
}
pub async fn start_build(&mut self) {
self.build_status.set(Status::Building { progress: 0.0 });
self.build_status.set(Status::Building {
progress: 0.0,
build_message: "Starting the build...".to_string(),
});
self.send_build_status().await;
}
pub async fn update_build_status(&mut self, progress: f64) {
pub async fn update_build_status(&mut self, progress: f64, build_message: String) {
if !matches!(self.build_status.get(), Status::Building { .. }) {
return;
}
self.build_status.set(Status::Building { progress });
self.build_status.set(Status::Building {
progress,
build_message,
});
self.send_build_status().await;
}
@@ -223,8 +248,11 @@ impl Server {
new_build_status_socket = &mut new_build_status_socket => {
if let Some(mut new_socket) = new_build_status_socket {
drop(new_message);
// Update the socket with the current status
if send_build_status_to(&self.build_status, &mut new_socket).await.is_ok() {
// Update the socket with project info and current build status
let project_info = SharedStatus::new(Status::ClientInit { application_name: self.application_name.clone(), platform: self.platform.clone() });
if send_build_status_to(&project_info, &mut new_socket).await.is_ok() {
_ = send_build_status_to(&self.build_status, &mut new_socket).await;
self.build_status_sockets.push(new_socket);
}
return None;