frontend fin

This commit is contained in:
Martin Vrhovšek 2025-02-01 15:36:20 +01:00
parent 6a8ea96c1c
commit a9582750fc

View File

@ -1,7 +1,7 @@
use iced::keyboard::key; use iced::keyboard::key;
use iced::widget::{button, center, checkbox, column, row, scrollable, text_input, Text}; use iced::widget::{button, center, checkbox, column, row, scrollable, text_input, Space, Text};
use iced::window::Settings; use iced::window::Settings;
use iced::{event, keyboard, widget, Element, Event, Length, Size, Subscription, Task, Theme}; use iced::{event, keyboard, widget, Center, Element, Event, Length, Size, Subscription, Task, Theme};
struct TaskData { struct TaskData {
checked: bool, checked: bool,
@ -31,6 +31,7 @@ struct Todo {
updated_task: String, updated_task: String,
tasks: Vec<TaskData>, tasks: Vec<TaskData>,
completed_tasks: usize, completed_tasks: usize,
local_storage: bool,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -200,12 +201,14 @@ impl Todo {
saved_tasks = saved_tasks.push(task_line); saved_tasks = saved_tasks.push(task_line);
} }
let footer = row![Text::new(format!("{} / {}", self.completed_tasks, self.tasks.len()))].padding(10); let status = Text::new(format!("{} / {}", self.completed_tasks, self.tasks.len()));
let storage = checkbox("Local storage", true);
let footer = row![status, Space::with_width(Length::Fill), storage].padding(10);
let mut output = column![new_task.padding(10)]; let mut output = column![new_task.padding(10)];
output = if self.tasks.is_empty() { output.push(saved_tasks.height(Length::Fill)) } else { output.push(scrollable(saved_tasks).height(Length::Fill).spacing(10)) }; output = if self.tasks.is_empty() { output.push(saved_tasks.height(Length::Fill)) } else { output.push(scrollable(saved_tasks).height(Length::Fill).spacing(10)) };
output = output.align_x(Center).push(footer);
output = output.push(footer);
center(output).into() center(output).into()
} }