From e796011deb2f087b931bda23a52613106d42f635 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Fri, 17 Jan 2025 18:56:20 +0300 Subject: [PATCH] feat: show toast --- Telegram/Resources/langs/lang.strings | 2 + Telegram/SourceFiles/ayu/ui/ayu_styles.style | 8 ++++ .../info/profile/info_profile_badge.cpp | 4 +- .../info/profile/info_profile_cover.cpp | 40 +++++++++++++++---- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 8f598d172..04ee96cc1 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -6399,6 +6399,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ayu_ContextCopyCallbackData" = "Copy Callback Data"; "ayu_RegisterURLScheme" = "Register URL Scheme"; "ayu_LocalPremiumNotice" = "You're using **local** Telegram Premium.\nIt **won't** give you any benefits.\n**Enjoy the star near your nickname!**"; +"ayu_DeveloperPopup" = "**{item}** is a member of the **exteraGram** development team."; +"ayu_SupporterPopup" = "**{item}** supported the development of **exteraGram** or **AyuGram** and received an exclusive badge."; "ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs."; "ayu_ConfirmationSticker" = "Do you want to send this sticker?"; "ayu_ConfirmationGIF" = "Do you want to send this GIF?"; diff --git a/Telegram/SourceFiles/ayu/ui/ayu_styles.style b/Telegram/SourceFiles/ayu/ui/ayu_styles.style index 712d12d6f..cf0634064 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_styles.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_styles.style @@ -61,3 +61,11 @@ topBarRecentActions: IconButton { color: windowBgOver; } } + +exteraBadgeToast: Toast(defaultToast) { + minWidth: msgMinWidth; + maxWidth: 480px; + padding: margins(54px, 13px, 19px, 12px); + icon: icon {{ "ayu/extera_badge", toastFg }}; + iconPosition: point(13px, 13px); +} diff --git a/Telegram/SourceFiles/info/profile/info_profile_badge.cpp b/Telegram/SourceFiles/info/profile/info_profile_badge.cpp index f04ffbf29..ed2773155 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_badge.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_badge.cpp @@ -45,7 +45,9 @@ namespace { [[nodiscard]] bool HasPremiumClick(const Badge::Content &content) { return content.badge == BadgeType::Premium - || (content.badge == BadgeType::Verified && content.emojiStatusId); + || (content.badge == BadgeType::Verified && content.emojiStatusId) + || (content.badge == BadgeType::Extera) + || (content.badge == BadgeType::ExteraSupporter); } } // namespace diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index 675e3a0dc..b77ddf10e 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -48,6 +48,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/utils/telegram_helpers.h" +#include "styles/style_ayu_styles.h" +#include "ui/toast/toast.h" namespace Info::Profile { @@ -411,9 +413,38 @@ Cover::Cover( ::Settings::ShowEmojiStatusPremium(_controller, _peer); } }); + if (_peer->isUser()) { + _exteraBadge->setPremiumClickCallback([=] + { + TextWithEntities text; + if (isExteraPeer(getBareID(_peer))) { + text = tr::ayu_DeveloperPopup( + tr::now, + lt_item, + TextWithEntities{_peer->name()}, + Ui::Text::RichLangValue); + } else if (isSupporterPeer(getBareID(_peer))) { + text = tr::ayu_SupporterPopup( + tr::now, + lt_item, + TextWithEntities{_peer->name()}, + Ui::Text::RichLangValue); + } else { + return; + } + + Ui::Toast::Show({ + .text = text, + .st = &st::exteraBadgeToast, + .adaptive = true, + .duration = 3 * crl::time(1000), + }); + }); + } rpl::merge( _verify->updated(), - _badge->updated() + _badge->updated(), + _exteraBadge->updated() ) | rpl::start_with_next([=] { refreshNameGeometry(width()); }, _name->lifetime()); @@ -426,13 +457,6 @@ Cover::Cover( _exteraBadge->setContent(Info::Profile::Badge::Content{BadgeType::None}); } - _exteraBadge->updated() | rpl::start_with_next( - [=] - { - refreshNameGeometry(width()); - }, - _name->lifetime()); - initViewers(std::move(title)); setupChildGeometry();