Updated segmented button to latest changes.

This commit is contained in:
Eduardo Flores 2022-12-06 11:43:27 -07:00
parent f5aa75b823
commit ccde98d797
2 changed files with 6 additions and 37 deletions

View file

@ -3,7 +3,7 @@
use cosmic::{ use cosmic::{
iced::widget::{ iced::widget::{
column, container, horizontal_space, pick_list, progress_bar, radio, row, slider, column, container, horizontal_space, pick_list, progress_bar, radio, row, slider, checkbox,
}, },
iced::{self, Alignment, Application, Command, Length}, iced::{self, Alignment, Application, Command, Length},
iced_lazy::responsive, iced_lazy::responsive,
@ -288,38 +288,7 @@ impl Application for Window {
checkbox("Checkbox", self.checkbox_value, Message::CheckboxToggled) checkbox("Checkbox", self.checkbox_value, Message::CheckboxToggled)
)) ))
.into(), .into(),
settings::view_section("Expander") ]).into();
.add(settings::item(
"Expander",
expander()
.title("Label")
.subtitle("Caption")
.icon(String::from("edit-paste"))
.on_row_selected(Box::new(Message::RowSelected))
.rows(vec![
list_row()
.title("Label")
.subtitle("Caption")
.icon(String::from("help-about")),
list_row().subtitle("Caption").title("Label"),
list_row().title("Label")
])
)).into(),
settings::view_section("List Box")
.add(settings::item(
"List Box",
list_box()
.style(theme::Container::Custom(list_section_style))
.children(vec![
cosmic::list_box_row!("Title").into(),
cosmic::list_box_row!("Title", "Subtitle").into(),
cosmic::list_box_row!("Title", "", "edit-paste").into(),
cosmic::list_box_row!("", "Subtitle", "edit-paste").into(),
cosmic::list_box_row!("Title", "Subtitle", "edit-paste").into()
])
.render()
)).into(),
]);
let mut widgets = Vec::with_capacity(2); let mut widgets = Vec::with_capacity(2);

View file

@ -1,11 +1,11 @@
use derive_setters::Setters; use derive_setters::Setters;
use iced::{ use iced::{
alignment::{Horizontal, Vertical}, alignment::{Horizontal, Vertical},
theme,
widget::{button, container, text, Row}, widget::{button, container, text, Row},
Background, Element, Length, Renderer, Theme, Color, Background, Length, Color,
}; };
use iced_lazy::Component; use iced_lazy::Component;
use crate::{theme, Theme, Renderer, Element};
#[derive(Setters)] #[derive(Setters)]
pub struct SegmentedButton<'a, Message> { pub struct SegmentedButton<'a, Message> {
@ -58,9 +58,9 @@ impl<'a, Message> Component<Message, Renderer> for SegmentedButton<'a, Message>
.width(Length::Units(136)) .width(Length::Units(136))
.height(Length::Units(32)) .height(Length::Units(32))
.style(if *state == index { .style(if *state == index {
theme::Button::Primary.into() theme::Button::Primary
} else { } else {
theme::Button::Secondary.into() theme::Button::Secondary
}) })
.on_press(SegmentedButtonEvent::Pressed(index)) .on_press(SegmentedButtonEvent::Pressed(index))
.into() .into()