ui: simply hide post button if buffer is empty
Fixes: 8464a1d22c ("disable post button if draft buffer empty")
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -208,10 +208,15 @@ impl<'a> PostView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| {
|
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
|
if ui
|
||||||
.add_sized(
|
.add_sized(
|
||||||
[91.0, 32.0],
|
[91.0, 32.0],
|
||||||
post_button(!self.draft.buffer.is_empty()),
|
egui::Button::new("Post now")
|
||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
@@ -239,23 +244,6 @@ 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 {
|
mod preview {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user