toolbar: process actions
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -534,9 +534,16 @@ fn render_damus_mobile(
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
let mut app_action: Option<AppAction> = None;
|
||||
|
||||
let active_col = app.columns_mut(app_ctx.accounts).selected as usize;
|
||||
if !app.columns(app_ctx.accounts).columns().is_empty() {
|
||||
let r = nav::render_nav(0, ui.available_rect_before_wrap(), app, app_ctx, ui)
|
||||
.process_render_nav_response(app, app_ctx, ui);
|
||||
let r = nav::render_nav(
|
||||
active_col,
|
||||
ui.available_rect_before_wrap(),
|
||||
app,
|
||||
app_ctx,
|
||||
ui,
|
||||
)
|
||||
.process_render_nav_response(app, app_ctx, ui);
|
||||
if let Some(r) = &r {
|
||||
match r {
|
||||
ProcessNavResult::SwitchOccurred => {
|
||||
@@ -563,7 +570,7 @@ fn render_damus_mobile(
|
||||
.clicked()
|
||||
&& !app.columns(app_ctx.accounts).columns().is_empty()
|
||||
{
|
||||
let router = app.columns_mut(app_ctx.accounts).columns_mut()[0].router_mut();
|
||||
let router = app.columns_mut(app_ctx.accounts).selected().router_mut();
|
||||
if router.top() == &Route::ComposeNote {
|
||||
router.go_back();
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ pub struct Columns {
|
||||
columns: Vec<Column>,
|
||||
|
||||
/// The selected column for key navigation
|
||||
selected: i32,
|
||||
pub selected: i32,
|
||||
}
|
||||
|
||||
impl Columns {
|
||||
@@ -47,6 +47,35 @@ impl Columns {
|
||||
Columns::default()
|
||||
}
|
||||
|
||||
/// Choose which column is selected. If in narrow mode, this
|
||||
/// decides which column to render in the main view
|
||||
pub fn select_column(&mut self, index: i32) {
|
||||
let len = self.columns.len();
|
||||
|
||||
if index < (len as i32) {
|
||||
self.selected = index;
|
||||
}
|
||||
}
|
||||
|
||||
/// Select the column based on the timeline kind.
|
||||
///
|
||||
/// TODO: add timeline if missing?
|
||||
pub fn select_by_kind(&mut self, kind: &TimelineKind) {
|
||||
for (i, col) in self.columns.iter().enumerate() {
|
||||
for route in col.router().routes() {
|
||||
if let Some(timeline) = route.timeline_id() {
|
||||
if timeline == kind {
|
||||
tracing::info!("selecting {kind:?} column");
|
||||
self.select_column(i as i32);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracing::error!("failed to select {kind:?} column");
|
||||
}
|
||||
|
||||
pub fn add_new_timeline_column(
|
||||
&mut self,
|
||||
timeline_cache: &mut TimelineCache,
|
||||
|
||||
@@ -37,9 +37,8 @@ impl Default for DecksCache {
|
||||
|
||||
impl DecksCache {
|
||||
/// Gets the first column in the currently active user's active deck
|
||||
pub fn first_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
||||
self.active_columns_mut(accounts)
|
||||
.and_then(|ad| ad.columns_mut().first_mut())
|
||||
pub fn selected_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
||||
self.active_columns_mut(accounts).map(|ad| ad.selected())
|
||||
}
|
||||
|
||||
/// Gets the active columns
|
||||
|
||||
Reference in New Issue
Block a user