fix!(widget): rename button function to button::custom
This commit is contained in:
parent
914d989049
commit
f12de010ec
15 changed files with 28 additions and 32 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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![
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use crate::{
|
|||
Element,
|
||||
};
|
||||
use derive_setters::Setters;
|
||||
use iced::alignment::Horizontal;
|
||||
use iced_core::{text::Wrap, Length};
|
||||
use taffy::AlignContent;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue