Merge pull request #869 from ellieplayswow/feature/open-with-subclasses

Bugfix to open-with dialog to use a scrollable with a managed height
This commit is contained in:
Jeremy Soller 2025-03-10 08:04:22 -06:00 committed by GitHub
commit 509a0afb98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4329,12 +4329,17 @@ impl Application for App {
};
let mut column = widget::list_column();
for (i, app) in self.get_programs_for_mime(&mime).iter().enumerate() {
let available_programs = self.get_programs_for_mime(&mime);
let item_height = 32.0;
let mut displayed_default = false;
for (i, app) in available_programs.iter().enumerate() {
column = column.add(
widget::button::custom(
widget::row::with_children(vec![
widget::icon(app.icon.clone()).size(32).into(),
if app.is_default {
if app.is_default && !displayed_default {
displayed_default = true;
widget::text::body(fl!(
"default-app",
name = Some(app.name.as_str())
@ -4353,7 +4358,7 @@ impl Application for App {
},
])
.spacing(space_s)
.height(Length::Fixed(32.0))
.height(Length::Fixed(item_height))
.align_y(Alignment::Center),
)
.width(Length::Fill)
@ -4370,7 +4375,22 @@ impl Application for App {
.secondary_action(
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
)
.control(column);
.control(
widget::scrollable(column).height(if let Some(size) = self.size {
let max_size = size.height - 256.0;
// (32 (item_height) + 5.0 (custom button padding)) + (space_xxs (list item spacing) * 2)
let scrollable_height = available_programs.len() as f32
* (item_height + 5.0 + (2.0 * space_xxs as f32));
if scrollable_height > max_size {
Length::Fill
} else {
Length::Shrink
}
} else {
Length::Fill
}),
);
if let Some(app) = store_opt {
dialog = dialog.tertiary_action(