feat!(widget): rewrite button & icon widget APIs
This commit is contained in:
parent
18debe546d
commit
4e4eeaac12
60 changed files with 2191 additions and 1113 deletions
|
|
@ -3,16 +3,18 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::{widget::text, Element, Renderer};
|
||||
use crate::{
|
||||
widget::{column, horizontal_space, row, text, Row},
|
||||
Element, Renderer,
|
||||
};
|
||||
use derive_setters::Setters;
|
||||
use iced::widget::{column, horizontal_space, row, Row};
|
||||
|
||||
/// A settings item aligned in a row
|
||||
#[must_use]
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub fn item<'a, Message: 'static>(
|
||||
title: impl Into<Cow<'a, str>>,
|
||||
widget: impl Into<Element<'a, Message>>,
|
||||
title: impl Into<Cow<'a, str>> + 'a,
|
||||
widget: impl Into<Element<'a, Message>> + 'a,
|
||||
) -> Row<'a, Message, Renderer> {
|
||||
item_row(vec![
|
||||
text(title).into(),
|
||||
|
|
@ -25,7 +27,7 @@ pub fn item<'a, Message: 'static>(
|
|||
#[must_use]
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub fn item_row<Message>(children: Vec<Element<Message>>) -> Row<Message, Renderer> {
|
||||
row(children)
|
||||
row::with_children(children)
|
||||
.align_items(iced::Alignment::Center)
|
||||
.padding([0, 18])
|
||||
.spacing(12)
|
||||
|
|
@ -65,10 +67,12 @@ impl<'a, Message: 'static> Item<'a, Message> {
|
|||
}
|
||||
|
||||
if let Some(description) = self.description {
|
||||
let title = text(self.title);
|
||||
let desc = text(description).size(10);
|
||||
let column = column::with_capacity(2)
|
||||
.spacing(2)
|
||||
.push(text(self.title))
|
||||
.push(text(description).size(10));
|
||||
|
||||
contents.push(column!(title, desc).spacing(2).into());
|
||||
contents.push(column.into());
|
||||
} else {
|
||||
contents.push(text(self.title).into());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ mod section;
|
|||
pub use self::item::{item, item_row};
|
||||
pub use self::section::{view_section, Section};
|
||||
|
||||
use crate::widget::{column, Column};
|
||||
use crate::{Element, Renderer};
|
||||
use iced::widget::{column, Column};
|
||||
|
||||
/// A column with a predefined style for creating a settings panel
|
||||
#[must_use]
|
||||
pub fn view_column<Message: 'static>(children: Vec<Element<Message>>) -> Column<Message, Renderer> {
|
||||
column(children).spacing(24).padding([0, 24]).max_width(678)
|
||||
column::with_children(children)
|
||||
.spacing(24)
|
||||
.padding([0, 24])
|
||||
.max_width(678)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::widget::ListColumn;
|
||||
use crate::widget::{column, text, ListColumn};
|
||||
use crate::Element;
|
||||
use iced::widget::{column, text};
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// A section within a settings view column.
|
||||
|
|
@ -31,10 +30,10 @@ impl<'a, Message: 'static> Section<'a, Message> {
|
|||
|
||||
impl<'a, Message: 'static> From<Section<'a, Message>> for Element<'a, Message> {
|
||||
fn from(data: Section<'a, Message>) -> Self {
|
||||
let title = text(data.title).font(crate::font::FONT_SEMIBOLD).into();
|
||||
|
||||
column(vec![title, data.children.into_element()])
|
||||
column::with_capacity(2)
|
||||
.spacing(8)
|
||||
.push(text(data.title).font(crate::font::FONT_SEMIBOLD))
|
||||
.push(data.children)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue