first commit
This commit is contained in:
commit
412aa641b4
7 changed files with 4165 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use nix
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
.direnv/
|
4001
Cargo.lock
generated
Normal file
4001
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
23
Cargo.toml
Normal file
23
Cargo.toml
Normal file
|
@ -0,0 +1,23 @@
|
|||
cargo-features = ["profile-rustflags"]
|
||||
[package]
|
||||
name = "zieltakt"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
iced = { version = "0.13.1" }
|
||||
|
||||
[profile.dev]
|
||||
incremental = true
|
||||
rustflags = ["-Zthreads=8"]
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
lto = true
|
||||
opt-level = "s"
|
||||
panic = "abort"
|
||||
strip = true
|
||||
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"]
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "nightly"
|
30
shell.nix
Normal file
30
shell.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
pkgs.mkShell rec {
|
||||
buildInputs = with pkgs; [
|
||||
xorg.libX11
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libxcb
|
||||
libxkbcommon
|
||||
|
||||
shaderc
|
||||
directx-shader-compiler
|
||||
libGL
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
vulkan-tools
|
||||
vulkan-tools-lunarg
|
||||
vulkan-validation-layers
|
||||
wayland
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}";
|
||||
'';
|
||||
}
|
106
src/main.rs
Normal file
106
src/main.rs
Normal file
|
@ -0,0 +1,106 @@
|
|||
use iced::widget::{column, container, scrollable, text, text_input};
|
||||
use iced::Alignment::Center;
|
||||
use iced::{Element, Fill, Task, Theme};
|
||||
|
||||
// use uuid::Uuid;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::application("Zieltakt", App::update, App::view)
|
||||
.theme(theme)
|
||||
.run_with(App::new)
|
||||
}
|
||||
|
||||
fn theme(_state: &App) -> Theme {
|
||||
Theme::Nightfly
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
enum App {
|
||||
#[default]
|
||||
Loading,
|
||||
Loaded(State),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
struct State {
|
||||
input_value: String,
|
||||
habits: Vec<Habit>,
|
||||
dirty: bool,
|
||||
saving: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Habit {
|
||||
// #[serde(default = "Uuid::new_v4")]
|
||||
// id: Uuid,
|
||||
description: String,
|
||||
completed: bool,
|
||||
// #[serde(skip)]
|
||||
// state: TaskState,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
InputChanged(String),
|
||||
CreateTask,
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn new() -> (Self, Task<Message>) {
|
||||
// TODO: Imlepment loading using serde
|
||||
(App::Loaded(State::default()), Task::none())
|
||||
}
|
||||
|
||||
fn update(app: &mut App, message: Message) -> Task<Message> {
|
||||
match app {
|
||||
App::Loading => {
|
||||
// TODO: Imlepment loading using serde
|
||||
Task::none()
|
||||
}
|
||||
App::Loaded(state) => {
|
||||
let command = match message {
|
||||
Message::InputChanged(value) => {
|
||||
state.input_value = value;
|
||||
Task::none()
|
||||
}
|
||||
Message::CreateTask => {
|
||||
state.habits.push(Habit {
|
||||
description: state.input_value.clone(),
|
||||
completed: false,
|
||||
});
|
||||
state.input_value = String::new();
|
||||
println!("{:?}", state.habits);
|
||||
Task::none()
|
||||
}
|
||||
|
||||
};
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn view(app: &App) -> Element<Message> {
|
||||
match &app {
|
||||
App::Loading => text("Loading...").into(),
|
||||
App::Loaded(State { input_value, .. }) => {
|
||||
let title = text("todos")
|
||||
.width(Fill)
|
||||
.size(100)
|
||||
.color([0.5, 0.5, 0.5])
|
||||
.align_x(Center);
|
||||
|
||||
let input = text_input("What needs to be done?", input_value)
|
||||
.id("new-task")
|
||||
.on_input(Message::InputChanged)
|
||||
.on_submit(Message::CreateTask)
|
||||
.padding(15)
|
||||
.size(30)
|
||||
.align_x(Center);
|
||||
|
||||
let content = column![title, input].spacing(20).max_width(800);
|
||||
|
||||
scrollable(container(content).center_x(Fill).padding(40)).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue