reintroduce account management

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-06-23 19:46:58 -04:00
parent ac0821db79
commit 6afb618089
9 changed files with 181 additions and 21 deletions

53
src/ui/global_popup.rs Normal file
View File

@@ -0,0 +1,53 @@
use std::{cell::RefCell, rc::Rc};
use egui::Sense;
use egui_nav::{Nav, NavAction};
use crate::{
fixed_window::{FixedWindow, FixedWindowResponse},
route::Route,
Damus,
};
static MARGIN: f32 = 100.0;
pub struct DesktopGlobalPopup {}
impl DesktopGlobalPopup {
pub fn show(routes: Vec<Route>, app: &mut Damus, ui: &mut egui::Ui) {
if routes.is_empty() || !app.show_global_popup {
return;
}
let rect = ui.ctx().screen_rect().shrink(MARGIN);
let title = if let Some(first) = routes.first() {
// TODO(kernelkind): not a great way of getting the title of the routes 'grouping'
Some(first.title())
} else {
None
};
let app_ctx = Rc::new(RefCell::new(app));
let resp = FixedWindow::maybe_with_title(title).show(ui, rect, |ui| {
let nav_response = Nav::new(routes).navigating(false).show(ui, |ui, nav| {
if let Some(resp) = nav.top().show_global_popup(&mut app_ctx.borrow_mut(), ui) {
ui.allocate_rect(resp.rect, Sense::hover())
} else {
ui.label("") // TODO(kernelkind): not a great practice
}
});
if let Some(NavAction::Returned) = nav_response.action {
app_ctx.borrow_mut().global_nav.pop();
}
nav_response.inner
});
if resp == FixedWindowResponse::Closed {
app_ctx.borrow_mut().global_nav.pop();
app_ctx.borrow_mut().show_global_popup = false;
}
}
}