VULKVMFWPDXQ5UR4EQL6UN3YPVFE7JPHNBO3SM5HAMRVCVQC5LWQC
import { Button , VerticalBox, HorizontalBox} from "std-widgets.slint";
export component MainApp inherits Window {
callback add(string);
callback del();
callback clear();
callback confirm();
in-out property <string> key;
in-out property <int> len;
VerticalBox {
// width: 25%;
alignment: center;
TextInput{
// input-type: password;
text: root.key;
horizontal-alignment: center;
}
HorizontalBox {
Button {
enabled: len <= 5;
text: "1";
clicked => {
add("1");
}
}
Button {
enabled: len <= 5;
text: "2";
clicked => {
add("2");
}
}
Button {
enabled: len <= 5;
text: "3";
clicked => {
add("3");
}
}
}
HorizontalBox {
Button {
enabled: len <= 5;
text: "4";
clicked => {
add("4");
}
}
Button {
enabled: len <= 5;
text: "5";
clicked => {
add("5");
}
}
Button {
enabled: len <= 5;
text: "6";
clicked => {
add("6");
}
}
}
HorizontalBox {
Button {
enabled: len <= 5;
text: "7";
clicked => {
add("7");
}
}
Button {
enabled: len <= 5;
text: "8";
clicked => {
add("8");
}
}
Button {
enabled: len <= 5;
text: "9";
clicked => {
add("9");
}
}
}
HorizontalBox {
Button {
text: "Temizle";
clicked => {
clear();
}
}
Button {
enabled: len <= 5;
text: "0";
clicked => {
add("0");
}
}
Button {
text: "Sil";
clicked => {
del();
}
}
}
HorizontalBox {
Button {
text: "Doğrula";
enabled: len == 6;
clicked => {
confirm();
}
}
}
}
}
use std::{fs, io::Write};
use slint::Timer;
slint::include_modules!();
fn main() {
let main_window = MainApp::new().unwrap();
// main_window.window().set_fullscreen(true);
let weak = main_window.as_weak().unwrap();
main_window.on_add(move |n| {
let mut key = weak.get_key();
key.push_str(&n);
weak.set_len(weak.get_len() + 1);
weak.set_key(key);
});
let weak = main_window.as_weak().unwrap();
main_window.on_del(move || {
let mut key = weak.get_key().to_string();
key.remove(weak.get_len() as usize - 1);
weak.set_len(weak.get_len() - 1);
weak.set_key(key.into());
});
let weak = main_window.as_weak().unwrap();
main_window.on_clear(move || {
weak.set_len(0);
weak.set_key("".into());
});
let weak = main_window.as_weak().unwrap();
main_window.on_confirm(move || {
let key = weak.get_key();
let mut key_file = std::fs::File::create("/tmp/kilit").unwrap();
key_file.write_all(key.as_bytes()).unwrap();
});
main_window.run().unwrap();
}
fn main() {
slint_build::compile("ui/main.slint").unwrap();
}
[package]
name = "lock-screen"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
slint ={git = "https://github.com/slint-ui/slint", branch="master"}
[build-dependencies]
slint-build = {git = "https://github.com/slint-ui/slint", branch="master"}