notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit cc541cd4ffa7fd6218b79fd59261d57389505b1e
parent 8a77ba5f8f74070a0536a7a2b61e2965abc57117
Author: Jakub Gladysz <jakub.gladysz@protonmail.com>
Date:   Thu,  3 Apr 2025 18:11:27 +0200

ui: add follow button

Signed-off-by: kernelkind <kernelkind@gmail.com>
Co-authored-by: Jakub Gladysz <jakub.gladysz@protonmail.com>
Co-authored-by: William Casarin <jb55@jb55.com>

Diffstat:
Mcrates/notedeck_ui/src/profile/mod.rs | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/crates/notedeck_ui/src/profile/mod.rs b/crates/notedeck_ui/src/profile/mod.rs @@ -8,9 +8,9 @@ pub use picture::ProfilePic; pub use preview::ProfilePreview; use egui::{load::TexturePoll, Label, RichText}; -use notedeck::{NostrName, NotedeckTextStyle}; +use notedeck::{IsFollowing, NostrName, NotedeckTextStyle}; -use crate::app_images; +use crate::{app_images, colors, widgets::styled_button_toggleable}; pub fn display_name_widget<'a>( name: &'a NostrName<'a>, @@ -115,3 +115,16 @@ pub fn banner(ui: &mut egui::Ui, banner_url: Option<&str>, height: f32) -> egui: .unwrap_or_else(|| ui.label("")) }) } + +pub fn follow_button(following: IsFollowing) -> impl egui::Widget + 'static { + move |ui: &mut egui::Ui| -> egui::Response { + let (bg_color, text) = match following { + IsFollowing::Unknown => (ui.visuals().noninteractive().bg_fill, "Unknown"), + IsFollowing::Yes => (ui.visuals().widgets.inactive.bg_fill, "Unfollow"), + IsFollowing::No => (colors::PINK, "Follow"), + }; + + let enabled = following != IsFollowing::Unknown; + ui.add(styled_button_toggleable(text, bg_color, enabled)) + } +}