Add a NEW badge to "Earn Stars".

This commit is contained in:
John Preston 2024-12-03 16:23:40 +04:00
parent 1fd1e34844
commit 42a2de4bf0
5 changed files with 15 additions and 5 deletions

View file

@ -257,7 +257,8 @@ void InnerWidget::fill() {
const auto button = BotStarRef::AddViewListButton(
container,
tr::lng_credits_summary_earn_title(),
tr::lng_credits_summary_earn_about());
tr::lng_credits_summary_earn_about(),
true);
button->setClickedCallback([=] {
_controller->showSection(BotStarRef::Join::Make(peer()));
});

View file

@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/table_layout.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/text/text_utilities.h"
#include "ui/new_badges.h"
#include "ui/painter.h"
#include "ui/vertical_list.h"
#include "styles/style_chat.h"
@ -247,7 +248,8 @@ rpl::producer<TextWithEntities> FormatForProgramDuration(
not_null<Ui::AbstractButton*> AddViewListButton(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> title,
rpl::producer<QString> subtitle) {
rpl::producer<QString> subtitle,
bool newBadge) {
const auto &stLabel = st::defaultFlatLabel;
const auto iconSize = st::settingsPremiumIconDouble.size();
const auto &titlePadding = st::settingsPremiumRowTitlePadding;
@ -273,6 +275,10 @@ not_null<Ui::AbstractButton*> AddViewListButton(
descriptionPadding);
description->setAttribute(Qt::WA_TransparentForMouseEvents);
if (newBadge) {
Ui::NewBadge::AddAfterLabel(parent, label);
}
const auto dummy = Ui::CreateChild<Ui::AbstractButton>(parent);
dummy->setAttribute(Qt::WA_TransparentForMouseEvents);
dummy->show();

View file

@ -51,7 +51,8 @@ using ConnectedBots = std::vector<ConnectedBot>;
[[nodiscard]] not_null<Ui::AbstractButton*> AddViewListButton(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> title,
rpl::producer<QString> subtitle);
rpl::producer<QString> subtitle,
bool newBadge = false);
[[nodiscard]] not_null<Ui::RoundButton*> AddFullWidthButton(
not_null<Ui::BoxContent*> box,

View file

@ -967,7 +967,8 @@ void InnerWidget::fill() {
const auto button = Info::BotStarRef::AddViewListButton(
container,
tr::lng_credits_summary_earn_title(),
tr::lng_credits_summary_earn_about());
tr::lng_credits_summary_earn_about(),
true);
button->setClickedCallback([=] {
_controller->showSection(Info::BotStarRef::Join::Make(_peer));
});

View file

@ -218,7 +218,8 @@ void Credits::setupStarRefPromo(not_null<Ui::VerticalLayout*> container) {
const auto button = Info::BotStarRef::AddViewListButton(
container,
tr::lng_credits_summary_earn_title(),
tr::lng_credits_summary_earn_about());
tr::lng_credits_summary_earn_about(),
true);
button->setClickedCallback([=] {
_controller->showSection(Info::BotStarRef::Join::Make(self));
});