chore: use cosmic theme padding & spacing across interface

This commit is contained in:
Michael Aaron Murphy 2024-02-15 04:31:57 +01:00 committed by Michael Murphy
parent 1d41792700
commit 9bebc7b1f6
2 changed files with 31 additions and 14 deletions

View file

@ -149,7 +149,7 @@ impl cosmic::Application for SettingsApp {
} else { } else {
icon::from_name("system-search-symbolic") icon::from_name("system-search-symbolic")
.apply(button::icon) .apply(button::icon)
.padding([0, 16]) .padding([0, cosmic::theme::active().cosmic().space_s()])
.on_press(Message::SearchActivate) .on_press(Message::SearchActivate)
.into() .into()
}); });
@ -420,6 +420,8 @@ impl cosmic::Application for SettingsApp {
} }
fn view(&self) -> Element<Message> { fn view(&self) -> Element<Message> {
let theme = cosmic::theme::active();
let page_view = if self.search_active { let page_view = if self.search_active {
self.search_view() self.search_view()
} else if let Some(content) = self.pages.content(self.active_page) { } else if let Some(content) = self.pages.content(self.active_page) {
@ -430,14 +432,18 @@ impl cosmic::Application for SettingsApp {
panic!("page without sub-pages or content"); panic!("page without sub-pages or content");
}; };
let padding = if self.core.is_condensed() { 0 } else { 64 }; let padding = if self.core.is_condensed() {
0
} else {
theme.cosmic().space_l()
};
container(page_view) container(page_view)
.max_width(800) .max_width(800)
.width(Length::Fill) .width(Length::Fill)
.apply(container) .apply(container)
.center_x() .center_x()
.padding([0, padding]) .padding([theme.cosmic().space_xxs(), padding])
.width(Length::Fill) .width(Length::Fill)
.apply(scrollable) .apply(scrollable)
.into() .into()
@ -601,9 +607,10 @@ impl SettingsApp {
Message::Page(parent), Message::Page(parent),
); );
let mut page_header_content = row::with_capacity(2) let mut page_header_content: cosmic::iced_widget::Row<'_, Message, Theme> =
.align_items(iced::Alignment::End) row::with_capacity(2)
.push(page_header); .align_items(iced::Alignment::End)
.push(page_header);
if let Some(element) = page.header_view() { if let Some(element) = page.header_view() {
page_header_content = page_header_content.push(element.map(Message::from)); page_header_content = page_header_content.push(element.map(Message::from));
@ -622,7 +629,7 @@ impl SettingsApp {
); );
} }
settings::view_column(column_widgets).padding(0).into() settings::view_column(column_widgets).into()
} }
fn search_changed(&mut self, phrase: String) { fn search_changed(&mut self, phrase: String) {
@ -676,7 +683,7 @@ impl SettingsApp {
let section = (section.view_fn)(&self.pages, model.as_ref(), section) let section = (section.view_fn)(&self.pages, model.as_ref(), section)
.map(Message::PageMessage) .map(Message::PageMessage)
.apply(iced::widget::container) .apply(iced::widget::container)
.padding([0, 0, 0, 48]); .padding([0, 0, 0, cosmic::theme::active().cosmic().space_xl()]);
sections.push(section.into()); sections.push(section.into());
} }
@ -686,7 +693,9 @@ impl SettingsApp {
/// Displays the sub-pages view of a page. /// Displays the sub-pages view of a page.
fn sub_page_view(&self, sub_pages: &[page::Entity]) -> cosmic::Element<Message> { fn sub_page_view(&self, sub_pages: &[page::Entity]) -> cosmic::Element<Message> {
let mut page_list = column::with_capacity(sub_pages.len()).spacing(18); let theme = cosmic::theme::active();
let mut page_list =
column::with_capacity(sub_pages.len()).spacing(theme.cosmic().space_s());
for entity in sub_pages.iter().copied() { for entity in sub_pages.iter().copied() {
let sub_page = &self.pages.info[entity]; let sub_page = &self.pages.info[entity];
@ -701,7 +710,8 @@ impl SettingsApp {
column::with_capacity(2) column::with_capacity(2)
.push(page_title(&self.pages.info[self.active_page])) .push(page_title(&self.pages.info[self.active_page]))
.push(Element::from(page_list).map(Message::Page)) .push(Element::from(page_list).map(Message::Page))
.spacing(24) .spacing(theme.cosmic().space_m())
.padding(0)
.into() .into()
} }
} }

View file

@ -362,9 +362,14 @@ impl Page {
/// View for the display arrangement section. /// View for the display arrangement section.
pub fn display_arrangement_view(&self) -> Element<pages::Message> { pub fn display_arrangement_view(&self) -> Element<pages::Message> {
let theme = cosmic::theme::active();
column() column()
.padding(cosmic::iced::Padding::from([16, 24])) .padding(cosmic::iced::Padding::from([
.spacing(10) theme.cosmic().space_s(),
theme.cosmic().space_m(),
]))
.spacing(theme.cosmic().space_xs())
.push(cosmic::widget::text::body(&*text::DISPLAY_ARRANGEMENT_DESC)) .push(cosmic::widget::text::body(&*text::DISPLAY_ARRANGEMENT_DESC))
.push({ .push({
Arrangement::new(&self.list, &self.display_tabs) Arrangement::new(&self.list, &self.display_tabs)
@ -383,6 +388,8 @@ impl Page {
/// View for the display configuration section. /// View for the display configuration section.
pub fn display_view(&self) -> Element<pages::Message> { pub fn display_view(&self) -> Element<pages::Message> {
let theme = cosmic::theme::active();
let Some(&active_id) = self.display_tabs.active_data::<OutputKey>() else { let Some(&active_id) = self.display_tabs.active_data::<OutputKey>() else {
return column().into(); return column().into();
}; };
@ -436,7 +443,7 @@ impl Page {
)); ));
column() column()
.spacing(24) .spacing(theme.cosmic().space_m())
.push(view_switcher::horizontal(&self.display_tabs).on_activate(Message::Display)) .push(view_switcher::horizontal(&self.display_tabs).on_activate(Message::Display))
.push(display_meta) .push(display_meta)
.push(cosmic::widget::text::heading(&*text::DISPLAY_OPTIONS)) .push(cosmic::widget::text::heading(&*text::DISPLAY_OPTIONS))
@ -541,7 +548,7 @@ impl Page {
.iter() .iter()
.filter_map(|&id| self.list.modes.get(id).map(|m| (id, m))) .filter_map(|&id| self.list.modes.get(id).map(|m| (id, m)))
{ {
let refresh_rates = self.cache.modes.entry(mode.size).or_insert_with(Vec::new); let refresh_rates = self.cache.modes.entry(mode.size).or_default();
refresh_rates.push(mode.refresh_rate); refresh_rates.push(mode.refresh_rate);