Emoji picker improvements

This commit is contained in:
Mike Dilger 2023-03-06 21:20:33 +13:00
parent a188b00ee8
commit 0b6852b53d
3 changed files with 45 additions and 6 deletions

41
src/ui/components/mod.rs Normal file
View File

@ -0,0 +1,41 @@
use eframe::egui;
use egui::{Label, Sense, Ui};
pub fn emoji_picker(ui: &mut Ui) -> Option<char> {
let mut emojis = "😀😁😆😅😂🤣\
😕🥺😯😭😍🥰\
😊🫡🤔💀🫂👀\
💜🔥\
👍🤙🤌🙏🤝🫰\
💯🎯👑🍆🚩"
.chars();
let mut output: Option<char> = None;
let mut quit: bool = false;
loop {
ui.vertical(|ui| {
ui.horizontal(|ui| {
for _ in 0..6 {
if let Some(emoji) = emojis.next() {
if ui
.add(Label::new(emoji.to_string()).sense(Sense::click()))
.clicked()
{
output = Some(emoji);
}
} else {
quit = true;
}
}
});
});
if quit {
break;
}
}
output
}

View File

@ -230,13 +230,10 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
// Emoji picker
ui.menu_button(RichText::new("😀▼").size(14.0), |ui| {
for emoji in "😀😁😆😅🤣😕😯👀❤💜👍🤙💯🎯🤌🙏🤝🫂⚡🍆".chars()
{
if ui.button(emoji.to_string()).clicked() {
app.draft.push(emoji);
}
if let Some(emoji) = crate::ui::components::emoji_picker(ui) {
app.draft.push(emoji);
}
});
})
});
});

View File

@ -1,3 +1,4 @@
mod components;
mod feed;
mod help;
mod people;