fix(ui): combine download size and Last updated onto one card metadata row

This commit is contained in:
Dylan M. Taylor committed 2026-11-30 23:06:12 -05:00
1 parent 553ae5beed
commit e4ddd0e056
2 files changed
+46 -20

No files matched your search

+38 -16
View File
@@ -707,27 +707,49 @@ impl LauncherUi {
ui.add_space(8.0);
}
}
if entry.job.is_none()
let download_size = (entry.job.is_none()
&& entry.paused.is_none()
&& matches!(self.primary_action(&entry, &status), Primary::Install | Primary::Update(_) | Primary::Download(_))
{
&& matches!(self.primary_action(&entry, &status), Primary::Install | Primary::Update(_) | Primary::Download(_)))
.then(|| {
let sizes = self.download_sizes(&entry);
if !sizes.iter().any(|(_, size)| *size == 0)
&& let Some((_, bytes)) = sizes.first()
{
let (min, max) = sizes.iter().fold((*bytes, *bytes), |(min, max), (_, size)| (min.min(*size), max.max(*size)));
let size =
if min == max { widgets::human_bytes(min) } else { format!("{} – {}", widgets::human_bytes(min), widgets::human_bytes(max)) };
ui.add(egui::Label::new(RichText::new(fmt(tl!("Download size: {size}"), &[("size", &size)])).size(12.5).color(t.muted)).truncate())
.on_hover_text(Self::sizes_text(&sizes));
if sizes.iter().any(|(_, size)| *size == 0) {
return None;
}
}
let (_, bytes) = sizes.first()?;
let (min, max) = sizes.iter().fold((*bytes, *bytes), |(min, max), (_, size)| (min.min(*size), max.max(*size)));
let size =
if min == max { widgets::human_bytes(min) } else { format!("{} – {}", widgets::human_bytes(min), widgets::human_bytes(max)) };
Some((size, Self::sizes_text(&sizes)))
})
.flatten();
if let Some(details) = AppDetails::by_id(id) {
crate::card_parts::blurb(ui, details.headline, t.muted, 4);
crate::card_parts::blurb(ui, details.headline, t.muted, 3);
}
if let Some(line) = crate::card_parts::last_updated(&entry) {
ui.add_space(6.0);
ui.add(egui::Label::new(RichText::new(line).size(12.5).color(t.faint)).selectable(false));
let last_updated = crate::card_parts::last_updated(&entry);
match (download_size, last_updated) {
(Some((size, hover)), Some(updated)) => {
ui.add_space(6.0);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 6.0;
ui.add(egui::Label::new(RichText::new(size).size(12.5).color(t.muted)).selectable(false)).on_hover_text(hover);
ui.add(egui::Label::new(RichText::new("·").size(12.5).color(t.faint)).selectable(false));
ui.add(egui::Label::new(RichText::new(updated).size(12.5).color(t.faint)).truncate().selectable(false));
});
}
(Some((size, hover)), None) => {
ui.add_space(6.0);
ui.add(
egui::Label::new(RichText::new(fmt(tl!("Download size: {size}"), &[("size", &size)])).size(12.5).color(t.muted))
.truncate()
.selectable(false),
)
.on_hover_text(hover);
}
(None, Some(updated)) => {
ui.add_space(6.0);
ui.add(egui::Label::new(RichText::new(updated).size(12.5).color(t.faint)).truncate().selectable(false));
}
(None, None) => {}
}
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
ui.horizontal(|ui| self.actions_in(ui, &entry, &status, inner.width(), Place::Card));
+8 -4
View File
@@ -4336,7 +4336,7 @@ fn install_and_update_actions_preview_download_sizes() {
let (mut h, _) = harness(view, egui::Theme::Dark, true);
h.run_steps(4);
if view == ViewMode::Grid {
assert!(h.query_all_by_label("Download size: 150 MB").count() >= 2);
assert!(h.query_all_by_label("150 MB").count() >= 2);
}
// Keep the action visible as the suite gains more cards.
h.get_by_role(egui::accesskit::Role::TextInput).click();
@@ -4369,6 +4369,8 @@ fn unknown_download_sizes_are_not_presented_as_one_kilobyte() {
h.hover_at(h.get_by_label("Update to 0.5.0").rect().center());
h.run_steps(40);
assert!(h.query_by_label_contains("Download size:").is_none());
assert!(h.query_by_label("0 B").is_none());
assert!(h.query_by_label("1 KB").is_none());
assert!(h.query_by_label_contains("Disk image (.dmg) ·").is_none());
}
@@ -4446,12 +4448,14 @@ fn download_size_preview_uses_the_managed_plan_or_manual_platform_formats() {
h.get_by_role(egui::accesskit::Role::TextInput).type_text("PhotoCraft");
h.run_steps(4);
if manage && has_plan && installer_size > 0 {
h.get_by_label("Download size: 100 MB");
h.get_by_label("100 MB");
} else if !manage && installer_size > 0 {
h.get_by_label("Download size: 100 MB – 2.0 GB");
h.get_by_label("100 MB – 2.0 GB");
} else {
assert!(
h.query_by_label_contains("Download size:").is_none(),
h.query_by_label_contains("Download size:").is_none()
&& h.query_by_label("100 MB").is_none()
&& h.query_by_label("100 MB – 2.0 GB").is_none(),
"an unknown managed plan or partial manual range must not imply a known size"
);
}