commit d17b5e07038ea76684d6cf8c20d9f5523b8b80ee
parent c4e0c710c97db3bb084ce2b1bf18d985a31d66bd
Author: William Casarin <jb55@jb55.com>
Date: Thu, 13 Jun 2024 11:57:59 -0700
Add forward navigation animation
Also fix a few nav clipping bugs
From egui-nav:
William Casarin (5):
add forward nav support
fix body overlapping header
fix transition clipping when in a smaller container
fix forward nav clipping in small containers
fix background layer having the wrong UI id
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
4 files changed, 54 insertions(+), 43 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -1108,7 +1108,7 @@ dependencies = [
[[package]]
name = "egui_nav"
version = "0.1.0"
-source = "git+https://github.com/damus-io/egui-nav?rev=9f640df83494a79cd7aa0b5983c83290d284d6ee#9f640df83494a79cd7aa0b5983c83290d284d6ee"
+source = "git+https://github.com/damus-io/egui-nav?rev=cbe7c894fdc4bffe72b44240ce259388ecc571f7#cbe7c894fdc4bffe72b44240ce259388ecc571f7"
dependencies = [
"egui",
"egui_extras",
diff --git a/Cargo.toml b/Cargo.toml
@@ -32,7 +32,7 @@ eframe = { version = "0.27.2", default-features = false, features = [ "glow", "w
egui_extras = { version = "0.27.2", features = ["all_loaders"] }
ehttp = "0.2.0"
egui_tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "120971fc43db6ba0b6f194f4bd4a66f7e00a4e22" }
-egui_nav = { git = "https://github.com/damus-io/egui-nav", rev = "9f640df83494a79cd7aa0b5983c83290d284d6ee" }
+egui_nav = { git = "https://github.com/damus-io/egui-nav", rev = "ac22dfccbaa3d2fee57a8b0250bde11ebf4c5563" }
reqwest = { version = "0.12.4", default-features = false, features = [ "rustls-tls-native-roots" ] }
image = { version = "0.24", features = ["jpeg", "png", "webp"] }
log = "0.4.17"
diff --git a/src/app.rs b/src/app.rs
@@ -869,57 +869,63 @@ fn render_panel(ctx: &egui::Context, app: &mut Damus, timeline_ind: usize) {
}
fn render_nav(routes: Vec<Route>, timeline_ind: usize, app: &mut Damus, ui: &mut egui::Ui) {
+ let navigating = app.timelines[timeline_ind].navigating;
let app_ctx = Rc::new(RefCell::new(app));
- let nav_response = Nav::new(routes).show(ui, |ui, nav| match nav.top() {
- Route::Timeline(_n) => {
- timeline::timeline_view(ui, &mut app_ctx.borrow_mut(), timeline_ind);
- }
+ let nav_response =
+ Nav::new(routes)
+ .navigating(navigating)
+ .show(ui, |ui, nav| match nav.top() {
+ Route::Timeline(_n) => {
+ timeline::timeline_view(ui, &mut app_ctx.borrow_mut(), timeline_ind);
+ }
- Route::ManageAccount => {
- ui.label("account management view");
- }
+ Route::ManageAccount => {
+ ui.label("account management view");
+ }
- Route::Thread(_key) => {
- ui.label("thread view");
- }
+ Route::Thread(_key) => {
+ ui.label("thread view");
+ }
- Route::Relays => {
- let pool = &mut app_ctx.borrow_mut().pool;
- let manager = RelayPoolManager::new(pool);
- RelayView::new(manager).ui(ui);
- }
+ Route::Relays => {
+ let pool = &mut app_ctx.borrow_mut().pool;
+ let manager = RelayPoolManager::new(pool);
+ RelayView::new(manager).ui(ui);
+ }
- Route::Reply(id) => {
- let app = app_ctx.borrow();
- let txn = if let Ok(txn) = Transaction::new(&app.ndb) {
- txn
- } else {
- ui.label("Reply to unknown note");
- return;
- };
+ Route::Reply(id) => {
+ let app = app_ctx.borrow();
+ let txn = if let Ok(txn) = Transaction::new(&app.ndb) {
+ txn
+ } else {
+ ui.label("Reply to unknown note");
+ return;
+ };
- let note = if let Ok(note) = app.ndb.get_note_by_id(&txn, id.bytes()) {
- note
- } else {
- ui.label("Reply to unknown note");
- return;
- };
+ let note = if let Ok(note) = app.ndb.get_note_by_id(&txn, id.bytes()) {
+ note
+ } else {
+ ui.label("Reply to unknown note");
+ return;
+ };
- ui.label(format!(
- "Replying to note by {}",
- app.ndb
- .get_profile_by_pubkey(&txn, note.pubkey())
- .as_ref()
- .ok()
- .and_then(|pr| Some(crate::profile::get_profile_name(pr)?.username()))
- .unwrap_or("??")
- ));
- }
- });
+ ui.label(format!(
+ "Replying to note by {}",
+ app.ndb
+ .get_profile_by_pubkey(&txn, note.pubkey())
+ .as_ref()
+ .ok()
+ .and_then(|pr| Some(crate::profile::get_profile_name(pr)?.username()))
+ .unwrap_or("??")
+ ));
+ }
+ });
if let Some(NavAction::Returned) = nav_response.action {
app_ctx.borrow_mut().timelines[timeline_ind].routes.pop();
+ } else if let Some(NavAction::Navigated) = nav_response.action {
+ app_ctx.borrow_mut().timelines[timeline_ind].navigating = false;
}
}
diff --git a/src/timeline.rs b/src/timeline.rs
@@ -126,6 +126,7 @@ pub struct Timeline {
pub views: Vec<TimelineView>,
pub selected_view: i32,
pub routes: Vec<Route>,
+ pub navigating: bool,
/// Our nostrdb subscription
pub subscription: Option<Subscription>,
@@ -139,8 +140,10 @@ impl Timeline {
let views = vec![notes, replies];
let selected_view = 0;
let routes = vec![Route::Timeline("Timeline".to_string())];
+ let navigating = false;
Timeline {
+ navigating,
filter,
views,
subscription,
@@ -309,9 +312,11 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
debug!("bar action: {:?}", action);
match action {
BarAction::Reply => {
- app.timelines[timeline]
+ let timeline = &mut app.timelines[timeline];
+ timeline
.routes
.push(Route::Reply(NoteId::new(note.id().to_owned())));
+ timeline.navigating = true;
}
}
}