From 18b9be0baa2a833ab4142e4bb16e30dda762f0f0 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 15 Aug 2023 17:16:49 -0400 Subject: [PATCH] update: iced 0.10.0 --- Cargo.toml | 2 ++ examples/cosmic-sctk/src/window.rs | 37 +++++++++++++++++++++++++++--- src/widget/mod.rs | 4 ++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 28c771d6..40370222 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,3 +124,5 @@ exclude = [ [patch."https://github.com/pop-os/libcosmic"] libcosmic = { path = "./", features = ["wayland", "tokio", "a11y"]} +[patch."https://github.com/pop-os/cosmic-time"] +cosmic-time = { path = "../cosmic-time"} diff --git a/examples/cosmic-sctk/src/window.rs b/examples/cosmic-sctk/src/window.rs index 76a857d0..66315f1b 100644 --- a/examples/cosmic-sctk/src/window.rs +++ b/examples/cosmic-sctk/src/window.rs @@ -15,7 +15,7 @@ use cosmic::{ widget::{ button, cosmic_container, header_bar, nav_bar, nav_bar_toggle, rectangle_tracker::{rectangle_tracker_subscription, RectangleTracker, RectangleUpdate}, - scrollable, segmented_button, segmented_selection, settings, IconSource, + scrollable, segmented_button, segmented_selection, settings, text_input, IconSource, }, Element, ElementExt, }; @@ -127,6 +127,7 @@ pub struct Window { rectangle_tracker: Option>, pub selection: segmented_button::SingleSelectModel, timeline: Timeline, + input_value: String, } impl Window { @@ -183,12 +184,12 @@ pub enum Message { Drag, Minimize, Maximize, - InputChanged, Rectangle(RectangleUpdate), NavBar(segmented_button::Entity), Ignore, Selection(segmented_button::Entity), Tick(Instant), + InputChanged(String), } impl Window { @@ -305,7 +306,6 @@ impl Application for Window { Message::Minimize => return set_mode_window(window::Id(0), window::Mode::Hidden), Message::Maximize => return toggle_maximize(window::Id(0)), Message::RowSelected(row) => println!("Selected row {row}"), - Message::InputChanged => {} Message::Rectangle(r) => match r { RectangleUpdate::Rectangle(_) => {} RectangleUpdate::Init(t) => { @@ -315,6 +315,9 @@ impl Application for Window { Message::Ignore => {} Message::Selection(key) => self.selection.activate(key), Message::Tick(now) => self.timeline.now(now), + Message::InputChanged(v) => { + self.input_value = v; + } } Command::none() @@ -476,6 +479,34 @@ impl Application for Window { .padding(16) .style(cosmic::theme::Container::Secondary), )) + .add(settings::item( + "Text Input", + text_input("test", &self.input_value) + .width(Length::Fill) + .on_input(Message::InputChanged), + )) + .add(settings::item( + "Text Input", + text_input("test", &self.input_value) + .label("Test Label") + .helper_text("helper_text") + .width(Length::Fill) + .on_input(Message::InputChanged), + )) + // .add(settings::item( + // "Text Input", + // text_input("test", &self.input_value) + // .helper_text("helper_text") + // .width(Length::Fill) + // .on_input(Message::InputChanged), + // )) + // .add(settings::item( + // "Text Input", + // text_input("test", &self.input_value) + // .helper_text("helper_text") + // .width(Length::Fill) + // .on_input(Message::InputChanged), + // )) .into(), ]) .into(); diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 5e96cdf9..708808d4 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -70,6 +70,10 @@ pub use warning::*; pub mod cosmic_container; pub use cosmic_container::*; +#[cfg(feature = "wayland")] +pub mod text_input; +#[cfg(feature = "wayland")] +pub use text_input::*; /// An element to distinguish a boundary between two elements. pub mod divider {