Added strike out cost without discount in premium options in settings.

This commit is contained in:
23rd 2025-04-12 22:35:11 +03:00 committed by John Preston
parent 9ad1d1c25d
commit 3ed6d1dec1
4 changed files with 38 additions and 9 deletions

View file

@ -33,6 +33,9 @@ Data::PremiumSubscriptionOption CreateSubscriptionOption(
.costPerMonth = Ui::FillAmountAndCurrency(
amount / float64(months),
currency),
.costNoDiscount = Ui::FillAmountAndCurrency(
monthlyAmount * months,
currency),
.costTotal = Ui::FillAmountAndCurrency(amount, currency),
.botUrl = botUrl,
};

View file

@ -14,6 +14,7 @@ struct PremiumSubscriptionOption {
QString duration;
QString discount;
QString costPerMonth;
QString costNoDiscount;
QString costTotal;
QString total;
QString botUrl;

View file

@ -85,6 +85,7 @@ using SectionCustomTopBarData = Info::Settings::SectionCustomTopBarData;
if (option.duration == tr::lng_months(tr::now, lt_count, 1)) {
option.costPerMonth = QString();
option.costNoDiscount = QString();
option.duration = tr::lng_premium_subscribe_months_1(tr::now);
} else if (option.duration == tr::lng_months(tr::now, lt_count, 6)) {
option.duration = tr::lng_premium_subscribe_months_6(tr::now);

View file

@ -927,9 +927,19 @@ void AddGiftOptions(
const auto costPerMonthIcon = info.costPerMonth.startsWith(kStar)
? GenerateStars(costPerMonthFont->height, 1)
: QImage();
const auto costPerMonthText = costPerMonthIcon.isNull()
? info.costPerMonth
: removedStar(info.costPerMonth);
const auto costPerMonthLabel
= row->lifetime().make_state<Ui::Text::String>();
costPerMonthLabel->setMarkedText(
st::shareBoxListItem.nameStyle,
TextWithEntities()
.append(Ui::Text::Wrapped(
TextWithEntities{ info.costNoDiscount },
EntityType::StrikeOut))
.append(' ')
.append(costPerMonthIcon.isNull()
? info.costPerMonth
: removedStar(info.costPerMonth)));
const auto costTotalEntry = [&] {
if (!info.costTotal.startsWith(kStar)) {
return QImage();
@ -1049,12 +1059,26 @@ void AddGiftOptions(
0);
p.setPen(st::windowSubTextFg);
p.setFont(costPerMonthFont);
const auto perMonthLeft = costPerMonthFont->spacew
+ costPerMonthIcon.width() / style::DevicePixelRatio();
p.drawText(
perRect.translated(perMonthLeft, 0),
costPerMonthText,
style::al_left);
{
const auto left = costPerMonthIcon.isNull()
? 0
: (costPerMonthFont->spacew
+ costPerMonthIcon.width()
/ style::DevicePixelRatio());
const auto costTotalWidth = costTotalFont->width(
info.costTotal);
const auto pos = perRect.translated(left, 0).topLeft();
const auto availableWidth = row->width()
- pos.x()
- costTotalWidth;
costPerMonthLabel->draw(p, {
.position = pos,
.outerWidth = availableWidth,
.availableWidth = availableWidth,
.elisionLines = 1,
});
}
p.drawImage(perRect.topLeft(), costPerMonthIcon);
const auto totalRect = row->rect()