fix!(widget): rename button function to button::custom

This commit is contained in:
Michael Aaron Murphy 2024-09-16 19:11:29 +02:00 committed by Jeremy Soller
parent 914d989049
commit f12de010ec
15 changed files with 28 additions and 32 deletions

View file

@ -197,7 +197,7 @@ impl Context {
}
let symbolic = icon.symbolic;
crate::widget::button(
crate::widget::button::custom(
layer_container(
widget::icon(icon)
.style(if symbolic {
@ -417,7 +417,7 @@ pub fn style() -> <crate::Theme as iced_style::application::StyleSheet>::Style {
pub fn menu_button<'a, Message>(
content: impl Into<Element<'a, Message>>,
) -> crate::widget::Button<'a, Message> {
crate::widget::button(content)
crate::widget::button::custom(content)
.style(Button::AppletMenu)
.padding(menu_control_padding())
.width(Length::Fill)

View file

@ -3,12 +3,8 @@
//! Subscribe to common application keyboard shortcuts.
use iced::{event, keyboard, mouse, Command, Event, Subscription};
use iced_core::{
keyboard::key::Named,
widget::{operation, Id, Operation},
Rectangle,
};
use iced::{event, keyboard, Event, Subscription};
use iced_core::keyboard::key::Named;
use iced_futures::event::listen_raw;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use super::{button, Builder, Style};
use super::{Builder, Style};
use crate::widget::{
icon::{self, Handle},
tooltip,
@ -159,7 +159,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.padding(builder.padding)
.spacing(builder.spacing)
.align_items(Alignment::Center)
.apply(button)
.apply(super::custom)
} else {
crate::widget::row::with_children(content)
.padding(builder.padding)
@ -167,7 +167,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.height(builder.height)
.spacing(builder.spacing)
.align_items(Alignment::Center)
.apply(button)
.apply(super::custom)
};
let button = button

View file

@ -82,7 +82,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.height(builder.height)
.spacing(builder.spacing)
.align_items(Alignment::Center)
.apply(button)
.apply(button::custom)
.padding(0)
.id(builder.id)
.on_press_maybe(builder.on_press.take())

View file

@ -43,8 +43,8 @@ use iced_core::widget::Id;
use iced_core::{Length, Padding};
use std::borrow::Cow;
/// A button with the default style, which may contain any widget as its content.
pub fn button<'a, Message>(content: impl Into<crate::Element<'a, Message>>) -> Button<'a, Message> {
/// A button with a custom element for its content.
pub fn custom<'a, Message>(content: impl Into<crate::Element<'a, Message>>) -> Button<'a, Message> {
Button::new(content)
}

View file

@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use super::{button, Builder, Style};
use super::{Builder, Style};
use crate::widget::{icon, row, tooltip};
use crate::{ext::CollectionWidget, Element};
use apply::Apply;
@ -124,7 +124,7 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
.height(builder.height)
.spacing(builder.spacing)
.align_items(Alignment::Center)
.apply(button)
.apply(super::custom)
.padding(0)
.id(builder.id)
.on_press_maybe(builder.on_press.take())

View file

@ -143,7 +143,7 @@ fn date_button<Message>(
button::Style::Text
};
let button = button(
let button = button::custom(
text(format!("{}", date.day()))
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center),

View file

@ -369,7 +369,7 @@ where
)
// TODO copy paste input contents
.trailing_icon({
let button = button(crate::widget::icon(
let button = button::custom(crate::widget::icon(
from_name("edit-copy-symbolic").size(spacing.space_s).into(),
))
.on_press(on_update(ColorPickerUpdate::Copied(Instant::now())))
@ -442,7 +442,7 @@ where
inner = inner.push(
column![
horizontal::light().width(self.width),
button(
button::custom(
text(reset_to_default)
.width(self.width)
.horizontal_alignment(iced_core::alignment::Horizontal::Center)
@ -458,14 +458,14 @@ where
inner = inner.push(
column![
horizontal::light().width(self.width),
button(
button::custom(
text(cancel)
.width(self.width)
.horizontal_alignment(iced_core::alignment::Horizontal::Center)
)
.width(self.width)
.on_press(on_update(ColorPickerUpdate::Cancel)),
button(
button::custom(
text(save)
.width(self.width)
.horizontal_alignment(iced_core::alignment::Horizontal::Center)
@ -781,7 +781,7 @@ pub fn color_button<'a, Message: 'static>(
) -> crate::widget::Button<'a, Message> {
let spacing = THEME.lock().unwrap().cosmic().spacing;
button(if color.is_some() {
button::custom(if color.is_some() {
Element::from(vertical_space(Length::Fixed(f32::from(spacing.space_s))))
} else {
Element::from(column![

View file

@ -143,7 +143,7 @@ where
pub fn menu_button<'a, Message: 'a>(
children: Vec<crate::Element<'a, Message>>,
) -> crate::widget::Button<'a, Message> {
widget::button(
widget::button::custom(
widget::Row::with_children(children)
.align_items(Alignment::Center)
.height(Length::Fill)
@ -192,7 +192,7 @@ pub fn menu_root<'a, Message, Renderer: renderer::Renderer>(
where
Element<'a, Message, crate::Theme, Renderer>: From<widget::Button<'a, Message>>,
{
widget::button(widget::text(label))
widget::button::custom(widget::text(label))
.padding([4, 12])
.style(theme::Button::MenuRoot)
.into()

View file

@ -96,7 +96,7 @@ pub mod aspect_ratio;
pub mod button;
#[doc(inline)]
pub use button::{button, Button, IconButton, LinkButton, TextButton};
pub use button::{Button, IconButton, LinkButton, TextButton};
pub(crate) mod common;

View file

@ -4,9 +4,7 @@
//! A button for toggling the navigation side panel.
use crate::{widget, Element};
use apply::Apply;
use derive_setters::Setters;
use iced::Length;
#[derive(Setters)]
pub struct NavBarToggle<Message> {

View file

@ -8,7 +8,6 @@ use crate::{
Element,
};
use derive_setters::Setters;
use iced::alignment::Horizontal;
use iced_core::{text::Wrap, Length};
use taffy::AlignContent;

View file

@ -53,7 +53,7 @@ impl<'a, Message: 'static> SpinButton<'a, Message> {
.height(Length::Fixed(32.0))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.apply(button)
.apply(button::custom)
.width(Length::Fixed(32.0))
.height(Length::Fixed(32.0))
.style(theme::Button::Text)
@ -73,7 +73,7 @@ impl<'a, Message: 'static> SpinButton<'a, Message> {
.height(Length::Fixed(32.0))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.apply(button)
.apply(button::custom)
.width(Length::Fixed(32.0))
.height(Length::Fixed(32.0))
.style(theme::Button::Text)

View file

@ -145,7 +145,7 @@ where
"image-red-eye-symbolic"
})
.size(16)
.apply(crate::widget::button)
.apply(crate::widget::button::custom)
.style(crate::theme::Button::Icon)
.on_press(msg)
.padding([spacing, spacing, spacing, spacing])
@ -501,7 +501,7 @@ where
self.trailing_icon(
crate::widget::icon::from_name("edit-clear-symbolic")
.size(16)
.apply(crate::widget::button)
.apply(crate::widget::button::custom)
.style(crate::theme::Button::Icon)
.width(32)
.height(32)

View file

@ -80,6 +80,7 @@ pub enum Duration {
}
impl Duration {
#[cfg(feature = "tokio")]
fn duration(&self) -> std::time::Duration {
match self {
Duration::Short => std::time::Duration::from_millis(5000),
@ -183,7 +184,9 @@ impl<Message: Clone + Send + 'static> Toasts<Message> {
);
}
#[cfg(feature = "tokio")]
let duration = toast.duration.duration();
let id = self.toasts.insert(toast);
self.queue.push_back(id);