update(example): add button to cards and update cosmic-time
This commit is contained in:
parent
785861a630
commit
e24465ba37
3 changed files with 14 additions and 3 deletions
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue