Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/notedeck/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use android_activity::AndroidApp;
pub enum AppAction {
Note(NoteAction),
ToggleChrome,
SwitchToDave,
}

pub trait App {
Expand Down
13 changes: 13 additions & 0 deletions crates/notedeck/src/persist/settings_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DEFAULT_LOCALE: &str = "en-US";
const DEFAULT_ZOOM_FACTOR: f32 = 1.0;
const DEFAULT_SHOW_SOURCE_CLIENT: &str = "hide";
const DEFAULT_SHOW_REPLIES_NEWEST_FIRST: bool = false;
const DEFAULT_ANIMATE_NAV_TRANSITIONS: bool = true;
#[cfg(any(target_os = "android", target_os = "ios"))]
pub const DEFAULT_NOTE_BODY_FONT_SIZE: f32 = 13.0;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
Expand All @@ -36,6 +37,12 @@ pub struct Settings {
pub show_source_client: String,
pub show_replies_newest_first: bool,
pub note_body_font_size: f32,
#[serde(default = "default_animate_nav_transitions")]
pub animate_nav_transitions: bool,
}

fn default_animate_nav_transitions() -> bool {
DEFAULT_ANIMATE_NAV_TRANSITIONS
}

impl Default for Settings {
Expand All @@ -47,6 +54,7 @@ impl Default for Settings {
show_source_client: DEFAULT_SHOW_SOURCE_CLIENT.to_string(),
show_replies_newest_first: DEFAULT_SHOW_REPLIES_NEWEST_FIRST,
note_body_font_size: DEFAULT_NOTE_BODY_FONT_SIZE,
animate_nav_transitions: DEFAULT_ANIMATE_NAV_TRANSITIONS,
}
}
}
Expand Down Expand Up @@ -191,6 +199,11 @@ impl SettingsHandler {
self.try_save_settings();
}

pub fn set_animate_nav_transitions(&mut self, value: bool) {
self.get_settings_mut().animate_nav_transitions = value;
self.try_save_settings();
}

pub fn update_batch<F>(&mut self, update_fn: F)
where
F: FnOnce(&mut Settings),
Expand Down
16 changes: 12 additions & 4 deletions crates/notedeck/src/profile/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use enostr::Pubkey;

pub enum ProfileContextSelection {
CopyLink,
ViewAs,
}

