From e24465ba37a6d5970238edcd90e79bb4d9fc9ae7 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 21 Jul 2023 12:37:17 -0400 Subject: [PATCH] update(example): add button to cards and update cosmic-time --- examples/cosmic-sctk/Cargo.toml | 2 +- examples/cosmic/Cargo.toml | 2 +- examples/cosmic/src/window/demo.rs | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/cosmic-sctk/Cargo.toml b/examples/cosmic-sctk/Cargo.toml index 4f290f4a..cb9332bd 100644 --- a/examples/cosmic-sctk/Cargo.toml +++ b/examples/cosmic-sctk/Cargo.toml @@ -7,5 +7,5 @@ publish = false [dependencies] libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "a11y"] } -cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev="178637c", default-features = false, features = ["libcosmic", "once_cell"] } +cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev="c39e737", default-features = false, features = ["libcosmic", "once_cell"] } # cosmic-time = { path = "../../../cosmic-time", default-features = false, features = ["libcosmic", "once_cell"] } diff --git a/examples/cosmic/Cargo.toml b/examples/cosmic/Cargo.toml index 1c2100a9..0eed3000 100644 --- a/examples/cosmic/Cargo.toml +++ b/examples/cosmic/Cargo.toml @@ -13,4 +13,4 @@ once_cell = "1.18" slotmap = "1.0.6" env_logger = "0.10" log = "0.4.17" -cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev="178637c", default-features = false, features = ["libcosmic", "once_cell"] } +cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev="c39e737", default-features = false, features = ["libcosmic", "once_cell"] } diff --git a/examples/cosmic/src/window/demo.rs b/examples/cosmic/src/window/demo.rs index ccf18f0e..bd0da06c 100644 --- a/examples/cosmic/src/window/demo.rs +++ b/examples/cosmic/src/window/demo.rs @@ -81,6 +81,7 @@ pub enum Message { TogglerToggled(bool), ViewSwitcher(segmented_button::Entity), InputChanged(String), + DeleteCard(usize), ClearAll, CardsToggled(bool), } @@ -196,6 +197,9 @@ impl State { self.cards_value = v; self.update_cards(); } + Message::DeleteCard(i) => { + self.cards.remove(i); + } } None @@ -466,7 +470,14 @@ impl State { &timeline, self.cards .iter() - .map(|c| column![text("test"), text(c).size(24).width(Length::Fill)].into()) + .enumerate() + .map(|(i, c)| column![ + button(cosmic::theme::Button::Text) + .text("Delete me") + .on_press(Message::DeleteCard(i)), + text(c).size(24).width(Length::Fill) + ] + .into()) .collect(), Message::ClearAll, |_, e| Message::CardsToggled(e),