chore: use theme::spacing() where applicable

This commit is contained in:
Vukašin Vojinović 2025-04-01 21:13:52 +02:00 committed by Michael Murphy
parent 227f7a76b1
commit 1486569481
12 changed files with 22 additions and 26 deletions

View file

@ -131,7 +131,7 @@ impl Application for SpinButtonExamplApp {
} }
fn view(&self) -> Element<Self::Message> { fn view(&self) -> Element<Self::Message> {
let space_xs = cosmic::theme::active().cosmic().spacing.space_xs; let space_xs = cosmic::theme::spacing().space_xs;
let vert_spinner_row = iced::widget::row![ let vert_spinner_row = iced::widget::row![
spin_button::vertical(&self.i8_str, self.i8_num, 1, -5, 5, Message::UpdateI8), spin_button::vertical(&self.i8_str, self.i8_num, 1, -5, 5, Message::UpdateI8),

View file

@ -53,7 +53,7 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
space_m, space_m,
space_l, space_l,
.. ..
} = crate::theme::active().cosmic().spacing; } = crate::theme::spacing();
let horizontal_padding = if max_width < 392.0 { space_s } else { space_l }; let horizontal_padding = if max_width < 392.0 { space_s } else { space_l };

View file

@ -292,7 +292,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
space_xxxs, space_xxxs,
space_xxs, space_xxs,
.. ..
} = theme::active().cosmic().spacing; } = theme::spacing();
// Take ownership of the regions to be packed. // Take ownership of the regions to be packed.
let start = std::mem::take(&mut self.start); let start = std::mem::take(&mut self.start);
@ -434,7 +434,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
.take() .take()
.map(|m| icon!("window-close-symbolic", 16, m)), .map(|m| icon!("window-close-symbolic", 16, m)),
) )
.spacing(theme::active().cosmic().space_xxs()) .spacing(theme::spacing().space_xxs)
.apply(widget::container) .apply(widget::container)
.center_y(Length::Fill) .center_y(Length::Fill)
.into() .into()

View file

