Build/download meters get a fixed width
Browse files at this commit5a068bff0e0b5fde3ed90cec1b01cd8871261f0eParent: 9063f7e- style
- build/download meters get a fixed width
- Required toggle lives in the build card so it is set before auto publish
2 changed files +44 -36
crates/client/src/gui/builder/releases.rsmodified+40 -33
| @@ -23,6 +23,7 @@ use crate::lang::w; | ||
| 23 | 23 | use crate::release::{Build, Event, Job, Level, PLAN, is_source}; |
| 24 | 24 | |
| 25 | 25 | const CLIENTS_TICK: Duration = Duration::from_secs(1); |
| 26 | +const METER: f32 = 140.; | |
| 26 | 27 | |
| 27 | 28 | #[derive(Default)] |
| 28 | 29 | pub(crate) struct Desk { |
| @@ -113,6 +114,16 @@ fn caption_text(value: impl Into<String>, color: Hsla) -> Div { | ||
| 113 | 114 | .child(value.into()) |
| 114 | 115 | } |
| 115 | 116 | |
| 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 | + | |
| 116 | 127 | fn job_row(row: &Row, palette: Palette) -> Div { |
| 117 | 128 | let (status, detail): (Div, Option<Div>) = match &row.phase { |
| 118 | 129 | Phase::Waiting => ( |
| @@ -123,16 +134,11 @@ fn job_row(row: &Row, palette: Palette) -> Div { | ||
| 123 | 134 | let status = if *total == 0 { |
| 124 | 135 | caption_text("…", palette.muted) |
| 125 | 136 | } 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 | + ) | |
| 136 | 142 | }; |
| 137 | 143 | (status, Some(caption_text(row.line.clone(), palette.muted))) |
| 138 | 144 | } |
| @@ -186,16 +192,9 @@ fn client_row(client: &UpdateClient, palette: Palette) -> Div { | ||
| 186 | 192 | }, |
| 187 | 193 | palette.muted, |
| 188 | 194 | ), |
| 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 | + } | |
| 199 | 198 | UpdateState::Installing { .. } => { |
| 200 | 199 | caption_text(w().builder_release.installing, palette.muted) |
| 201 | 200 | } |
| @@ -426,6 +425,16 @@ impl Yumush { | ||
| 426 | 425 | entity_action(entity, |yumush, _, cx| yumush.cancel_build(cx)), |
| 427 | 426 | ) |
| 428 | 427 | }); |
| 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 | + ); | |
| 429 | 438 | let rows: Vec<Div> = self |
| 430 | 439 | .desk |
| 431 | 440 | .jobs |
| @@ -449,7 +458,16 @@ impl Yumush { | ||
| 449 | 458 | .child(choose), |
| 450 | 459 | ) |
| 451 | 460 | .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 | + ) | |
| 453 | 471 | } |
| 454 | 472 | |
| 455 | 473 | fn clients_card(&self, palette: Palette) -> Div { |
| @@ -498,21 +516,10 @@ impl Yumush { | ||
| 498 | 516 | .opacity(0.4) |
| 499 | 517 | .into_any_element() |
| 500 | 518 | }; |
| 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 | - | |
| 512 | 519 | card(palette) |
| 513 | 520 | .child(card_header(w().builder_release.draft, Vec::new(), palette)) |
| 514 | 521 | .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)) | |
| 516 | 523 | } |
| 517 | 524 | |
| 518 | 525 | 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> { | ||
| 396 | 396 | loop { |
| 397 | 397 | let mut slot = cx.child.lock().unwrap(); |
| 398 | 398 | 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 | + } | |
| 402 | 403 | let Some(child) = slot.as_mut() else { |
| 403 | 404 | return Err("no child".into()); |
| 404 | 405 | }; |