Skip to content

Commit

Permalink
fix(context menu): increase vertical item padding (#665)
Browse files Browse the repository at this point in the history
This matches the context menu to the designs.
  • Loading branch information
git-f0x authored Nov 25, 2024
1 parent 23d0a3b commit 06150f7
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 55 deletions.
8 changes: 4 additions & 4 deletions examples/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ impl Application for App {
fn view_window(&self, window_id: window::Id) -> Element<Message> {
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<Message> {
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() {
Expand Down Expand Up @@ -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())));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down
86 changes: 46 additions & 40 deletions src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)));
Expand All @@ -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,
))),
Expand All @@ -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)),
));
}
}
Expand All @@ -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)));
}
_ => {}
}
Expand Down Expand Up @@ -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)
)));
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
])
Expand All @@ -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(),
])
Expand Down Expand Up @@ -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(),
])
Expand All @@ -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(),
Expand All @@ -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(),
])
Expand All @@ -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(),
])
Expand Down

0 comments on commit 06150f7

Please sign in to comment.