forge
Explore
Log in

Don't you dare go Hollow

Build/download meters get a fixed width

Browse files at this commit

5a068bff0e0b5fde3ed90cec1b01cd8871261f0eAhmet Kaan GümüşParent: 9063f7e
  • style
    • build/download meters get a fixed width
    • Required toggle lives in the build card so it is set before auto publish
Show full message
💄 style: build/download meters get a fixed width; Required toggle lives in the build card so it is set before auto publish
crates/client/src/gui/builder/releases.rsmodified+40 -33
@@ -23,6 +23,7 @@ use crate::lang::w;
2323 use crate::release::{Build, Event, Job, Level, PLAN, is_source};
2424
2525 const CLIENTS_TICK: Duration = Duration::from_secs(1);
26+const METER: f32 = 140.;
2627
2728 #[derive(Default)]
2829 pub(crate) struct Desk {
@@ -113,6 +114,16 @@ fn caption_text(value: impl Into<String>, color: Hsla) -> Div {
113114 .child(value.into())
114115 }
115116
117+fn meter(share: f32, label: String, palette: Palette) -> Div {
118+ div()
119+ .w(px(METER))
120+ .flex()
121+ .items_center()
122+ .gap(px(space::SM))
123+ .child(parts::track(Fill::Part(share), false, palette.tokens))
124+ .child(caption_text(label, palette.muted))
125+}
126+
116127 fn job_row(row: &Row, palette: Palette) -> Div {
117128 let (status, detail): (Div, Option<Div>) = match &row.phase {
118129 Phase::Waiting => (
@@ -123,16 +134,11 @@ fn job_row(row: &Row, palette: Palette) -> Div {
123134 let status = if *total == 0 {
124135 caption_text("…", palette.muted)
125136 } else {
126- div()
127- .flex()
128- .items_center()
129- .gap(px(space::SM))
130- .child(parts::track(
131- Fill::Part(*done as f32 / *total as f32),
132- false,
133- palette.tokens,
134- ))
135- .child(caption_text(format!("{done}/{total}"), palette.muted))
137+ meter(
138+ *done as f32 / *total as f32,
139+ format!("{done}/{total}"),
140+ palette,
141+ )
136142 };
137143 (status, Some(caption_text(row.line.clone(), palette.muted)))
138144 }
@@ -186,16 +192,9 @@ fn client_row(client: &UpdateClient, palette: Palette) -> Div {
186192 },
187193 palette.muted,
188194 ),
189- UpdateState::Downloading { percent, .. } => div()
190- .flex()
191- .items_center()
192- .gap(px(space::SM))
193- .child(parts::track(
194- Fill::Part(f32::from(percent) / 100.),
195- false,
196- palette.tokens,
197- ))
198- .child(caption_text(format!("{percent}%"), palette.muted)),
195+ UpdateState::Downloading { percent, .. } => {
196+ meter(f32::from(percent) / 100., format!("{percent}%"), palette)
197+ }
199198 UpdateState::Installing { .. } => {
200199 caption_text(w().builder_release.installing, palette.muted)
201200 }
@@ -426,6 +425,16 @@ impl Yumush {
426425 entity_action(entity, |yumush, _, cx| yumush.cancel_build(cx)),
427426 )
428427 });
428+ let required = parts::labeled_toggle(
429+ "release_required",
430+ w().builder_release.required,
431+ self.desk.required,
432+ palette.tokens,
433+ entity_action(entity, |yumush, _, cx| {
434+ yumush.desk.required = !yumush.desk.required;
435+ cx.notify();
436+ }),
437+ );
429438 let rows: Vec<Div> = self
430439 .desk
431440 .jobs
@@ -449,7 +458,16 @@ impl Yumush {
449458 .child(choose),
450459 )
451460 .child(div().flex().flex_col().children(rows))
452- .child(list_row().justify_end().children(cancel).child(build))
461+ .child(
462+ list_row().justify_between().child(required).child(
463+ div()
464+ .flex()
465+ .items_center()
466+ .gap(px(space::SM))
467+ .children(cancel)
468+ .child(build),
469+ ),
470+ )
453471 }
454472
455473 fn clients_card(&self, palette: Palette) -> Div {
@@ -498,21 +516,10 @@ impl Yumush {
498516 .opacity(0.4)
499517 .into_any_element()
500518 };
501- let required = parts::labeled_toggle(
502- "release_draft_required",
503- w().builder_release.required,
504- self.desk.required,
505- palette.tokens,
506- entity_action(entity, |yumush, _, cx| {
507- yumush.desk.required = !yumush.desk.required;
508- cx.notify();
509- }),
510- );
511-
512519 card(palette)
513520 .child(card_header(w().builder_release.draft, Vec::new(), palette))
514521 .child(div().flex().flex_col().children(rows))
515- .child(list_row().justify_between().child(required).child(publish))
522+ .child(list_row().justify_end().child(publish))
516523 }
517524
518525 fn releases_card(&self, entity: &Entity<Self>, palette: Palette) -> Div {
crates/client/src/release.rsmodified+4 -3
@@ -396,9 +396,10 @@ fn wait(cx: &Cx) -> Result<ExitStatus, String> {
396396 loop {
397397 let mut slot = cx.child.lock().unwrap();
398398 if cx.cancelled()
399- && let Some(child) = slot.as_mut() {
400- let _ = child.kill();
401- }
399+ && let Some(child) = slot.as_mut()
400+ {
401+ let _ = child.kill();
402+ }
402403 let Some(child) = slot.as_mut() else {
403404 return Err("no child".into());
404405 };