use unseen notification indicator

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-07-31 19:01:52 -04:00
parent 10225158e5
commit 41aa2db3c7
2 changed files with 33 additions and 11 deletions

View File

@@ -10,7 +10,9 @@ use notedeck::{
WalletType,
};
use notedeck_columns::{
column::SelectionResult, timeline::kind::ListKind, timeline::TimelineKind, Damus,
column::SelectionResult,
timeline::{kind::ListKind, TimelineKind},
Damus,
};
use notedeck_dave::{Dave, DaveAvatar};
use notedeck_notebook::Notebook;
@@ -343,7 +345,12 @@ impl Chrome {
});
strip.cell(|ui| {
if let Some(action) = self.toolbar(ui) {
let pk = ctx.accounts.get_selected_account().key.pubkey;
let unseen_notification =
unseen_notification(self.get_columns_app(), ctx.ndb, pk);
if let Some(action) = self.toolbar(ui, unseen_notification) {
got_action = Some(ChromePanelAction::Toolbar(action))
}
});
@@ -352,7 +359,7 @@ impl Chrome {
got_action
}
fn toolbar(&mut self, ui: &mut egui::Ui) -> Option<ToolbarAction> {
fn toolbar(&mut self, ui: &mut egui::Ui, unseen_notification: bool) -> Option<ToolbarAction> {
use egui_tabs::{TabColor, Tabs};
let rect = ui.available_rect_before_wrap();
@@ -396,7 +403,9 @@ impl Chrome {
action = Some(ToolbarAction::Dave);
}
}
} else if index == 2 && notifications_button(ui, btn_size).clicked() {
} else if index == 2
&& notifications_button(ui, btn_size, unseen_notification).clicked()
{
action = Some(ToolbarAction::Notifications);
}
@@ -562,6 +571,7 @@ fn expanding_button(
light_img: egui::Image,
dark_img: egui::Image,
ui: &mut egui::Ui,
unseen_indicator: bool,
) -> egui::Response {
let max_size = ICON_WIDTH * ICON_EXPANSION_MULTIPLE; // max size of the widget
let img = if ui.visuals().dark_mode {
@@ -573,12 +583,15 @@ fn expanding_button(
let helper = AnimationHelper::new(ui, name, egui::vec2(max_size, max_size));
let cur_img_size = helper.scale_1d_pos(img_size);
img.paint_at(
ui,
helper
.get_animation_rect()
.shrink((max_size - cur_img_size) / 2.0),
);
let paint_rect = helper
.get_animation_rect()
.shrink((max_size - cur_img_size) / 2.0);
img.paint_at(ui, paint_rect);
if unseen_indicator {
paint_unseen_indicator(ui, paint_rect, helper.scale_1d_pos(3.0));
}
helper.take_animation_response()
}
@@ -605,6 +618,7 @@ fn support_button(ui: &mut egui::Ui) -> egui::Response {
app_images::help_light_image(),
app_images::help_dark_image(),
ui,
false,
)
}
@@ -615,16 +629,18 @@ fn settings_button(ui: &mut egui::Ui) -> egui::Response {
app_images::settings_light_image(),
app_images::settings_dark_image(),
ui,
false,
)
}
fn notifications_button(ui: &mut egui::Ui, size: f32) -> egui::Response {
fn notifications_button(ui: &mut egui::Ui, size: f32, unseen_indicator: bool) -> egui::Response {
expanding_button(
"notifications-button",
size,
app_images::notifications_light_image(),
app_images::notifications_dark_image(),
ui,
unseen_indicator,
)
}
@@ -635,6 +651,7 @@ fn home_button(ui: &mut egui::Ui, size: f32) -> egui::Response {
app_images::home_light_image(),
app_images::home_dark_image(),
ui,
false,
)
}
@@ -645,6 +662,7 @@ fn columns_button(ui: &mut egui::Ui) -> egui::Response {
app_images::columns_image(),
app_images::columns_image(),
ui,
false,
)
}
@@ -655,6 +673,7 @@ fn accounts_button(ui: &mut egui::Ui) -> egui::Response {
app_images::accounts_image().tint(ui.visuals().text_color()),
app_images::accounts_image(),
ui,
false,
)
}
@@ -665,6 +684,7 @@ fn notebook_button(ui: &mut egui::Ui) -> egui::Response {
app_images::algo_image(),
app_images::algo_image(),
ui,
false,
)
}

View File

@@ -545,6 +545,8 @@ fn render_nav_body(
scroll_to_top,
);
app.timeline_cache.set_fresh(kind);
// always clear the scroll_to_top request
if scroll_to_top {
app.options.remove(AppOptions::ScrollToTop);