Move App creation into its impl
This commit is contained in:
parent
e839770c9a
commit
19fe7a4ef5
1 changed files with 20 additions and 16 deletions
36
src/main.rs
36
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<Note>, 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");
|
||||
|
|
Loading…
Reference in a new issue