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_subscriber_subtitle" = "appx. {total} per month";
"lng_credits_subscription_row_to" = "Subscription"; "lng_credits_subscription_row_to" = "Subscription";
"lng_credits_subscription_row_to_bot" = "Bot";
"lng_credits_subscription_row_from" = "Subscribed"; "lng_credits_subscription_row_from" = "Subscribed";
"lng_credits_subscription_row_next_on" = "Renews"; "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()) { if (!entry.id.isEmpty()) {
constexpr auto kOneLineCount = 22; constexpr auto kOneLineCount = 22;
const auto oneLine = entry.id.size() <= kOneLineCount; const auto oneLine = entry.id.size() <= kOneLineCount;
@ -1326,9 +1333,17 @@ void AddSubscriptionEntryTable(
const auto peerId = PeerId(s.barePeerId); const auto peerId = PeerId(s.barePeerId);
AddTableRow( AddTableRow(
table, 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, controller,
peerId); 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.until.isNull()) {
if (s.subscription.period > 0) { if (s.subscription.period > 0) {
const auto subscribed = s.until.addSecs(-s.subscription.period); const auto subscribed = s.until.addSecs(-s.subscription.period);

View file

@ -852,6 +852,16 @@ void ReceiptCreditsBox(
content, content,
GenericEntryPhoto(content, callback, stUser.photoSize))); GenericEntryPhoto(content, callback, stUser.photoSize)));
AddViewMediaHandler(thumb->entity(), controller, e); 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) { } else if (peer && !e.gift) {
if (e.subscriptionUntil.isNull() && s.until.isNull()) { if (e.subscriptionUntil.isNull() && s.until.isNull()) {
content->add(object_ptr<Ui::CenterWrap<>>( content->add(object_ptr<Ui::CenterWrap<>>(
@ -951,11 +961,13 @@ void ReceiptCreditsBox(
box, box,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
rpl::single(!s.until.isNull() rpl::single(!s.title.isEmpty()
? s.title
: !s.until.isNull()
? tr::lng_credits_box_subscription_title(tr::now) ? tr::lng_credits_box_subscription_title(tr::now)
: isPrize : isPrize
? tr::lng_credits_box_history_entry_giveaway_name(tr::now) ? 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) ? tr::lng_credits_box_history_entry_subscription(tr::now)
: !e.title.isEmpty() : !e.title.isEmpty()
? e.title ? e.title