diff --git a/crates/client/src/gui/builder/releases.rs b/crates/client/src/gui/builder/releases.rs index e0a1567..ab2205a 100644 --- a/crates/client/src/gui/builder/releases.rs +++ b/crates/client/src/gui/builder/releases.rs @@ -23,6 +23,7 @@ use crate::lang::w; use crate::release::{Build, Event, Job, Level, PLAN, is_source}; const CLIENTS_TICK: Duration = Duration::from_secs(1); +const METER: f32 = 140.; #[derive(Default)] pub(crate) struct Desk { @@ -113,6 +114,16 @@ fn caption_text(value: impl Into, color: Hsla) -> Div { .child(value.into()) } +fn meter(share: f32, label: String, palette: Palette) -> Div { + div() + .w(px(METER)) + .flex() + .items_center() + .gap(px(space::SM)) + .child(parts::track(Fill::Part(share), false, palette.tokens)) + .child(caption_text(label, palette.muted)) +} + fn job_row(row: &Row, palette: Palette) -> Div { let (status, detail): (Div, Option
) = match &row.phase { Phase::Waiting => ( @@ -123,16 +134,11 @@ fn job_row(row: &Row, palette: Palette) -> Div { let status = if *total == 0 { caption_text("…", palette.muted) } else { - div() - .flex() - .items_center() - .gap(px(space::SM)) - .child(parts::track( - Fill::Part(*done as f32 / *total as f32), - false, - palette.tokens, - )) - .child(caption_text(format!("{done}/{total}"), palette.muted)) + meter( + *done as f32 / *total as f32, + format!("{done}/{total}"), + palette, + ) }; (status, Some(caption_text(row.line.clone(), palette.muted))) } @@ -186,16 +192,9 @@ fn client_row(client: &UpdateClient, palette: Palette) -> Div { }, palette.muted, ), - UpdateState::Downloading { percent, .. } => div() - .flex() - .items_center() - .gap(px(space::SM)) - .child(parts::track( - Fill::Part(f32::from(percent) / 100.), - false, - palette.tokens, - )) - .child(caption_text(format!("{percent}%"), palette.muted)), + UpdateState::Downloading { percent, .. } => { + meter(f32::from(percent) / 100., format!("{percent}%"), palette) + } UpdateState::Installing { .. } => { caption_text(w().builder_release.installing, palette.muted) } @@ -426,6 +425,16 @@ impl Yumush { entity_action(entity, |yumush, _, cx| yumush.cancel_build(cx)), ) }); + let required = parts::labeled_toggle( + "release_required", + w().builder_release.required, + self.desk.required, + palette.tokens, + entity_action(entity, |yumush, _, cx| { + yumush.desk.required = !yumush.desk.required; + cx.notify(); + }), + ); let rows: Vec
= self .desk .jobs @@ -449,7 +458,16 @@ impl Yumush { .child(choose), ) .child(div().flex().flex_col().children(rows)) - .child(list_row().justify_end().children(cancel).child(build)) + .child( + list_row().justify_between().child(required).child( + div() + .flex() + .items_center() + .gap(px(space::SM)) + .children(cancel) + .child(build), + ), + ) } fn clients_card(&self, palette: Palette) -> Div { @@ -498,21 +516,10 @@ impl Yumush { .opacity(0.4) .into_any_element() }; - let required = parts::labeled_toggle( - "release_draft_required", - w().builder_release.required, - self.desk.required, - palette.tokens, - entity_action(entity, |yumush, _, cx| { - yumush.desk.required = !yumush.desk.required; - cx.notify(); - }), - ); - card(palette) .child(card_header(w().builder_release.draft, Vec::new(), palette)) .child(div().flex().flex_col().children(rows)) - .child(list_row().justify_between().child(required).child(publish)) + .child(list_row().justify_end().child(publish)) } fn releases_card(&self, entity: &Entity, palette: Palette) -> Div { diff --git a/crates/client/src/release.rs b/crates/client/src/release.rs index 85008bf..1dd4a7f 100644 --- a/crates/client/src/release.rs +++ b/crates/client/src/release.rs @@ -396,9 +396,10 @@ fn wait(cx: &Cx) -> Result { loop { let mut slot = cx.child.lock().unwrap(); if cx.cancelled() - && let Some(child) = slot.as_mut() { - let _ = child.kill(); - } + && let Some(child) = slot.as_mut() + { + let _ = child.kill(); + } let Some(child) = slot.as_mut() else { return Err("no child".into()); };