preview.rs (611B)
1 use notedeck::AppResponse; 2 3 pub struct PreviewConfig { 4 pub is_mobile: bool, 5 } 6 7 pub trait Preview { 8 type Prev: notedeck::App; 9 10 fn preview(cfg: PreviewConfig) -> Self::Prev; 11 } 12 13 pub struct PreviewApp { 14 view: Box<dyn notedeck::App>, 15 } 16 17 impl PreviewApp { 18 pub fn new(view: impl notedeck::App + 'static) -> PreviewApp { 19 let view = Box::new(view); 20 Self { view } 21 } 22 } 23 24 impl notedeck::App for PreviewApp { 25 fn update(&mut self, app_ctx: &mut notedeck::AppContext<'_>, ui: &mut egui::Ui) -> AppResponse { 26 self.view.update(app_ctx, ui); 27 AppResponse::none() 28 } 29 }