Fixed display of credits icon in table row from gift box.

This commit is contained in:
23rd 2025-02-04 21:31:39 +03:00 committed by John Preston
parent f2f0c7df92
commit 049ebf9027

View file

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/basic_click_handlers.h" // UrlClickHandler::Open. #include "ui/basic_click_handlers.h" // UrlClickHandler::Open.
#include "ui/boxes/boost_box.h" // StartFireworks. #include "ui/boxes/boost_box.h" // StartFireworks.
#include "ui/controls/userpic_button.h" #include "ui/controls/userpic_button.h"
#include "ui/effects/credits_graphics.h"
#include "ui/effects/premium_graphics.h" #include "ui/effects/premium_graphics.h"
#include "ui/effects/premium_stars_colored.h" #include "ui/effects/premium_stars_colored.h"
#include "ui/effects/premium_top_bar.h" #include "ui/effects/premium_top_bar.h"
@ -405,21 +406,14 @@ void AddTableRow(
auto result = object_ptr<Ui::RpWidget>(table); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto session = &show->session(); const auto star = Ui::CreateSingleStarWidget(
const auto makeContext = [session](Fn<void()> update) { raw,
return Core::MarkedTextContext{ table->st().defaultValue.style.font->height);
.session = session,
.customEmojiRepaint = std::move(update),
};
};
auto star = session->data().customEmojiManager().creditsEmoji();
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
raw, raw,
rpl::single(star.append( Lang::FormatStarsAmountDecimal(entry.credits),
' ' + Lang::FormatStarsAmountDecimal(entry.credits))),
table->st().defaultValue, table->st().defaultValue,
st::defaultPopupMenu, st::defaultPopupMenu);
std::move(makeContext));
const auto convert = convertToStars const auto convert = convertToStars
? Ui::CreateChild<Ui::RoundButton>( ? Ui::CreateChild<Ui::RoundButton>(
@ -430,7 +424,8 @@ void AddTableRow(
table->st().smallButton) table->st().smallButton)
: nullptr; : nullptr;
if (convert) { if (convert) {
convert->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); using namespace Ui;
convert->setTextTransform(RoundButton::TextTransform::NoTransform);
convert->setClickedCallback(std::move(convertToStars)); convert->setClickedCallback(std::move(convertToStars));
} }
rpl::combine( rpl::combine(
@ -440,11 +435,13 @@ void AddTableRow(
const auto convertSkip = convertWidth const auto convertSkip = convertWidth
? (st::normalFont->spacew + convertWidth) ? (st::normalFont->spacew + convertWidth)
: 0; : 0;
label->resizeToNaturalWidth(width - convertSkip); const auto labelLeft = rect::right(star) + st::normalFont->spacew;
label->moveToLeft(0, 0, width); label->resizeToNaturalWidth(width - convertSkip - labelLeft);
star->moveToLeft(0, 0, width);
label->moveToLeft(labelLeft, 0, width);
if (convert) { if (convert) {
convert->moveToLeft( convert->moveToLeft(
label->width() + st::normalFont->spacew, rect::right(label) + st::normalFont->spacew,
(table->st().defaultValue.style.font->ascent (table->st().defaultValue.style.font->ascent
- table->st().smallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);