Added emoji selector to name input field in filter edit box.

This commit is contained in:
23rd
2025-11-02 13:34:08 +03:00
parent e16c05385f
commit 3ff376774f
2 changed files with 53 additions and 2 deletions
@@ -16,11 +16,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/premium_preview_box.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/message_field.h"
#include "chat_helpers/tabbed_panel.h"
#include "chat_helpers/tabbed_selector.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "core/ui_integration.h"
#include "data/stickers/data_custom_emoji.h"
#include "data/stickers/data_stickers.h"
#include "data/data_channel.h"
#include "data/data_chat_filters.h"
#include "data/data_document.h"
#include "data/data_peer.h"
#include "data/data_peer_values.h" // Data::AmPremiumValue.
#include "data/data_premium_limits.h"
@@ -32,6 +37,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "settings/settings_common.h"
#include "ui/chat/chats_filter_tag.h"
#include "ui/controls/emoji_button_factory.h"
#include "ui/controls/emoji_button.h"
#include "ui/effects/animation_value_f.h"
#include "ui/effects/animations.h"
#include "ui/effects/panel_animation.h"
@@ -54,6 +61,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_layers.h"
#include "styles/style_window.h"
#include "styles/style_chat.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_info_userpic_builder.h"
namespace {
@@ -357,6 +365,7 @@ void EditFilterBox(
rpl::variable<TextWithEntities> title;
rpl::variable<bool> staticTitle;
rpl::variable<int> colorIndex;
base::unique_qptr<ChatHelpers::TabbedPanel> emojiPanel;
};
const auto owner = &window->session().data();
const auto state = box->lifetime().make_state<State>(State{
@@ -483,6 +492,47 @@ void EditFilterBox(
nameEditing->custom = true;
}, box->lifetime());
using Selector = ChatHelpers::TabbedSelector;
state->emojiPanel = base::make_unique_q<ChatHelpers::TabbedPanel>(
box->getDelegate()->outerContainer(),
window,
object_ptr<Selector>(
nullptr,
window->uiShow(),
Window::GifPauseReason::Layer,
Selector::Mode::EmojiOnly));
state->emojiPanel->setDesiredHeightValues(
1.,
st::emojiPanMinHeight / 2,
st::emojiPanMinHeight);
state->emojiPanel->hide();
state->emojiPanel->selector()->setCurrentPeer(window->session().user());
state->emojiPanel->selector()->emojiChosen(
) | rpl::start_with_next([=](ChatHelpers::EmojiChosen data) {
Ui::InsertEmojiAtCursor(name->textCursor(), data.emoji);
}, name->lifetime());
state->emojiPanel->selector()->customEmojiChosen(
) | rpl::start_with_next([=](ChatHelpers::FileChosen data) {
const auto info = data.document->sticker();
if (info
&& info->setType == Data::StickersType::Emoji
&& !window->session().premium()) {
ShowPremiumPreviewBox(
window,
PremiumFeature::AnimatedEmoji);
} else {
Data::InsertCustomEmoji(name, data.document);
}
}, name->lifetime());
const auto emojiButton = Ui::AddEmojiToggleToField(
name,
box,
window,
state->emojiPanel.get(),
st::windowFilterNameEmojiPosition);
emojiButton->show();
name->changes(
) | rpl::start_with_next([=] {
if (!nameEditing->settingDefault) {
+3 -2
View File
@@ -283,9 +283,10 @@ windowFilterSmallRemove: IconButton(notifyClose) {
}
windowFilterSmallRemoveRight: 10px;
windowFilterNameInput: InputField(defaultInputField) {
textMargins: margins(0px, 26px, 56px, 4px);
textMargins: margins(0px, 26px, 87px, 4px);
}
windowFilterNameCharsLimitRightPosition: point(42px, 27px);
windowFilterNameEmojiPosition: point(-65px, 22px);
windowFilterNameCharsLimitRightPosition: point(75px, 27px);
windowFilterStaticTitlePosition: point(0px, 5px);
windowFilterIconToggleSize: size(36px, 36px);
windowFilterIconTogglePosition: point(-4px, 18px);