notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

preview.rs (540B)


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