chore(widget): use Row type in settings::item
This commit is contained in:
parent
03a5c929fd
commit
4564c36c83
1 changed files with 5 additions and 5 deletions
|
|
@ -5,7 +5,7 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
widget::{column, horizontal_space, row, text, Row},
|
widget::{column, horizontal_space, row, text, Row},
|
||||||
Element, Renderer,
|
Element,
|
||||||
};
|
};
|
||||||
use derive_setters::Setters;
|
use derive_setters::Setters;
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ use derive_setters::Setters;
|
||||||
pub fn item<'a, Message: 'static>(
|
pub fn item<'a, Message: 'static>(
|
||||||
title: impl Into<Cow<'a, str>> + 'a,
|
title: impl Into<Cow<'a, str>> + 'a,
|
||||||
widget: impl Into<Element<'a, Message>> + 'a,
|
widget: impl Into<Element<'a, Message>> + 'a,
|
||||||
) -> Row<'a, Message, Renderer> {
|
) -> Row<'a, Message> {
|
||||||
item_row(vec![
|
item_row(vec![
|
||||||
text(title).into(),
|
text(title).into(),
|
||||||
horizontal_space(iced::Length::Fill).into(),
|
horizontal_space(iced::Length::Fill).into(),
|
||||||
|
|
@ -26,7 +26,7 @@ pub fn item<'a, Message: 'static>(
|
||||||
/// A settings item aligned in a row
|
/// A settings item aligned in a row
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::module_name_repetitions)]
|
#[allow(clippy::module_name_repetitions)]
|
||||||
pub fn item_row<Message>(children: Vec<Element<Message>>) -> Row<Message, Renderer> {
|
pub fn item_row<Message>(children: Vec<Element<Message>>) -> Row<Message> {
|
||||||
row::with_children(children)
|
row::with_children(children)
|
||||||
.align_items(iced::Alignment::Center)
|
.align_items(iced::Alignment::Center)
|
||||||
.padding([0, 18])
|
.padding([0, 18])
|
||||||
|
|
@ -59,7 +59,7 @@ pub struct Item<'a, Message> {
|
||||||
|
|
||||||
impl<'a, Message: 'static> Item<'a, Message> {
|
impl<'a, Message: 'static> Item<'a, Message> {
|
||||||
/// Assigns a control to the item.
|
/// Assigns a control to the item.
|
||||||
pub fn control(self, widget: impl Into<Element<'a, Message>>) -> Row<'a, Message, Renderer> {
|
pub fn control(self, widget: impl Into<Element<'a, Message>>) -> Row<'a, Message> {
|
||||||
let mut contents = Vec::with_capacity(4);
|
let mut contents = Vec::with_capacity(4);
|
||||||
|
|
||||||
if let Some(icon) = self.icon {
|
if let Some(icon) = self.icon {
|
||||||
|
|
@ -87,7 +87,7 @@ impl<'a, Message: 'static> Item<'a, Message> {
|
||||||
self,
|
self,
|
||||||
is_checked: bool,
|
is_checked: bool,
|
||||||
message: impl Fn(bool) -> Message + 'static,
|
message: impl Fn(bool) -> Message + 'static,
|
||||||
) -> Row<'a, Message, Renderer> {
|
) -> Row<'a, Message> {
|
||||||
self.control(crate::widget::toggler(None, is_checked, message))
|
self.control(crate::widget::toggler(None, is_checked, message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue