From 87afc88b02a025584c512b42db9bea1625369db2 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Fri, 17 Feb 2023 18:22:00 +1300 Subject: [PATCH] Content warning: the ability to post with a content-warning label --- src/ui/feed/post.rs | 28 ++++++++++++++++++++++++++++ src/ui/mod.rs | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/src/ui/feed/post.rs b/src/ui/feed/post.rs index 8c8ec89b..80f936cd 100644 --- a/src/ui/feed/post.rs +++ b/src/ui/feed/post.rs @@ -90,6 +90,22 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram }); } + if app.include_content_warning { + ui.horizontal(|ui| { + ui.label("Content Warning: "); + ui.add( + TextEdit::singleline(&mut app.content_warning) + .hint_text("Type content warning here") + .text_color(if ui.visuals().dark_mode { + Color32::WHITE + } else { + Color32::BLACK + }) + .desired_width(f32::INFINITY), + ); + }); + } + ui.add( TextEdit::multiline(&mut app.draft) .hint_text("Type your message here") @@ -114,6 +130,9 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram if app.include_subject { tags.push(Tag::Subject(app.subject.clone())); } + if app.include_content_warning { + tags.push(Tag::ContentWarning(app.content_warning.clone())); + } let _ = GLOBALS.to_overlord.send(ToOverlordMessage::Post( app.draft.clone(), tags, @@ -159,6 +178,15 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram app.include_subject = true; } + if app.include_content_warning { + if ui.button("Remove Content Warning").clicked() { + app.include_content_warning = false; + app.content_warning = "".to_owned(); + } + } else if ui.button("Add Content Warning").clicked() { + app.include_content_warning = true; + } + // Emoji picker ui.menu_button(RichText::new("😀▼").size(14.0), |ui| { for emoji in "😀😁😆😅🤣😕😯👀❤💜👍🤙💯🎯🤌🙏🤝🫂⚡🍆".chars() diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 017d0b57..958ca4d6 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -114,6 +114,8 @@ struct GossipUi { tag_someone: String, include_subject: bool, subject: String, + include_content_warning: bool, + content_warning: String, replying_to: Option, // User entry: metadata @@ -251,6 +253,8 @@ impl GossipUi { tag_someone: "".to_owned(), include_subject: false, subject: "".to_owned(), + include_content_warning: false, + content_warning: "".to_owned(), replying_to: None, editing_metadata: false, metadata: Metadata::new(),