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>
This commit is contained in:
William Casarin
2024-06-13 11:57:59 -07:00
parent c4e0c710c9
commit d17b5e0703
4 changed files with 54 additions and 43 deletions

2
Cargo.lock generated
View File

@@ -1108,7 +1108,7 @@ dependencies = [
[[package]] [[package]]
name = "egui_nav" name = "egui_nav"
version = "0.1.0" 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 = [ dependencies = [
"egui", "egui",
"egui_extras", "egui_extras",

View File

@@ -32,7 +32,7 @@ eframe = { version = "0.27.2", default-features = false, features = [ "glow", "w
egui_extras = { version = "0.27.2", features = ["all_loaders"] } egui_extras = { version = "0.27.2", features = ["all_loaders"] }
ehttp = "0.2.0" ehttp = "0.2.0"
egui_tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "120971fc43db6ba0b6f194f4bd4a66f7e00a4e22" } 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" ] } reqwest = { version = "0.12.4", default-features = false, features = [ "rustls-tls-native-roots" ] }
image = { version = "0.24", features = ["jpeg", "png", "webp"] } image = { version = "0.24", features = ["jpeg", "png", "webp"] }
log = "0.4.17" log = "0.4.17"

View File

@@ -869,9 +869,13 @@ 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) { 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 app_ctx = Rc::new(RefCell::new(app));
let nav_response = Nav::new(routes).show(ui, |ui, nav| match nav.top() { let nav_response =
Nav::new(routes)
.navigating(navigating)
.show(ui, |ui, nav| match nav.top() {
Route::Timeline(_n) => { Route::Timeline(_n) => {
timeline::timeline_view(ui, &mut app_ctx.borrow_mut(), timeline_ind); timeline::timeline_view(ui, &mut app_ctx.borrow_mut(), timeline_ind);
} }
@@ -920,6 +924,8 @@ fn render_nav(routes: Vec<Route>, timeline_ind: usize, app: &mut Damus, ui: &mut
if let Some(NavAction::Returned) = nav_response.action { if let Some(NavAction::Returned) = nav_response.action {
app_ctx.borrow_mut().timelines[timeline_ind].routes.pop(); 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;
} }
} }

View File

@@ -126,6 +126,7 @@ pub struct Timeline {
pub views: Vec<TimelineView>, pub views: Vec<TimelineView>,
pub selected_view: i32, pub selected_view: i32,
pub routes: Vec<Route>, pub routes: Vec<Route>,
pub navigating: bool,
/// Our nostrdb subscription /// Our nostrdb subscription
pub subscription: Option<Subscription>, pub subscription: Option<Subscription>,
@@ -139,8 +140,10 @@ impl Timeline {
let views = vec![notes, replies]; let views = vec![notes, replies];
let selected_view = 0; let selected_view = 0;
let routes = vec![Route::Timeline("Timeline".to_string())]; let routes = vec![Route::Timeline("Timeline".to_string())];
let navigating = false;
Timeline { Timeline {
navigating,
filter, filter,
views, views,
subscription, subscription,
@@ -309,9 +312,11 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
debug!("bar action: {:?}", action); debug!("bar action: {:?}", action);
match action { match action {
BarAction::Reply => { BarAction::Reply => {
app.timelines[timeline] let timeline = &mut app.timelines[timeline];
timeline
.routes .routes
.push(Route::Reply(NoteId::new(note.id().to_owned()))); .push(Route::Reply(NoteId::new(note.id().to_owned())));
timeline.navigating = true;
} }
} }
} }