fix(display): hide arrangement section when there is less than two displays

This commit is contained in:
Michael Aaron Murphy 2024-02-15 04:51:51 +01:00 committed by Michael Murphy
parent ced3f2ffd8
commit 219cb36d3c
2 changed files with 29 additions and 9 deletions

View file

@ -624,9 +624,16 @@ impl SettingsApp {
let section = &self.pages.sections[id];
let model = &self.pages.page[self.active_page];
column_widgets.push(
(section.view_fn)(&self.pages, model.as_ref(), section).map(Message::PageMessage),
);
if section
.show_while
.as_ref()
.map_or(true, |func| func(model.as_ref()))
{
column_widgets.push(
(section.view_fn)(&self.pages, model.as_ref(), section)
.map(Message::PageMessage),
);
}
}
settings::view_column(column_widgets).into()
@ -680,12 +687,18 @@ impl SettingsApp {
sections.push(search_header(&self.pages, page));
}
let section = (section.view_fn)(&self.pages, model.as_ref(), section)
.map(Message::PageMessage)
.apply(iced::widget::container)
.padding([0, 0, 0, cosmic::theme::active().cosmic().space_xl()]);
if section
.show_while
.as_ref()
.map_or(true, |func| func(model.as_ref()))
{
let section = (section.view_fn)(&self.pages, model.as_ref(), section)
.map(Message::PageMessage)
.apply(iced::widget::container)
.padding([0, 0, 0, cosmic::theme::active().cosmic().space_xl()]);
sections.push(section.into());
sections.push(section.into());
}
}
settings::view_column(sections).into()

View file

@ -11,6 +11,7 @@ use arrangement::Arrangement;
use cosmic::iced::Length;
use cosmic::iced_core::Alignment;
use cosmic::iced_widget::scrollable::{Direction, Properties};
use cosmic::prelude::CollectionWidget;
use cosmic::widget::{
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
};
@ -179,6 +180,8 @@ impl page::Page<crate::pages::Message> for Page {
text::DISPLAY_ARRANGEMENT.clone(),
text::DISPLAY_ARRANGEMENT_DESC.clone(),
])
// Show section when there is more than 1 display
.show_while::<Page>(|page| page.list.outputs.len() > 1)
.view::<Page>(|_binder, page, _section| page.display_arrangement_view()),
),
// Display configuration
@ -444,7 +447,11 @@ impl Page {
column()
.spacing(theme.cosmic().space_m())
.push(view_switcher::horizontal(&self.display_tabs).on_activate(Message::Display))
.push_maybe(if self.list.outputs.len() > 1 {
Some(view_switcher::horizontal(&self.display_tabs).on_activate(Message::Display))
} else {
None
})
.push(display_meta)
.push(cosmic::widget::text::heading(&*text::DISPLAY_OPTIONS))
.push(display_options)