| 1 | #[cfg(feature = "ui-fixture")] |
| 2 | #[path = "../../../tests/rust-app-ui/fake.rs"] |
| 3 | mod fake; |
| 4 | #[path = "system_font.rs"] |
| 5 | mod system_font; |
| 6 | use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, FontId, TextStyle}; |
| 7 | fn main() -> eframe::Result { |
| 8 | let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?; |
| 9 | eframe::run_native( |
| 10 | "Zipelo", |
| 11 | eframe::NativeOptions { |
| 12 | renderer: eframe::Renderer::Glow, |
| 13 | viewport: egui::ViewportBuilder::default() |
| 14 | .with_inner_size([1060.0, 720.0]) |
| 15 | .with_min_inner_size([760.0, 540.0]), |
| 16 | ..Default::default() |
| 17 | }, |
| 18 | Box::new(move |cc| { |
| 19 | let mut fonts = FontDefinitions::empty(); |
| 20 | let mut data = FontData::from_owned(font.bytes); |
| 21 | data.index = font.face_index; |
| 22 | fonts.font_data.insert("noto-kr".into(), data.into()); |
| 23 | fonts |
| 24 | .families |
| 25 | .insert(FontFamily::Proportional, vec!["noto-kr".into()]); |
| 26 | cc.egui_ctx.set_fonts(fonts); |
| 27 | cc.egui_ctx.set_visuals(egui::Visuals::light()); |
| 28 | cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| { |
| 29 | style |
| 30 | .text_styles |
| 31 | .insert(TextStyle::Body, FontId::proportional(18.0)); |
| 32 | style |
| 33 | .text_styles |
| 34 | .insert(TextStyle::Button, FontId::proportional(18.0)); |
| 35 | style |
| 36 | .text_styles |
| 37 | .insert(TextStyle::Heading, FontId::proportional(26.0)); |
| 38 | style.visuals.panel_fill = Color32::WHITE; |
| 39 | style.visuals.override_text_color = Some(Color32::from_rgb(24, 39, 57)); |
| 40 | style.visuals.selection.bg_fill = Color32::from_rgb(211, 230, 246); |
| 41 | style.spacing.item_spacing = egui::vec2(12.0, 10.0); |
| 42 | style.spacing.button_padding = egui::vec2(14.0, 10.0); |
| 43 | }); |
| 44 | let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args( |
| 45 | std::env::args_os().skip(1).collect(), |
| 46 | std::env::current_dir()?, |
| 47 | ) |
| 48 | .map_err(std::io::Error::other)?; |
| 49 | let factory: Box<dyn zipelo_ui_memory_app::archive_ui::Factory> = if fixture { |
| 50 | #[cfg(feature = "ui-fixture")] |
| 51 | { |
| 52 | Box::new(fake::FakeFactory::default()) |
| 53 | } |
| 54 | #[cfg(not(feature = "ui-fixture"))] |
| 55 | { |
| 56 | return Err(Box::new(std::io::Error::other( |
| 57 | "ui-fixture feature가 필요합니다", |
| 58 | ))); |
| 59 | } |
| 60 | } else { |
| 61 | Box::new( |
| 62 | zipelo_ui_memory_app::archive_process::ProcessFactory::sibling() |
| 63 | .map_err(std::io::Error::other)?, |
| 64 | ) |
| 65 | }; |
| 66 | Ok(Box::new( |
| 67 | zipelo_ui_memory_app::archive_screen::ArchiveApp::new(factory, startup, fixture), |
| 68 | )) |
| 69 | }), |
| 70 | ) |
| 71 | } |