From 75a75626cefed6abaccbaa6ed4a2686a8b09f696 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 17 Oct 2024 11:29:34 +0400 Subject: [PATCH] Show info about popular apps section. --- Telegram/Resources/langs/lang.strings | 9 +++++ .../SourceFiles/core/local_url_handlers.cpp | 15 +++++++++ Telegram/SourceFiles/dialogs/dialogs.style | 4 +++ .../dialogs/ui/dialogs_suggestions.cpp | 33 ++++++++++++++++++- .../dialogs/ui/dialogs_suggestions.h | 3 ++ 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index eb2555768..e00d24f3f 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -5623,6 +5623,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_channels_recommended" = "Similar channels"; "lng_bot_apps_your" = "Apps you use"; "lng_bot_apps_popular" = "Grossing apps"; +"lng_bot_apps_which" = "Which apps are included here? {link}"; +"lng_bot_apps_which_link" = "Learn >"; + +"lng_popular_apps_info_title" = "Top Mini Apps"; +"lng_popular_apps_info_text" = "This catalogue ranks mini apps based on their daily revenue, measured in Stars. To be listed, developers must set their main mini apps in {bot} (as described {link}), have over **1,000** daily users, and earn a daily revenue above **1,000** Stars, based on the weekly average."; +"lng_popular_apps_info_bot" = "@botfather"; +"lng_popular_apps_info_here" = "here"; +"lng_popular_apps_info_url" = "https://core.telegram.org/bots/webapps#launching-the-main-mini-app"; +"lng_popular_apps_info_confirm" = "Understood"; "lng_font_box_title" = "Choose font family"; "lng_font_default" = "Default"; diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index c07832e9a..1c4add992 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -965,6 +965,17 @@ bool ShowStarsExamples( return true; } +bool ShowPopularAppsAbout( + Window::SessionController *controller, + const Match &match, + const QVariant &context) { + if (!controller) { + return false; + } + controller->show(Dialogs::PopularAppsAboutBox(controller)); + return true; +} + void ExportTestChatTheme( not_null controller, not_null theme) { @@ -1431,6 +1442,10 @@ const std::vector &InternalUrlHandlers() { u"^stars_examples$"_q, ShowStarsExamples, }, + { + u"^about_popular_apps$"_q, + ShowPopularAppsAbout, + }, }; return Result; } diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index d039869b7..8dea08276 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -743,3 +743,7 @@ dialogsSearchTagPromoLeft: 6px; dialogsSearchTagPromoRight: 1px; dialogsSearchTagPromoSkip: 6px; +dialogsPopularAppsPadding: margins(10px, 8px, 10px, 12px); +dialogsPopularAppsAbout: FlatLabel(boxDividerLabel) { + minWidth: 128px; +} diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp index 7e4995af3..43b5c5882 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.cpp @@ -1162,8 +1162,22 @@ void PopularAppsController::fill() { appendRow(bot); } } + const auto count = delegate()->peerListFullRowsCount(); + setCount(count); + if (count > 0) { + delegate()->peerListSetBelowWidget(object_ptr( + (QWidget*)nullptr, + object_ptr( + (QWidget*)nullptr, + tr::lng_bot_apps_which( + lt_link, + tr::lng_bot_apps_which_link( + ) | Ui::Text::ToLink(u"internal:about_popular_apps"_q), + Ui::Text::WithEntities), + st::dialogsPopularAppsAbout), + st::dialogsPopularAppsPadding)); + } delegate()->peerListRefreshRows(); - setCount(delegate()->peerListFullRowsCount()); } void PopularAppsController::appendRow(not_null bot) { @@ -2325,4 +2339,21 @@ object_ptr StarsExamplesBox( return Box(std::move(controller), std::move(initBox)); } +object_ptr PopularAppsAboutBox( + not_null window) { + return Ui::MakeInformBox({ + .text = tr::lng_popular_apps_info_text( + lt_bot, + rpl::single(Ui::Text::Link( + u"@botfather"_q, + u"https://t.me/botfather"_q)), + lt_link, + tr::lng_popular_apps_info_here( + ) | Ui::Text::ToLink(tr::lng_popular_apps_info_url(tr::now)), + Ui::Text::RichLangValue), + .confirmText = tr::lng_popular_apps_info_confirm(), + .title = tr::lng_popular_apps_info_title(), + }); +} + } // namespace Dialogs diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h index be868b77a..32998519f 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_suggestions.h @@ -219,4 +219,7 @@ private: [[nodiscard]] object_ptr StarsExamplesBox( not_null window); +[[nodiscard]] object_ptr PopularAppsAboutBox( + not_null window); + } // namespace Dialogs