From ccde98d797ba85dcb1a89df41953af252ee0fca5 Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Tue, 6 Dec 2022 11:43:27 -0700 Subject: [PATCH] Updated segmented button to latest changes. --- examples/cosmic/src/window.rs | 35 ++-------------------------------- src/widget/segmented_button.rs | 8 ++++---- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/examples/cosmic/src/window.rs b/examples/cosmic/src/window.rs index 1657822d..98e7196e 100644 --- a/examples/cosmic/src/window.rs +++ b/examples/cosmic/src/window.rs @@ -3,7 +3,7 @@ use cosmic::{ 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_lazy::responsive, @@ -288,38 +288,7 @@ impl Application for Window { checkbox("Checkbox", self.checkbox_value, Message::CheckboxToggled) )) .into(), - settings::view_section("Expander") - .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(), - ]); + ]).into(); let mut widgets = Vec::with_capacity(2); diff --git a/src/widget/segmented_button.rs b/src/widget/segmented_button.rs index 1a19ac8f..7fef1cfd 100644 --- a/src/widget/segmented_button.rs +++ b/src/widget/segmented_button.rs @@ -1,11 +1,11 @@ use derive_setters::Setters; use iced::{ alignment::{Horizontal, Vertical}, - theme, widget::{button, container, text, Row}, - Background, Element, Length, Renderer, Theme, Color, + Background, Length, Color, }; use iced_lazy::Component; +use crate::{theme, Theme, Renderer, Element}; #[derive(Setters)] pub struct SegmentedButton<'a, Message> { @@ -58,9 +58,9 @@ impl<'a, Message> Component for SegmentedButton<'a, Message> .width(Length::Units(136)) .height(Length::Units(32)) .style(if *state == index { - theme::Button::Primary.into() + theme::Button::Primary } else { - theme::Button::Secondary.into() + theme::Button::Secondary }) .on_press(SegmentedButtonEvent::Pressed(index)) .into()