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();
}