update(example): add button to cards and update cosmic-time

This commit is contained in:
Ashley Wulber 2023-07-21 12:37:17 -04:00 committed by Ian Douglas Scott
parent 785861a630
commit e24465ba37
3 changed files with 14 additions and 3 deletions

View file

@ -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),