notedeck

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

preview.rs (631B)


      1 use notedeck::AppAction;
      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(
     26         &mut self,
     27         app_ctx: &mut notedeck::AppContext<'_>,
     28         ui: &mut egui::Ui,
     29     ) -> Option<AppAction> {
     30         self.view.update(app_ctx, ui);
     31         None
     32     }
     33 }