From e0a7de1ef54e11682ee60c4bc17a4b1659ecdcfb Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sat, 29 Aug 2026 10:23:00 +0100 Subject: task-001: new transaction form is viewable (not interactive yet) --- .../src/gui/components/new_transaction_form.rs | 45 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'schist_desktop_gui/src') diff --git a/schist_desktop_gui/src/gui/components/new_transaction_form.rs b/schist_desktop_gui/src/gui/components/new_transaction_form.rs index 3625dcb..58509b1 100644 --- a/schist_desktop_gui/src/gui/components/new_transaction_form.rs +++ b/schist_desktop_gui/src/gui/components/new_transaction_form.rs @@ -1,24 +1,57 @@ -use iced::Element; +use iced::{Element, widget::row}; -use crate::{gui::components::Text, traits::{Component, Viewable}}; +use crate::{gui::components::{Text, button, input::input}, style::SPACING_SM, traits::{Component, Viewable}}; #[derive(Clone, Debug)] -pub struct NewTransactionForm {} +pub struct NewTransactionForm { + day: String, + month: String, + year: String, + bucket: String, + payee: String, + quantity: String, + submit_text: Text, +} #[derive(Clone, Debug)] -pub enum Message {} +pub enum Message { + DayInputChanged(String), + MonthInputChanged(String), + YearInputChanged(String), + BucketInputChanged(String), + PayeeInputChanged(String), + QuantityInputChanged(String), + Submit, +} pub enum Action { None } impl NewTransactionForm { pub fn new() -> Self { - Self {} + Self { + day: String::new(), + month: String::new(), + year: String::new(), + bucket: String::new(), + payee: String::new(), + quantity: String::new(), + submit_text: Text::new("+ Add"), + } } } impl<'a> Viewable<'a, Message> for NewTransactionForm { fn view(&'a self) -> Element<'a, Message> { - Text::new("TODO: implement new transaction form").as_element() + row![ + input("25").on_input(Message::DayInputChanged).width(32.0), + input("12").on_input(Message::MonthInputChanged).width(32.0), + input("2026").on_input(Message::YearInputChanged).width(48.0), + input("").on_input(Message::BucketInputChanged).width(138.0), + input("").on_input(Message::PayeeInputChanged).width(266.0), + input("").on_input(Message::QuantityInputChanged).width(104.0), + button(&self.submit_text, Message::Submit, false).width(64.0), + ].spacing(u32::from(SPACING_SM)) + .into() } } -- cgit v1.2.3