notedeck

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

app.rs (2801B)


      1 use notedeck::{AppContext, AppResponse};
      2 
      3 use notedeck_columns::Damus;
      4 use notedeck_dave::Dave;
      5 
      6 #[cfg(feature = "clndash")]
      7 use notedeck_clndash::ClnDash;
      8 
      9 #[cfg(feature = "messages")]
     10 use notedeck_messages::MessagesApp;
     11 
     12 #[cfg(feature = "dashboard")]
     13 use notedeck_dashboard::Dashboard;
     14 
     15 #[cfg(feature = "notebook")]
     16 use notedeck_notebook::Notebook;
     17 
     18 #[cfg(feature = "nostrverse")]
     19 use notedeck_nostrverse::NostrverseApp;
     20 
     21 #[allow(clippy::large_enum_variant)]
     22 pub enum NotedeckApp {
     23     Dave(Box<Dave>),
     24     Columns(Box<Damus>),
     25 
     26     #[cfg(feature = "notebook")]
     27     Notebook(Box<Notebook>),
     28 
     29     #[cfg(feature = "clndash")]
     30     ClnDash(Box<ClnDash>),
     31 
     32     #[cfg(feature = "messages")]
     33     Messages(Box<MessagesApp>),
     34 
     35     #[cfg(feature = "dashboard")]
     36     Dashboard(Box<Dashboard>),
     37 
     38     #[cfg(feature = "nostrverse")]
     39     Nostrverse(Box<NostrverseApp>),
     40     Other(String, Box<dyn notedeck::App>),
     41 }
     42 
     43 impl notedeck::App for NotedeckApp {
     44     #[profiling::function]
     45     fn update(&mut self, ctx: &mut AppContext, egui_ctx: &egui::Context) {
     46         match self {
     47             NotedeckApp::Dave(dave) => dave.update(ctx, egui_ctx),
     48             NotedeckApp::Columns(columns) => columns.update(ctx, egui_ctx),
     49 
     50             #[cfg(feature = "notebook")]
     51             NotedeckApp::Notebook(notebook) => notebook.update(ctx, egui_ctx),
     52 
     53             #[cfg(feature = "clndash")]
     54             NotedeckApp::ClnDash(clndash) => clndash.update(ctx, egui_ctx),
     55 
     56             #[cfg(feature = "messages")]
     57             NotedeckApp::Messages(dms) => dms.update(ctx, egui_ctx),
     58 
     59             #[cfg(feature = "dashboard")]
     60             NotedeckApp::Dashboard(db) => db.update(ctx, egui_ctx),
     61 
     62             #[cfg(feature = "nostrverse")]
     63             NotedeckApp::Nostrverse(nostrverse) => nostrverse.update(ctx, egui_ctx),
     64 
     65             NotedeckApp::Other(_name, other) => other.update(ctx, egui_ctx),
     66         }
     67     }
     68 
     69     #[profiling::function]
     70     fn render(&mut self, ctx: &mut AppContext, ui: &mut egui::Ui) -> AppResponse {
     71         match self {
     72             NotedeckApp::Dave(dave) => dave.render(ctx, ui),
     73             NotedeckApp::Columns(columns) => columns.render(ctx, ui),
     74 
     75             #[cfg(feature = "notebook")]
     76             NotedeckApp::Notebook(notebook) => notebook.render(ctx, ui),
     77 
     78             #[cfg(feature = "clndash")]
     79             NotedeckApp::ClnDash(clndash) => clndash.render(ctx, ui),
     80 
     81             #[cfg(feature = "messages")]
     82             NotedeckApp::Messages(dms) => dms.render(ctx, ui),
     83 
     84             #[cfg(feature = "dashboard")]
     85             NotedeckApp::Dashboard(db) => db.render(ctx, ui),
     86 
     87             #[cfg(feature = "nostrverse")]
     88             NotedeckApp::Nostrverse(nostrverse) => nostrverse.render(ctx, ui),
     89 
     90             NotedeckApp::Other(_name, other) => other.render(ctx, ui),
     91         }
     92     }
     93 }