notedeck

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

commit de802cd36323e2771317bc24cdba29aab9cbe102
parent 536f7579a90042871772801566032fe4f59bc336
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 27 Nov 2024 09:26:51 -0800

Revert "ui: simply hide post button if buffer is empty"

This reverts commit 4133570c2e2e8c7ab03d3edec2f69b4f392cde18.

Diffstat:
Msrc/ui/note/post.rs | 27+++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/ui/note/post.rs b/src/ui/note/post.rs @@ -208,13 +208,11 @@ impl<'a> PostView<'a> { } ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| { - if self.draft.buffer.is_empty() { - // Don't render button if our buffer is empty - return None; - } - if ui - .add_sized([91.0, 32.0], egui::Button::new("Post now")) + .add_sized( + [91.0, 32.0], + post_button(!self.draft.buffer.is_empty()), + ) .clicked() { let new_post = NewPost::new( @@ -241,6 +239,23 @@ impl<'a> PostView<'a> { } } +fn post_button(interactive: bool) -> impl egui::Widget { + move |ui: &mut egui::Ui| { + let button = egui::Button::new("Post now"); + if interactive { + ui.add(button) + } else { + ui.add( + button + .sense(egui::Sense::hover()) + .fill(ui.visuals().widgets.noninteractive.bg_fill) + .stroke(ui.visuals().widgets.noninteractive.bg_stroke), + ) + .on_hover_cursor(egui::CursorIcon::NotAllowed) + } + } +} + mod preview { use super::*;