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:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -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",
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
86
src/app.rs
86
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) {
|
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 =
|
||||||
Route::Timeline(_n) => {
|
Nav::new(routes)
|
||||||
timeline::timeline_view(ui, &mut app_ctx.borrow_mut(), timeline_ind);
|
.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 => {
|
Route::ManageAccount => {
|
||||||
ui.label("account management view");
|
ui.label("account management view");
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::Thread(_key) => {
|
Route::Thread(_key) => {
|
||||||
ui.label("thread view");
|
ui.label("thread view");
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::Relays => {
|
Route::Relays => {
|
||||||
let pool = &mut app_ctx.borrow_mut().pool;
|
let pool = &mut app_ctx.borrow_mut().pool;
|
||||||
let manager = RelayPoolManager::new(pool);
|
let manager = RelayPoolManager::new(pool);
|
||||||
RelayView::new(manager).ui(ui);
|
RelayView::new(manager).ui(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::Reply(id) => {
|
Route::Reply(id) => {
|
||||||
let app = app_ctx.borrow();
|
let app = app_ctx.borrow();
|
||||||
let txn = if let Ok(txn) = Transaction::new(&app.ndb) {
|
let txn = if let Ok(txn) = Transaction::new(&app.ndb) {
|
||||||
txn
|
txn
|
||||||
} else {
|
} else {
|
||||||
ui.label("Reply to unknown note");
|
ui.label("Reply to unknown note");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let note = if let Ok(note) = app.ndb.get_note_by_id(&txn, id.bytes()) {
|
let note = if let Ok(note) = app.ndb.get_note_by_id(&txn, id.bytes()) {
|
||||||
note
|
note
|
||||||
} else {
|
} else {
|
||||||
ui.label("Reply to unknown note");
|
ui.label("Reply to unknown note");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
"Replying to note by {}",
|
"Replying to note by {}",
|
||||||
app.ndb
|
app.ndb
|
||||||
.get_profile_by_pubkey(&txn, note.pubkey())
|
.get_profile_by_pubkey(&txn, note.pubkey())
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|pr| Some(crate::profile::get_profile_name(pr)?.username()))
|
.and_then(|pr| Some(crate::profile::get_profile_name(pr)?.username()))
|
||||||
.unwrap_or("??")
|
.unwrap_or("??")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user