Content warning: the ability to post with a content-warning label

This commit is contained in:
Mike Dilger 2023-02-17 18:22:00 +13:00
parent 13725c8ef7
commit 87afc88b02
2 changed files with 32 additions and 0 deletions

View File

@ -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()

View File

@ -114,6 +114,8 @@ struct GossipUi {
tag_someone: String,
include_subject: bool,
subject: String,
include_content_warning: bool,
content_warning: String,
replying_to: Option<Id>,
// 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(),