From 75183612662c38f6375be2ee5919ccbe2a3ce901 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 13 Nov 2024 23:59:49 +0300 Subject: [PATCH] Improved style of ReceiptCreditsBox for subscription with detailed info. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/gift_premium_box.cpp | 17 ++++++++++++++++- .../settings/settings_credits_graphics.cpp | 16 ++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 6d6e3ed67..b838c9367 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2509,6 +2509,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_subscriber_subtitle" = "appx. {total} per month"; "lng_credits_subscription_row_to" = "Subscription"; +"lng_credits_subscription_row_to_bot" = "Bot"; "lng_credits_subscription_row_from" = "Subscribed"; "lng_credits_subscription_row_next_on" = "Renews"; diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index a3d385c72..482f6678a 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1247,6 +1247,13 @@ void AddCreditsHistoryEntryTable( })); } } + if (!entry.subscriptionUntil.isNull() && !entry.title.isEmpty()) { + AddTableRow( + table, + tr::lng_gift_link_label_reason(), + tr::lng_credits_box_history_entry_subscription( + Ui::Text::WithEntities)); + } if (!entry.id.isEmpty()) { constexpr auto kOneLineCount = 22; const auto oneLine = entry.id.size() <= kOneLineCount; @@ -1326,9 +1333,17 @@ void AddSubscriptionEntryTable( const auto peerId = PeerId(s.barePeerId); AddTableRow( table, - tr::lng_credits_subscription_row_to(), + (!s.title.isEmpty() && peerIsUser(peerId)) + ? tr::lng_credits_subscription_row_to_bot() + : tr::lng_credits_subscription_row_to(), controller, peerId); + if (!s.title.isEmpty()) { + AddTableRow( + table, + tr::lng_credits_subscription_row_to(), + rpl::single(Ui::Text::WithEntities(s.title))); + } if (!s.until.isNull()) { if (s.subscription.period > 0) { const auto subscribed = s.until.addSecs(-s.subscription.period); diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 298ca6925..8d913bdac 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -852,6 +852,16 @@ void ReceiptCreditsBox( content, GenericEntryPhoto(content, callback, stUser.photoSize))); AddViewMediaHandler(thumb->entity(), controller, e); + } else if (s.photoId || (e.photoId && !e.subscriptionUntil.isNull())) { + const auto photoId = s.photoId ? s.photoId : e.photoId; + const auto callback = [=](Fn update) { + return Ui::GenerateCreditsPaintEntryCallback( + session->data().photo(photoId), + std::move(update)); + }; + content->add(object_ptr>( + content, + GenericEntryPhoto(content, callback, stUser.photoSize))); } else if (peer && !e.gift) { if (e.subscriptionUntil.isNull() && s.until.isNull()) { content->add(object_ptr>( @@ -951,11 +961,13 @@ void ReceiptCreditsBox( box, object_ptr( box, - rpl::single(!s.until.isNull() + rpl::single(!s.title.isEmpty() + ? s.title + : !s.until.isNull() ? tr::lng_credits_box_subscription_title(tr::now) : isPrize ? tr::lng_credits_box_history_entry_giveaway_name(tr::now) - : !e.subscriptionUntil.isNull() + : (!e.subscriptionUntil.isNull() && e.title.isEmpty()) ? tr::lng_credits_box_history_entry_subscription(tr::now) : !e.title.isEmpty() ? e.title