mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-14 05:44:20 +01:00
disable post button if draft buffer empty
closes: https://github.com/damus-io/notedeck/issues/417 Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -209,7 +209,10 @@ impl<'a> PostView<'a> {
|
||||
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| {
|
||||
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(
|
||||
@@ -236,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::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user