pub struct ProfileContext {
Expand All @@ -11,10 +12,17 @@ pub struct ProfileContext {

impl ProfileContextSelection {
pub fn process(&self, ctx: &egui::Context, pk: &Pubkey) {
let Some(npub) = pk.npub() else {
return;
};
match self {
ProfileContextSelection::CopyLink => {
let Some(npub) = pk.npub() else {
return;
};

ctx.copy_text(format!("https://damus.io/{npub}"));
ctx.copy_text(format!("https://damus.io/{npub}"));
}
ProfileContextSelection::ViewAs => {
// handled separately in profile.rs
}
}
}
}
14 changes: 13 additions & 1 deletion crates/notedeck_chrome/src/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl ChromePanelAction {
}

Self::Settings => {
Self::columns_navigate(ctx, chrome, notedeck_columns::Route::Settings);
Self::columns_navigate(ctx, chrome, notedeck_columns::Route::settings());
}

Self::Wallet => {
Expand Down Expand Up @@ -197,6 +197,14 @@ impl Chrome {
}
}

fn switch_to_dave(&mut self) {
for (i, app) in self.apps.iter().enumerate() {
if let NotedeckApp::Dave(_) = app {
self.active = i as i32;
}
}
}

pub fn set_active(&mut self, app: i32) {
self.active = app;
}
Expand Down Expand Up @@ -456,6 +464,10 @@ fn chrome_handle_app_action(
chrome.toggle();
}

AppAction::SwitchToDave => {
chrome.switch_to_dave();
}

AppAction::Note(note_action) => {
chrome.switch_to_columns();
let Some(columns) = chrome.get_columns_app() else {
Expand Down
92 changes: 85 additions & 7 deletions crates/notedeck_columns/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ pub struct Damus {

/// keep track of follow packs
pub onboarding: Onboarding,

/// Track which column is hovered for mouse back/forward navigation
hovered_column: Option<usize>,
}

fn handle_egui_events(input: &egui::InputState, columns: &mut Columns) {
fn handle_egui_events(input: &egui::InputState, columns: &mut Columns, hovered_column: Option<usize>) {
for event in &input.raw.events {
match event {
egui::Event::Key { key, pressed, .. } if *pressed => match key {
Expand All @@ -89,6 +92,30 @@ fn handle_egui_events(input: &egui::InputState, columns: &mut Columns) {
_ => {}
},

egui::Event::PointerButton {
button: egui::PointerButton::Extra1,
pressed: true,
..
} => {
if let Some(col_idx) = hovered_column {
columns.column_mut(col_idx).router_mut().go_back();
} else {
columns.get_selected_router().go_back();
}
}

egui::Event::PointerButton {
button: egui::PointerButton::Extra2,
pressed: true,
..
} => {
if let Some(col_idx) = hovered_column {
columns.column_mut(col_idx).router_mut().go_forward();
} else {
columns.get_selected_router().go_forward();
}
}

egui::Event::InsetsChanged => {
tracing::debug!("insets have changed!");
}
Expand All @@ -106,7 +133,7 @@ fn try_process_event(
) -> Result<()> {
let current_columns =
get_active_columns_mut(app_ctx.i18n, app_ctx.accounts, &mut damus.decks_cache);
ctx.input(|i| handle_egui_events(i, current_columns));
ctx.input(|i| handle_egui_events(i, current_columns, damus.hovered_column));

let ctx2 = ctx.clone();
let wakeup = move || {
Expand Down Expand Up @@ -533,6 +560,7 @@ impl Damus {
jobs,
threads,
onboarding: Onboarding::default(),
hovered_column: None,
}
}

Expand Down Expand Up @@ -584,6 +612,7 @@ impl Damus {
jobs: JobsCache::default(),
threads: Threads::default(),
onboarding: Onboarding::default(),
hovered_column: None,
}
}

Expand Down Expand Up @@ -686,6 +715,21 @@ fn render_damus_mobile(
ProcessNavResult::PfpClicked => {
app_action = Some(AppAction::ToggleChrome);
}

ProcessNavResult::SwitchAccount(pubkey) => {
// Add as pubkey-only account if not already present
let kp = enostr::Keypair::only_pubkey(*pubkey);
let _ = app_ctx.accounts.add_account(kp);

let txn = nostrdb::Transaction::new(app_ctx.ndb).expect("txn");
app_ctx.accounts.select_account(
pubkey,
app_ctx.ndb,
&txn,
app_ctx.pool,
ui.ctx(),
);
}
}
}
}
Expand Down Expand Up @@ -775,7 +819,7 @@ fn should_show_compose_button(decks: &DecksCache, accounts: &Accounts) -> bool {
Route::Reply(_) => false,
Route::Quote(_) => false,
Route::Relays => false,
Route::Settings => false,
Route::Settings(_) => false,
Route::ComposeNote => false,
Route::AddColumn(_) => false,
Route::EditProfile(_) => false,
Expand All @@ -786,6 +830,8 @@ fn should_show_compose_button(decks: &DecksCache, accounts: &Accounts) -> bool {
Route::Wallet(_) => false,
Route::CustomizeZapAmount(_) => false,
Route::RepostDecision(_) => false,
Route::Following(_) => false,
Route::FollowedBy(_) => false,
}
}

Expand Down Expand Up @@ -826,6 +872,7 @@ fn timelines_view(
) -> AppResponse {
let num_cols = get_active_columns(ctx.accounts, &app.decks_cache).num_columns();
let mut side_panel_action: Option<nav::SwitchingAction> = None;
let mut app_action: Option<AppAction> = None;
let mut responses = Vec::with_capacity(num_cols);

let mut can_take_drag_from = Vec::new();
Expand All @@ -837,16 +884,25 @@ fn timelines_view(
.horizontal(|mut strip| {
strip.cell(|ui| {
let rect = ui.available_rect_before_wrap();
let current_route = get_active_columns(ctx.accounts, &app.decks_cache)
.selected()
.map(|col| col.router().top());
let side_panel = DesktopSidePanel::new(
ctx.accounts.get_selected_account(),
&app.decks_cache,
ctx.i18n,
ctx.ndb,
ctx.img_cache,
current_route,
ctx.pool,
)
.show(ui);

if let Some(side_panel) = side_panel {
if side_panel.response.clicked() || side_panel.response.secondary_clicked() {
if let Some(action) = DesktopSidePanel::perform_action(
if side_panel.action == SidePanelAction::Dave {
app_action = Some(AppAction::SwitchToDave);
} else if let Some(action) = DesktopSidePanel::perform_action(
&mut app.decks_cache,
ctx.accounts,
side_panel.action,
Expand Down Expand Up @@ -876,6 +932,8 @@ fn timelines_view(
);
});

app.hovered_column = None;

for col_index in 0..num_cols {
strip.cell(|ui| {
let rect = ui.available_rect_before_wrap();
Expand All @@ -889,6 +947,11 @@ fn timelines_view(
can_take_drag_from.extend(resp.can_take_drag_from());
responses.push(resp);

// Track hovered column for mouse back/forward navigation
if ui.rect_contains_pointer(rect) {
app.hovered_column = Some(col_index);
}

// vertical line
ui.painter()
.vline(rect.right(), rect.y_range(), v_line_stroke);
Expand Down Expand Up @@ -917,9 +980,8 @@ fn timelines_view(
);
}

let mut app_action: Option<AppAction> = None;

for response in responses {
if app_action.is_none() {
for response in responses {
let nav_result = response.process_render_nav_response(app, ctx, ui);

if let Some(nr) = &nav_result {
Expand All @@ -929,8 +991,24 @@ fn timelines_view(
ProcessNavResult::PfpClicked => {
app_action = Some(AppAction::ToggleChrome);
}

ProcessNavResult::SwitchAccount(pubkey) => {
// Add as pubkey-only account if not already present
let kp = enostr::Keypair::only_pubkey(*pubkey);
let _ = ctx.accounts.add_account(kp);

let txn = nostrdb::Transaction::new(ctx.ndb).expect("txn");
ctx.accounts.select_account(
pubkey,
ctx.ndb,
&txn,
ctx.pool,
ui.ctx(),
);
}
}
}
}
}

if app.options.contains(AppOptions::TmpColumns) {
Expand Down
3 changes: 2 additions & 1 deletion crates/notedeck_columns/src/draft.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use egui::text::LayoutJob;
use poll_promise::Promise;

use crate::{media_upload::Nip94Event, post::PostBuffer, ui::note::PostType, Error};
use crate::{media_upload::Nip94Event, post::PostBuffer, ui::{note::PostType, search::FocusState}, Error};
use std::collections::HashMap;

#[derive(Default)]
Expand All @@ -12,6 +12,7 @@ pub struct Draft {
pub uploaded_media: Vec<Nip94Event>, // media uploads to include
pub uploading_media: Vec<Promise<Result<Nip94Event, Error>>>, // promises that aren't ready yet
pub upload_errors: Vec<String>, // media upload errors to show the user
pub focus_state: FocusState,
}

pub struct MentionHint {
Expand Down
2 changes: 1 addition & 1 deletion crates/notedeck_columns/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ pub mod storage;

pub use app::Damus;
pub use error::Error;
pub use route::Route;
pub use route::{Route, SettingsRoute};

pub type Result<T> = std::result::Result<T, error::Error>;
Loading