@ -28,7 +28,7 @@ impl<Message: 'static> Default for ListColumn<'_, Message> {
fn default() -> Self { fn default() -> Self {
let cosmic_theme::Spacing { let cosmic_theme::Spacing {
space_xxs, space_m, .. space_xxs, space_m, ..
} = theme::active().cosmic().spacing; } = theme::spacing();
Self { Self {
spacing: 0, spacing: 0,

View file

@ -240,7 +240,7 @@ where
.enumerate() .enumerate()
.flat_map(|(i, item)| { .flat_map(|(i, item)| {
let mut trees = vec![]; let mut trees = vec![];
let spacing = crate::theme::active().cosmic().spacing; let spacing = crate::theme::spacing();
match item { match item {
MenuItem::Button(label, icon, action) => { MenuItem::Button(label, icon, action) => {

View file

@ -18,7 +18,7 @@
//! //!
//! const REPOSITORY: &str = "https://github.com/pop-os/libcosmic"; //! const REPOSITORY: &str = "https://github.com/pop-os/libcosmic";
//! //!
//! let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing; //! let cosmic_theme::Spacing { space_xxs, .. } = theme::spacing();
//! //!
//! let link = widget::button::link(REPOSITORY) //! let link = widget::button::link(REPOSITORY)
//! .on_press(Message::LaunchUrl(REPOSITORY)) //! .on_press(Message::LaunchUrl(REPOSITORY))
@ -364,7 +364,7 @@ pub mod tooltip {
tooltip: impl Into<Element<'a, Message>>, tooltip: impl Into<Element<'a, Message>>,
position: Position, position: Position,
) -> Tooltip<'a, Message> { ) -> Tooltip<'a, Message> {
let xxs = crate::theme::active().cosmic().space_xxs(); let xxs = crate::theme::spacing().space_xxs;
Tooltip::new(content, tooltip, position) Tooltip::new(content, tooltip, position)
.class(crate::theme::Container::Tooltip) .class(crate::theme::Container::Tooltip)

View file

@ -20,9 +20,8 @@ pub fn horizontal<SelectionMode: Default, Message>(
where where
Model<SelectionMode>: Selectable, Model<SelectionMode>: Selectable,
{ {
let theme = crate::theme::active(); let space_s = crate::theme::spacing().space_s;
let space_s = theme.cosmic().space_s(); let space_xxs = crate::theme::spacing().space_xxs;
let space_xxs = theme.cosmic().space_xxs();
segmented_button::horizontal(model) segmented_button::horizontal(model)
.button_alignment(iced::Alignment::Center) .button_alignment(iced::Alignment::Center)
@ -46,9 +45,8 @@ where
Model<SelectionMode>: Selectable, Model<SelectionMode>: Selectable,
SelectionMode: Default, SelectionMode: Default,
{ {
let theme = crate::theme::active(); let space_s = crate::theme::spacing().space_s;
let space_s = theme.cosmic().space_s(); let space_xxs = crate::theme::spacing().space_xxs;
let space_xxs = theme.cosmic().space_xxs();
segmented_button::vertical(model) segmented_button::vertical(model)
.button_alignment(iced::Alignment::Center) .button_alignment(iced::Alignment::Center)

View file

@ -38,7 +38,7 @@ pub fn item<'a, Message: 'static>(
#[allow(clippy::module_name_repetitions)] #[allow(clippy::module_name_repetitions)]
pub fn item_row<Message>(children: Vec<Element<Message>>) -> Row<Message> { pub fn item_row<Message>(children: Vec<Element<Message>>) -> Row<Message> {
row::with_children(children) row::with_children(children)
.spacing(theme::active().cosmic().space_xs()) .spacing(theme::spacing().space_xs)
.align_y(iced::Alignment::Center) .align_y(iced::Alignment::Center)
} }
@ -69,7 +69,7 @@ pub fn flex_item<'a, Message: 'static>(
#[allow(clippy::module_name_repetitions)] #[allow(clippy::module_name_repetitions)]
pub fn flex_item_row<Message>(children: Vec<Element<Message>>) -> FlexRow<Message> { pub fn flex_item_row<Message>(children: Vec<Element<Message>>) -> FlexRow<Message> {
flex_row(children) flex_row(children)
.spacing(theme::active().cosmic().space_xs()) .spacing(theme::spacing().space_xs)
.min_item_width(200.0) .min_item_width(200.0)
.justify_items(iced::Alignment::Center) .justify_items(iced::Alignment::Center)
.justify_content(AlignContent::SpaceBetween) .justify_content(AlignContent::SpaceBetween)

View file

@ -13,5 +13,5 @@ use crate::{Element, theme};
/// A column with a predefined style for creating a settings panel /// A column with a predefined style for creating a settings panel
#[must_use] #[must_use]
pub fn view_column<Message: 'static>(children: Vec<Element<Message>>) -> Column<Message> { pub fn view_column<Message: 'static>(children: Vec<Element<Message>>) -> Column<Message> {
column::with_children(children).spacing(theme::active().cosmic().space_m()) column::with_children(children).spacing(theme::spacing().space_m)
} }

View file

@ -20,9 +20,8 @@ pub fn horizontal<SelectionMode: Default, Message>(
where where
Model<SelectionMode>: Selectable, Model<SelectionMode>: Selectable,
{ {
let theme = crate::theme::active(); let space_s = crate::theme::spacing().space_s;
let space_s = theme.cosmic().space_s(); let space_xs = crate::theme::spacing().space_xs;
let space_xs = theme.cosmic().space_xs();
segmented_button::horizontal(model) segmented_button::horizontal(model)
.minimum_button_width(76) .minimum_button_width(76)
@ -44,9 +43,8 @@ where
Model<SelectionMode>: Selectable, Model<SelectionMode>: Selectable,
SelectionMode: Default, SelectionMode: Default,
{ {
let theme = crate::theme::active(); let space_s = crate::theme::spacing().space_s;
let space_s = theme.cosmic().space_s(); let space_xs = crate::theme::spacing().space_xs;
let space_xs = theme.cosmic().space_xs();
SegmentedButton::new(model) SegmentedButton::new(model)
.minimum_button_width(76) .minimum_button_width(76)

View file

@ -57,7 +57,7 @@ where
Message: Clone + 'static, Message: Clone + 'static,
{ {
fn from(val: CompactTableView<'a, SelectionMode, Item, Category, Message>) -> Self { fn from(val: CompactTableView<'a, SelectionMode, Item, Category, Message>) -> Self {
let cosmic_theme::Spacing { space_xxxs, .. } = theme::active().cosmic().spacing; let cosmic_theme::Spacing { space_xxxs, .. } = theme::spacing();
val.model val.model
.iter() .iter()
.map(|entity| { .map(|entity| {
@ -193,7 +193,7 @@ where
space_xxxs, space_xxxs,
space_xxs, space_xxs,
.. ..
} = theme::active().cosmic().spacing; } = theme::spacing();
Self { Self {
model, model,

View file

@ -264,7 +264,7 @@ where
space_xxxs, space_xxxs,
space_xxs, space_xxs,
.. ..
} = theme::active().cosmic().spacing; } = theme::spacing();
Self { Self {
model, model,