From 06150f7d44c7369e6beb70648b48059e3bb1b0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Mon, 25 Nov 2024 03:24:24 +0100 Subject: [PATCH] fix(context menu): increase vertical item padding (#665) This matches the context menu to the designs. --- examples/dialog.rs | 8 ++--- src/app.rs | 14 ++++---- src/dialog.rs | 6 ++-- src/menu.rs | 2 +- src/tab.rs | 86 +++++++++++++++++++++++++--------------------- 5 files changed, 61 insertions(+), 55 deletions(-) diff --git a/examples/dialog.rs b/examples/dialog.rs index e4e6d4c..99c5caa 100644 --- a/examples/dialog.rs +++ b/examples/dialog.rs @@ -84,12 +84,12 @@ impl Application for App { fn view_window(&self, window_id: window::Id) -> Element { match &self.dialog_opt { Some(dialog) => dialog.view(window_id), - None => widget::text("No dialog").into(), + None => widget::text::body("No dialog").into(), } } fn view(&self) -> Element { - let mut column = widget::column().spacing(8); + let mut column = widget::column().spacing(8).padding(8); { let mut button = widget::button::standard("Open File"); if self.dialog_opt.is_none() { @@ -130,11 +130,11 @@ impl Application for App { if let Some(result) = &self.result_opt { match result { DialogResult::Cancel => { - column = column.push(widget::text("Cancel")); + column = column.push(widget::text::body("Cancel")); } DialogResult::Open(paths) => { for path in paths.iter() { - column = column.push(widget::text(format!("{}", path.display()))); + column = column.push(widget::text::body(format!("{}", path.display()))); } } } diff --git a/src/app.rs b/src/app.rs index a725ff6..0d60f3c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1142,7 +1142,7 @@ impl App { } } widget::column::with_children(vec![ - widget::text(fl!("network-drive-description")).into(), + widget::text::body(fl!("network-drive-description")).into(), table.into(), ]) .spacing(space_m) @@ -1269,7 +1269,7 @@ impl App { ]) .align_y(Alignment::Center) .into(), - widget::text(op.pending_text(progress, controller.state())).into(), + widget::text::body(op.pending_text(progress, controller.state())).into(), ])); } children.push(section.into()); @@ -1280,8 +1280,8 @@ impl App { for (_id, (op, controller, error)) in self.failed_operations.iter().rev() { let progress = controller.progress(); section = section.add(widget::column::with_children(vec![ - widget::text(op.pending_text(progress, controller.state())).into(), - widget::text(error).into(), + widget::text::body(op.pending_text(progress, controller.state())).into(), + widget::text::body(error).into(), ])); } children.push(section.into()); @@ -1290,7 +1290,7 @@ impl App { if !self.complete_operations.is_empty() { let mut section = widget::settings::section().title(fl!("complete")); for (_id, op) in self.complete_operations.iter().rev() { - section = section.add(widget::text(op.completed_text())); + section = section.add(widget::text::body(op.completed_text())); } children.push(section.into()); } @@ -3713,10 +3713,10 @@ impl Application for App { widget::row::with_children(vec![ widget::icon(app.icon.clone()).size(32).into(), if app.is_default { - widget::text(fl!("default-app", name = app.name.as_str())) + widget::text::body(fl!("default-app", name = app.name.as_str())) .into() } else { - widget::text(app.name.to_string()).into() + widget::text::body(app.name.to_string()).into() }, widget::horizontal_space().into(), if *selected == i { diff --git a/src/dialog.rs b/src/dialog.rs index 1927239..4b06aef 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -806,9 +806,9 @@ impl Application for App { for item in items.iter() { if item.selected { actions.extend( - item.preview_header().into_iter().map(|element| { - element.map(move |message| Message::from(message)) - }), + item.preview_header() + .into_iter() + .map(|element| element.map(Message::from)), ) } } diff --git a/src/menu.rs b/src/menu.rs index d3616ae..d3d9f8a 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -30,7 +30,7 @@ macro_rules! menu_button { .height(Length::Fixed(24.0)) .align_y(Alignment::Center) ) - .padding([theme::active().cosmic().spacing.space_xxxs, 16]) + .padding([theme::active().cosmic().spacing.space_xxs, 16]) .width(Length::Fill) .class(theme::Button::MenuItem) ); diff --git a/src/tab.rs b/src/tab.rs index a6e3f07..284d036 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1415,42 +1415,45 @@ impl Item { let mut details = widget::column().spacing(space_xxxs); details = details.push(widget::text::heading(self.name.clone())); - details = details.push(widget::text(fl!("type", mime = self.mime.to_string()))); + details = details.push(widget::text::body(fl!( + "type", + mime = self.mime.to_string() + ))); let mut settings = Vec::new(); match &self.metadata { ItemMetadata::Path { metadata, children } => { if metadata.is_dir() { - details = details.push(widget::text(fl!("items", items = children))); + details = details.push(widget::text::body(fl!("items", items = children))); let size = match &self.dir_size { DirSize::Calculating(_) => fl!("calculating"), DirSize::Directory(size) => format_size(*size), DirSize::NotDirectory => String::new(), DirSize::Error(err) => err.clone(), }; - details = details.push(widget::text(fl!("item-size", size = size))); + details = details.push(widget::text::body(fl!("item-size", size = size))); } else { - details = details.push(widget::text(fl!( + details = details.push(widget::text::body(fl!( "item-size", size = format_size(metadata.len()) ))); } if let Ok(time) = metadata.created() { - details = details.push(widget::text(fl!( + details = details.push(widget::text::body(fl!( "item-created", created = format_time(time).to_string() ))); } if let Ok(time) = metadata.modified() { - details = details.push(widget::text(fl!( + details = details.push(widget::text::body(fl!( "item-modified", modified = format_time(time).to_string() ))); } if let Ok(time) = metadata.accessed() { - details = details.push(widget::text(fl!( + details = details.push(widget::text::body(fl!( "item-accessed", accessed = format_time(time).to_string() ))); @@ -1464,7 +1467,7 @@ impl Item { PermissionOwner::Owner, )) .description(fl!("owner")) - .control(widget::text(format_permissions( + .control(widget::text::body(format_permissions( metadata, PermissionOwner::Owner, ))), @@ -1476,14 +1479,14 @@ impl Item { PermissionOwner::Group, )) .description(fl!("group")) - .control(widget::text(format_permissions( + .control(widget::text::body(format_permissions( metadata, PermissionOwner::Group, ))), ); settings.push(widget::settings::item::builder(fl!("other")).control( - widget::text(format_permissions(metadata, PermissionOwner::Other)), + widget::text::body(format_permissions(metadata, PermissionOwner::Other)), )); } } @@ -1497,7 +1500,7 @@ impl Item { .unwrap_or(&ItemThumbnail::NotImage) { ItemThumbnail::Image(_, Some((width, height))) => { - details = details.push(widget::text(format!("{}x{}", width, height))); + details = details.push(widget::text::body(format!("{}x{}", width, height))); } _ => {} } @@ -1538,15 +1541,15 @@ impl Item { match &self.metadata { ItemMetadata::Path { metadata, children } => { if metadata.is_dir() { - column = column.push(widget::text(format!("Items: {}", children))); + column = column.push(widget::text::body(format!("Items: {}", children))); } else { - column = column.push(widget::text(format!( + column = column.push(widget::text::body(format!( "Size: {}", format_size(metadata.len()) ))); } if let Ok(time) = metadata.modified() { - column = column.push(widget::text(format!( + column = column.push(widget::text::body(format!( "Last modified: {}", format_time(time) ))); @@ -3584,7 +3587,7 @@ impl Tab { .size(64) .icon() .into(), - widget::text(if has_hidden { + widget::text::body(if has_hidden { fl!("empty-folder-hidden") } else if matches!(self.location, Location::Search(..)) { fl!("no-results") @@ -3857,17 +3860,19 @@ impl Tab { false, false, )), - widget::button::custom(widget::text(item.display_name.clone())) - .id(item.button_id.clone()) - .on_press(Message::Click(Some(*i))) - .padding([0, space_xxxs]) - .class(button_style( - item.selected, - item.highlighted, - true, - true, - false, - )), + widget::button::custom(widget::text::body( + item.display_name.clone(), + )) + .id(item.button_id.clone()) + .on_press(Message::Click(Some(*i))) + .padding([0, space_xxxs]) + .class(button_style( + item.selected, + item.highlighted, + true, + true, + false, + )), ]; let mut column = widget::column::with_capacity(buttons.len()) @@ -4016,7 +4021,7 @@ impl Tab { .size(icon_size) .into(), widget::column::with_children(vec![ - widget::text(item.display_name.clone()).into(), + widget::text::body(item.display_name.clone()).into(), //TODO: translate? widget::text::caption(format!("{} - {}", modified_text, size_text)) .into(), @@ -4033,7 +4038,7 @@ impl Tab { .size(icon_size) .into(), widget::column::with_children(vec![ - widget::text(item.display_name.clone()).into(), + widget::text::body(item.display_name.clone()).into(), widget::text::caption(match item.path_opt() { Some(path) => path.display().to_string(), None => String::new(), @@ -4042,10 +4047,10 @@ impl Tab { ]) .width(Length::Fill) .into(), - widget::text(modified_text.clone()) + widget::text::body(modified_text.clone()) .width(Length::Fixed(modified_width)) .into(), - widget::text(size_text.clone()) + widget::text::body(size_text.clone()) .width(Length::Fixed(size_width)) .into(), ]) @@ -4058,13 +4063,13 @@ impl Tab { .content_fit(ContentFit::Contain) .size(icon_size) .into(), - widget::text(item.display_name.clone()) + widget::text::body(item.display_name.clone()) .width(Length::Fill) .into(), - widget::text(modified_text.clone()) + widget::text::body(modified_text.clone()) .width(Length::Fixed(modified_width)) .into(), - widget::text(size_text.clone()) + widget::text::body(size_text.clone()) .width(Length::Fixed(size_width)) .into(), ]) @@ -4121,9 +4126,10 @@ impl Tab { .size(icon_size) .into(), widget::column::with_children(vec![ - widget::text(item.display_name.clone()).into(), + widget::text::body(item.display_name.clone()).into(), //TODO: translate? - widget::text(format!("{} - {}", modified_text, size_text)).into(), + widget::text::body(format!("{} - {}", modified_text, size_text)) + .into(), ]) .into(), ]) @@ -4137,7 +4143,7 @@ impl Tab { .size(icon_size) .into(), widget::column::with_children(vec![ - widget::text(item.display_name.clone()).into(), + widget::text::body(item.display_name.clone()).into(), widget::text::caption(match item.path_opt() { Some(path) => path.display().to_string(), None => String::new(), @@ -4146,10 +4152,10 @@ impl Tab { ]) .width(Length::Fill) .into(), - widget::text(modified_text.clone()) + widget::text::body(modified_text.clone()) .width(Length::Fixed(modified_width)) .into(), - widget::text(size_text.clone()) + widget::text::body(size_text.clone()) .width(Length::Fixed(size_width)) .into(), ]) @@ -4162,13 +4168,13 @@ impl Tab { .content_fit(ContentFit::Contain) .size(icon_size) .into(), - widget::text(item.display_name.clone()) + widget::text::body(item.display_name.clone()) .width(Length::Fill) .into(), widget::text(modified_text) .width(Length::Fixed(modified_width)) .into(), - widget::text(size_text) + widget::text::body(size_text) .width(Length::Fixed(size_width)) .into(), ])