diff --git a/crates/notedeck_chrome/Cargo.toml b/crates/notedeck_chrome/Cargo.toml index 63d54a21e9f3..d8f071af09fc 100644 --- a/crates/notedeck_chrome/Cargo.toml +++ b/crates/notedeck_chrome/Cargo.toml @@ -16,6 +16,7 @@ egui = { workspace = true } notedeck_columns = { workspace = true } notedeck_ui = { workspace = true } notedeck_dave = { workspace = true } +notedeck_notebook = { workspace = true } notedeck = { workspace = true } nostrdb = { workspace = true } puffin = { workspace = true, optional = true } diff --git a/crates/notedeck_chrome/src/android.rs b/crates/notedeck_chrome/src/android.rs index cecec89bdc4a..a7e8e98349f6 100644 --- a/crates/notedeck_chrome/src/android.rs +++ b/crates/notedeck_chrome/src/android.rs @@ -88,6 +88,7 @@ pub async fn android_main(app: AndroidApp) { chrome.add_app(NotedeckApp::Columns(columns)); chrome.add_app(NotedeckApp::Dave(dave)); + chrome.add_app(NotedeckApp::Dave(dave)); // test dav chrome.set_active(0); diff --git a/crates/notedeck_chrome/src/app.rs b/crates/notedeck_chrome/src/app.rs index bf44aae1eb2b..d672e6c3f24f 100644 --- a/crates/notedeck_chrome/src/app.rs +++ b/crates/notedeck_chrome/src/app.rs @@ -1,11 +1,13 @@ use notedeck::{AppAction, AppContext}; use notedeck_columns::Damus; use notedeck_dave::Dave; +use notedeck_notebook::Notebook; #[allow(clippy::large_enum_variant)] pub enum NotedeckApp { - Dave(Dave), - Columns(Damus), + Dave(Box), + Columns(Box), + Notebook(Box), Other(Box), } @@ -14,6 +16,7 @@ impl notedeck::App for NotedeckApp { match self { NotedeckApp::Dave(dave) => dave.update(ctx, ui), NotedeckApp::Columns(columns) => columns.update(ctx, ui), + NotedeckApp::Notebook(notebook) => notebook.update(ctx, ui), NotedeckApp::Other(other) => other.update(ctx, ui), } } diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs index 54bf004e3df7..68a123deede4 100644 --- a/crates/notedeck_chrome/src/chrome.rs +++ b/crates/notedeck_chrome/src/chrome.rs @@ -10,6 +10,7 @@ use notedeck_columns::{ column::SelectionResult, timeline::kind::ListKind, timeline::TimelineKind, Damus, }; use notedeck_dave::{Dave, DaveAvatar}; +use notedeck_notebook::Notebook; use notedeck_ui::{app_images, AnimationHelper, ProfilePic}; static ICON_WIDTH: f32 = 40.0; @@ -191,6 +192,16 @@ impl Chrome { None } + fn get_notebook(&mut self) -> Option<&mut Notebook> { + for app in &mut self.apps { + if let NotedeckApp::Notebook(notebook) = app { + return Some(notebook); + } + } + + None + } + fn switch_to_dave(&mut self) { for (i, app) in self.apps.iter().enumerate() { if let NotedeckApp::Dave(_) = app { @@ -199,6 +210,14 @@ impl Chrome { } } + fn switch_to_notebook(&mut self) { + for (i, app) in self.apps.iter().enumerate() { + if let NotedeckApp::Notebook(_) = app { + self.active = i as i32; + } + } + } + fn switch_to_columns(&mut self) { for (i, app) in self.apps.iter().enumerate() { if let NotedeckApp::Columns(_) = app { @@ -420,13 +439,11 @@ impl Chrome { ui.add(milestone_name()); ui.add_space(16.0); //let dark_mode = ui.ctx().style().visuals.dark_mode; + if columns_button(ui) + .on_hover_cursor(egui::CursorIcon::PointingHand) + .clicked() { - if columns_button(ui) - .on_hover_cursor(egui::CursorIcon::PointingHand) - .clicked() - { - self.active = 0; - } + self.active = 0; } ui.add_space(32.0); @@ -438,6 +455,16 @@ impl Chrome { self.switch_to_dave(); } } + //ui.add_space(32.0); + + if let Some(_notebook) = self.get_notebook() { + if notebook_button(ui) + .on_hover_cursor(egui::CursorIcon::PointingHand) + .clicked() + { + self.switch_to_notebook(); + } + } } } @@ -563,6 +590,16 @@ fn columns_button(ui: &mut egui::Ui) -> egui::Response { ) } +fn notebook_button(ui: &mut egui::Ui) -> egui::Response { + expanding_button( + "columns-button", + 40.0, + app_images::new_message_image(), + app_images::new_message_image(), + ui, + ) +} + fn dave_sidebar_rect(ui: &mut egui::Ui) -> Rect { let size = vec2(60.0, 60.0); let available = ui.available_rect_before_wrap(); diff --git a/crates/notedeck_chrome/src/notedeck.rs b/crates/notedeck_chrome/src/notedeck.rs index 51b202ab389c..5394f0e972c3 100644 --- a/crates/notedeck_chrome/src/notedeck.rs +++ b/crates/notedeck_chrome/src/notedeck.rs @@ -16,6 +16,7 @@ use notedeck_chrome::{ }; use notedeck_columns::Damus; use notedeck_dave::Dave; +use notedeck_notebook::Notebook; use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::EnvFilter; @@ -95,6 +96,7 @@ async fn main() { let mut chrome = Chrome::new(); let columns = Damus::new(&mut notedeck.app_context(), &args); let dave = Dave::new(cc.wgpu_render_state.as_ref()); + let notebook = Notebook::new(); setup_chrome(ctx, notedeck.args(), notedeck.theme()); @@ -109,8 +111,9 @@ async fn main() { "unrecognized args: {completely_unrecognized:?}" ); - chrome.add_app(NotedeckApp::Columns(columns)); - chrome.add_app(NotedeckApp::Dave(dave)); + chrome.add_app(NotedeckApp::Columns(Box::new(columns))); + chrome.add_app(NotedeckApp::Dave(Box::new(dave))); + chrome.add_app(NotedeckApp::Notebook(Box::new(notebook))); chrome.set_active(0);