diff --git a/src/main.rs b/src/main.rs index b9c3c42..3fd6e49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use std::collections::{VecDeque}; use std::fs; use std::time::SystemTime; use directories::ProjectDirs; -use eframe::Frame; +use eframe::{CreationContext, Frame}; use egui::{Context, RichText, TextEdit, Widget}; use log::info; use simple_logger::SimpleLogger; @@ -41,6 +41,24 @@ struct App { text_buffer: String, } +impl App { + fn new(_cc: &CreationContext<'_>, notes: Vec, saving: Saving) -> Self { + Self { + password: None, + update_notes_next: false, + tested_password: false, + notes, + mode: CurrentMode::PasswordInput, + saving, + + password_buffer: String::new(), + + title_buffer: String::new(), + text_buffer: String::new(), + } + } +} + fn main() { SimpleLogger::new().init().expect("failed to initialize logger"); @@ -65,24 +83,10 @@ fn main() { let notes = saving.read_notes().unwrap(); info!("successfully read initial notes"); - let app = App { - password: None, - update_notes_next: false, - tested_password: false, - notes, - mode: CurrentMode::PasswordInput, - saving, - - password_buffer: String::new(), - - title_buffer: String::new(), - text_buffer: String::new(), - }; - eframe::run_native( "notes", options, - Box::new(move |_cc| Box::new(app)) + Box::new(move |cc| Box::new(App::new(cc, notes, saving))) ).expect("failed to run native"); info!("shutdown");