accounts: use column nav for account management

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-09-16 16:28:56 -07:00
parent 3c79724a81
commit 52a7ed53ec
4 changed files with 34 additions and 11 deletions

View File

@@ -40,7 +40,6 @@ fn open_thread(
) -> Option<BarResult> { ) -> Option<BarResult> {
{ {
router.route_to(Route::thread(NoteId::new(selected_note.to_owned()))); router.route_to(Route::thread(NoteId::new(selected_note.to_owned())));
router.navigating = true;
} }
let root_id = crate::note::root_note_id_from_selected_id(ndb, note_cache, txn, selected_note); let root_id = crate::note::root_note_id_from_selected_id(ndb, note_cache, txn, selected_note);

View File

@@ -3,7 +3,7 @@ use crate::{
app_creation::setup_cc, app_creation::setup_cc,
app_style::user_requested_visuals_change, app_style::user_requested_visuals_change,
args::Args, args::Args,
column::Columns, column::{Column, Columns},
draft::Drafts, draft::Drafts,
error::{Error, FilterError}, error::{Error, FilterError},
filter, filter,
@@ -14,6 +14,7 @@ use crate::{
nav, nav,
note::NoteRef, note::NoteRef,
notecache::{CachedNote, NoteCache}, notecache::{CachedNote, NoteCache},
route::Route,
subscriptions::{SubKind, Subscriptions}, subscriptions::{SubKind, Subscriptions},
thread::Threads, thread::Threads,
timeline::{Timeline, TimelineKind, ViewFilter}, timeline::{Timeline, TimelineKind, ViewFilter},
@@ -962,11 +963,18 @@ fn timelines_view(ui: &mut egui::Ui, sizes: Size, app: &mut Damus, columns: usiz
let rect = ui.available_rect_before_wrap(); let rect = ui.available_rect_before_wrap();
let side_panel = DesktopSidePanel::new(app).show(ui); let side_panel = DesktopSidePanel::new(app).show(ui);
if side_panel.response.clicked() { let router = if let Some(router) =
info!("clicked {:?}", side_panel.action); app.columns.columns_mut().get_mut(0).map(|c: &mut Column| c.router_mut())
} {
router
} else {
// TODO(jb55): Maybe we should have an empty column route?
let columns = app.columns.columns_mut();
columns.push(Column::new(vec![Route::accounts()]));
columns[0].router_mut()
};
DesktopSidePanel::perform_action(app, side_panel.action); DesktopSidePanel::perform_action(router, side_panel.action);
// vertical sidebar line // vertical sidebar line
ui.painter().vline( ui.painter().vline(

View File

@@ -68,6 +68,7 @@ impl<R: Clone> Router<R> {
} }
pub fn route_to(&mut self, route: R) { pub fn route_to(&mut self, route: R) {
self.navigating = true;
self.routes.push(route); self.routes.push(route);
} }

View File

@@ -1,6 +1,11 @@
use egui::{Button, Layout, SidePanel, Vec2, Widget}; use egui::{Button, Layout, SidePanel, Vec2, Widget};
use crate::{ui::profile_preview_controller, Damus}; use crate::{
column::Column,
route::{Route, Router},
ui::profile_preview_controller,
Damus,
};
use super::{ProfilePic, View}; use super::{ProfilePic, View};
@@ -80,10 +85,13 @@ impl<'a> DesktopSidePanel<'a> {
} }
} }
pub fn perform_action(app: &mut Damus, action: SidePanelAction) { pub fn perform_action(router: &mut Router<Route>, action: SidePanelAction) {
match action { match action {
SidePanelAction::Panel => {} // TODO SidePanelAction::Panel => {} // TODO
SidePanelAction::Account => app.show_account_switcher = !app.show_account_switcher, SidePanelAction::Account => {
router.route_to(Route::accounts());
//app.show_account_switcher = !app.show_account_switcher,
}
SidePanelAction::Settings => {} // TODO SidePanelAction::Settings => {} // TODO
SidePanelAction::Columns => (), // TODO SidePanelAction::Columns => (), // TODO
} }
@@ -138,7 +146,10 @@ mod preview {
impl DesktopSidePanelPreview { impl DesktopSidePanelPreview {
fn new() -> Self { fn new() -> Self {
let app = test_data::test_app(); let mut app = test_data::test_app();
app.columns
.columns_mut()
.push(Column::new(vec![Route::accounts()]));
DesktopSidePanelPreview { app } DesktopSidePanelPreview { app }
} }
} }
@@ -153,7 +164,11 @@ mod preview {
strip.cell(|ui| { strip.cell(|ui| {
let mut panel = DesktopSidePanel::new(&mut self.app); let mut panel = DesktopSidePanel::new(&mut self.app);
let response = panel.show(ui); let response = panel.show(ui);
DesktopSidePanel::perform_action(&mut self.app, response.action);
DesktopSidePanel::perform_action(
self.app.columns.columns_mut()[0].router_mut(),
response.action,
);
}); });
}); });