diff --git a/Telegram/SourceFiles/api/api_premium_option.cpp b/Telegram/SourceFiles/api/api_premium_option.cpp index c4346dbe07..f5f0af380d 100644 --- a/Telegram/SourceFiles/api/api_premium_option.cpp +++ b/Telegram/SourceFiles/api/api_premium_option.cpp @@ -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, }; diff --git a/Telegram/SourceFiles/data/data_premium_subscription_option.h b/Telegram/SourceFiles/data/data_premium_subscription_option.h index df2c4a8c4e..5b11a532f0 100644 --- a/Telegram/SourceFiles/data/data_premium_subscription_option.h +++ b/Telegram/SourceFiles/data/data_premium_subscription_option.h @@ -14,6 +14,7 @@ struct PremiumSubscriptionOption { QString duration; QString discount; QString costPerMonth; + QString costNoDiscount; QString costTotal; QString total; QString botUrl; diff --git a/Telegram/SourceFiles/settings/settings_premium.cpp b/Telegram/SourceFiles/settings/settings_premium.cpp index a834f9a6d8..ff3868f059 100644 --- a/Telegram/SourceFiles/settings/settings_premium.cpp +++ b/Telegram/SourceFiles/settings/settings_premium.cpp @@ -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); diff --git a/Telegram/SourceFiles/ui/effects/premium_graphics.cpp b/Telegram/SourceFiles/ui/effects/premium_graphics.cpp index ed73836f3c..5b277429d4 100644 --- a/Telegram/SourceFiles/ui/effects/premium_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/premium_graphics.cpp @@ -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(); + 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()