Show info about popular apps section.

This commit is contained in:
John Preston 2024-10-17 11:29:34 +04:00
parent cec9688d58
commit 75a75626ce
5 changed files with 63 additions and 1 deletions

View file

@ -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";

View file

@ -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<Window::SessionController*> controller,
not_null<const Data::CloudTheme*> theme) {
@ -1431,6 +1442,10 @@ const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
u"^stars_examples$"_q,
ShowStarsExamples,
},
{
u"^about_popular_apps$"_q,
ShowPopularAppsAbout,
},
};
return Result;
}

View file

@ -743,3 +743,7 @@ dialogsSearchTagPromoLeft: 6px;
dialogsSearchTagPromoRight: 1px;
dialogsSearchTagPromoSkip: 6px;
dialogsPopularAppsPadding: margins(10px, 8px, 10px, 12px);
dialogsPopularAppsAbout: FlatLabel(boxDividerLabel) {
minWidth: 128px;
}

View file

@ -1162,8 +1162,22 @@ void PopularAppsController::fill() {
appendRow(bot);
}
}
const auto count = delegate()->peerListFullRowsCount();
setCount(count);
if (count > 0) {
delegate()->peerListSetBelowWidget(object_ptr<Ui::DividerLabel>(
(QWidget*)nullptr,
object_ptr<Ui::FlatLabel>(
(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<UserData*> bot) {
@ -2325,4 +2339,21 @@ object_ptr<Ui::BoxContent> StarsExamplesBox(
return Box<PeerListBox>(std::move(controller), std::move(initBox));
}
object_ptr<Ui::BoxContent> PopularAppsAboutBox(
not_null<Window::SessionController*> 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

View file

@ -219,4 +219,7 @@ private:
[[nodiscard]] object_ptr<Ui::BoxContent> StarsExamplesBox(
not_null<Window::SessionController*> window);
[[nodiscard]] object_ptr<Ui::BoxContent> PopularAppsAboutBox(
not_null<Window::SessionController*> window);
} // namespace Dialogs