initial commit
This commit is contained in:
commit
d321be19ad
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
/.idea
|
4042
Cargo.lock
generated
Normal file
4042
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "todo-app"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
iced = "0.13.1"
|
65
src/main.rs
Normal file
65
src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use iced::widget::{button, center, column, row, text_input, Space, Text};
|
||||
use iced::window::Settings;
|
||||
use iced::{Center, Element, Length, Size, Theme};
|
||||
|
||||
fn main() -> iced::Result {
|
||||
let settings = Settings {
|
||||
size: Size::new(500.0, 600.0),
|
||||
resizable: false,
|
||||
..Settings::default()
|
||||
};
|
||||
|
||||
iced::application("ToDo", Todo::update, Todo::view)
|
||||
.theme(Todo::theme)
|
||||
.window(settings)
|
||||
.run()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Todo {
|
||||
new_task: String,
|
||||
tasks: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
AddTask,
|
||||
ContentUpdated,
|
||||
}
|
||||
|
||||
impl Todo {
|
||||
fn update(&mut self, message: Message) {
|
||||
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let input = text_input("Enter new task", &self.new_task)
|
||||
.width(300)
|
||||
.size(25);
|
||||
//.read_line(self.new_task)
|
||||
|
||||
let add_btn = button(
|
||||
Text::new("Add task")
|
||||
.size(19)
|
||||
.center()
|
||||
)
|
||||
.width(Length::Shrink)
|
||||
.height(40)
|
||||
.padding(10);
|
||||
|
||||
let skeleton = row![input, add_btn].spacing(10);
|
||||
let r = column![
|
||||
Space::with_height(Length::Fill),
|
||||
skeleton
|
||||
]
|
||||
.spacing(20)
|
||||
.align_x(Center);
|
||||
|
||||
let container = center(r);
|
||||
container.into()
|
||||
}
|
||||
|
||||
fn theme(&self) -> Theme {
|
||||
Theme::Dark
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user