Improved style of ReceiptCreditsBox for subscription with detailed info.

This commit is contained in:
23rd 2024-11-13 23:59:49 +03:00 committed by John Preston
parent f7aaece2f7
commit 7518361266
3 changed files with 31 additions and 3 deletions

View File

@ -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";

View File

@ -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);

View File

@ -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<void()> update) {
return Ui::GenerateCreditsPaintEntryCallback(
session->data().photo(photoId),
std::move(update));
};
content->add(object_ptr<Ui::CenterWrap<>>(
content,
GenericEntryPhoto(content, callback, stUser.photoSize)));
} else if (peer && !e.gift) {
if (e.subscriptionUntil.isNull() && s.until.isNull()) {
content->add(object_ptr<Ui::CenterWrap<>>(
@ -951,11 +961,13 @@ void ReceiptCreditsBox(
box,
object_ptr<Ui::FlatLabel>(
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