diff --git a/src/ui/feed.rs b/src/ui/feed.rs index 50994029..fdea575b 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -2,10 +2,10 @@ use super::{GossipUi, Page}; use crate::comms::ToOverlordMessage; use crate::feed::FeedKind; use crate::globals::{Globals, GLOBALS}; -use crate::ui::widgets::{CopyButton, LikeButton, ReplyButton}; +use crate::ui::widgets::CopyButton; use eframe::egui; use egui::{ - Align, Color32, Context, Frame, Image, Layout, RichText, ScrollArea, SelectableLabel, Sense, + Align, Color32, Context, Frame, Image, Label, Layout, RichText, ScrollArea, SelectableLabel, Sense, Separator, Stroke, TextEdit, TextStyle, Ui, Vec2, }; use linkify::{LinkFinder, LinkKind}; @@ -533,7 +533,7 @@ fn render_post_actual( ui.add_space(24.0); - if ui.add(ReplyButton {}).clicked() { + if ui.add(Label::new(RichText::new("💬").size(18.0)).sense(Sense::click())).clicked() { app.replying_to = Some(event.id); // Cleanup tags @@ -552,7 +552,7 @@ fn render_post_actual( ui.add_space(24.0); - if ui.add(LikeButton {}).clicked() { + if ui.add(Label::new(RichText::new("♡").size(20.0)).sense(Sense::click())).clicked() { let _ = GLOBALS .to_overlord .send(ToOverlordMessage::Like(event.id, event.pubkey)); diff --git a/src/ui/widgets/copy_button.rs b/src/ui/widgets/copy_button.rs index d957b760..0a9109ff 100644 --- a/src/ui/widgets/copy_button.rs +++ b/src/ui/widgets/copy_button.rs @@ -80,9 +80,9 @@ impl Widget for CopyButton { let (id, rect) = ui.allocate_space(space); let response = ui.interact(rect, id, Sense::click()); let shift = if response.is_pointer_button_down_on() { - 2.0 + 6.0 } else { - 0.0 + 4.0 }; let pos = Pos2 { x: rect.min.x + padding.x + shift, diff --git a/src/ui/widgets/like_button.rs b/src/ui/widgets/like_button.rs deleted file mode 100644 index c31e7976..00000000 --- a/src/ui/widgets/like_button.rs +++ /dev/null @@ -1,128 +0,0 @@ -use eframe::{egui, epaint}; -use egui::{Color32, Pos2, Response, Sense, Shape, Ui, Vec2, Widget}; -use epaint::{PathShape, Stroke}; - -pub struct LikeButton {} - -impl LikeButton { - fn paint(ui: &mut Ui, corner: Pos2) { - ui.painter().add(Shape::Path(PathShape { - points: vec![ - Pos2 { - x: corner.x + 8.0, - y: corner.y + 16.0, - }, - Pos2 { - x: corner.x + 9.0, - y: corner.y + 15.0, - }, - Pos2 { - x: corner.x + 12.0, - y: corner.y + 13.0, - }, - Pos2 { - x: corner.x + 15.0, - y: corner.y + 9.0, - }, - Pos2 { - x: corner.x + 16.0, - y: corner.y + 6.0, - }, - Pos2 { - x: corner.x + 16.0, - y: corner.y + 4.0, - }, - Pos2 { - x: corner.x + 15.0, - y: corner.y + 2.0, - }, - Pos2 { - x: corner.x + 13.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 12.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 10.0, - y: corner.y + 1.0, - }, - Pos2 { - x: corner.x + 8.0, - y: corner.y + 3.0, - }, - Pos2 { - x: corner.x + 6.0, - y: corner.y + 1.0, - }, - Pos2 { - x: corner.x + 4.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 3.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 1.0, - y: corner.y + 2.0, - }, - Pos2 { - x: corner.x + 0.0, - y: corner.y + 4.0, - }, - Pos2 { - x: corner.x + 0.0, - y: corner.y + 6.0, - }, - Pos2 { - x: corner.x + 1.0, - y: corner.y + 9.0, - }, - Pos2 { - x: corner.x + 4.0, - y: corner.y + 13.0, - }, - Pos2 { - x: corner.x + 7.0, - y: corner.y + 15.0, - }, - Pos2 { - x: corner.x + 8.0, - y: corner.y + 16.0, - }, - ], - closed: true, - fill: Color32::TRANSPARENT, - stroke: Stroke { - width: 1.0, - color: Color32::from_rgb(0x8d, 0x7f, 0x73), - }, - })); - } -} - -impl Widget for LikeButton { - fn ui(self, ui: &mut Ui) -> Response { - let padding = ui.spacing().button_padding; - let space = Vec2 { - x: 16.0 + padding.x * 2.0, - y: 16.0 + padding.y * 2.0, - }; - let (id, rect) = ui.allocate_space(space); - let response = ui.interact(rect, id, Sense::click()); - let shift = if response.is_pointer_button_down_on() { - 2.0 - } else { - 0.0 - }; - let pos = Pos2 { - x: rect.min.x + padding.x + shift, - y: rect.min.y + padding.y + shift, - }; - Self::paint(ui, ui.painter().round_pos_to_pixels(pos)); - - response - } -} diff --git a/src/ui/widgets/mod.rs b/src/ui/widgets/mod.rs index 4cd87d32..34985845 100644 --- a/src/ui/widgets/mod.rs +++ b/src/ui/widgets/mod.rs @@ -1,8 +1,2 @@ mod copy_button; pub use copy_button::CopyButton; - -mod reply_button; -pub use reply_button::ReplyButton; - -mod like_button; -pub use like_button::LikeButton; diff --git a/src/ui/widgets/reply_button.rs b/src/ui/widgets/reply_button.rs deleted file mode 100644 index 040a8d74..00000000 --- a/src/ui/widgets/reply_button.rs +++ /dev/null @@ -1,92 +0,0 @@ -use eframe::{egui, epaint}; -use egui::{Color32, Pos2, Response, Sense, Shape, Ui, Vec2, Widget}; -use epaint::{PathShape, Stroke}; - -pub struct ReplyButton {} - -impl ReplyButton { - fn paint(ui: &mut Ui, corner: Pos2) { - ui.painter().add(Shape::Path(PathShape { - points: vec![ - Pos2 { - x: corner.x + 2.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 14.0, - y: corner.y + 0.0, - }, - Pos2 { - x: corner.x + 16.0, - y: corner.y + 2.0, - }, - Pos2 { - x: corner.x + 16.0, - y: corner.y + 8.0, - }, - Pos2 { - x: corner.x + 14.0, - y: corner.y + 10.0, - }, - Pos2 { - x: corner.x + 12.0, - y: corner.y + 10.0, - }, - Pos2 { - x: corner.x + 4.0, - y: corner.y + 15.0, - }, - Pos2 { - x: corner.x + 6.0, - y: corner.y + 10.0, - }, - Pos2 { - x: corner.x + 2.0, - y: corner.y + 10.0, - }, - Pos2 { - x: corner.x + 0.0, - y: corner.y + 8.0, - }, - Pos2 { - x: corner.x + 0.0, - y: corner.y + 2.0, - }, - Pos2 { - x: corner.x + 2.0, - y: corner.y + 0.0, - }, - ], - closed: true, - fill: Color32::TRANSPARENT, - stroke: Stroke { - width: 1.0, - color: Color32::from_rgb(0x8d, 0x7f, 0x73), - }, - })); - } -} - -impl Widget for ReplyButton { - fn ui(self, ui: &mut Ui) -> Response { - let padding = ui.spacing().button_padding; - let space = Vec2 { - x: 16.0 + padding.x * 2.0, - y: 16.0 + padding.y * 2.0, - }; - let (id, rect) = ui.allocate_space(space); - let response = ui.interact(rect, id, Sense::click()); - let shift = if response.is_pointer_button_down_on() { - 2.0 - } else { - 0.0 - }; - let pos = Pos2 { - x: rect.min.x + padding.x + shift, - y: rect.min.y + padding.y + shift, - }; - Self::paint(ui, ui.painter().round_pos_to_pixels(pos)); - - response - } -}