Skip to content

Commit

Permalink
Merge pull request #16 from francesco-gaglione/5-cancel-button-in-new…
Browse files Browse the repository at this point in the history
…-category-form

Cancel button in new category form
  • Loading branch information
francesco-gaglione authored Oct 19, 2024
2 parents 9094362 + da72cf1 commit ee406cd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pages/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum CategoriesMessage {
AddCategory,
NewCategoryNameChanged(String),
NewCategorySubmitted,
NewCategoryCancel,
NewCategoryTypeChanged(usize),
PreviousMonth,
NextMonth,
Expand Down Expand Up @@ -117,6 +118,12 @@ impl Categories {
.on_press(CategoriesMessage::NewCategorySubmitted)
.style(widget::button::Style::Suggested),
)
.push(widget::horizontal_space(Length::from(10)))
.push(
widget::button::text(fl!("cancel"))
.on_press(CategoriesMessage::NewCategoryCancel)
.style(widget::button::Style::Destructive),
)
.width(Length::Fill)
.align_items(Alignment::End),
)
Expand Down Expand Up @@ -209,12 +216,11 @@ impl Categories {
)
.push(widget::vertical_space(Length::from(10)));
}

element = element.push(widget::vertical_space(Length::from(10)));

element = element.push(widget::text::title4(fl!("expense-categories")));


for c in &self
.categories
.clone()
Expand Down Expand Up @@ -297,6 +303,10 @@ impl Categories {
CategoriesMessage::NewCategoryTypeChanged(value) => {
self.selected_category_type = Some(value);
}
CategoriesMessage::NewCategoryCancel => {
self.add_category_view = false;
self.form_new_category_name = "".to_string();
}
}
Command::batch(commands)
}
Expand Down

0 comments on commit ee406cd

Please sign in to comment.