mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Implement star gift view box.
This commit is contained in:
parent
18904412cd
commit
efbd3ca8fa
16 changed files with 279 additions and 49 deletions
|
@ -3007,6 +3007,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_gift_sent_title" = "Gift Sent!";
|
"lng_gift_sent_title" = "Gift Sent!";
|
||||||
"lng_gift_sent_about#one" = "You spent **{count}** Star from your balance.";
|
"lng_gift_sent_about#one" = "You spent **{count}** Star from your balance.";
|
||||||
"lng_gift_sent_about#other" = "You spent **{count}** Stars from your balance.";
|
"lng_gift_sent_about#other" = "You spent **{count}** Stars from your balance.";
|
||||||
|
"lng_gift_limited_of_one" = "unique";
|
||||||
|
"lng_gift_limited_of_count" = "1 of {amount}";
|
||||||
|
"lng_gift_anonymous_hint" = "Only you can see the sender's name.";
|
||||||
|
"lng_gift_availability" = "Availability";
|
||||||
|
"lng_gift_availability_left#one" = "{count} of {amount} left";
|
||||||
|
"lng_gift_availability_left#other" = "{count} of {amount} left";
|
||||||
|
"lng_gift_availability_none" = "None of {amount} left";
|
||||||
|
|
||||||
"lng_accounts_limit_title" = "Limit Reached";
|
"lng_accounts_limit_title" = "Limit Reached";
|
||||||
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account.";
|
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account.";
|
||||||
|
|
|
@ -72,7 +72,7 @@ constexpr auto kTransactionsLimit = 100;
|
||||||
return Data::CreditsHistoryEntry{
|
return Data::CreditsHistoryEntry{
|
||||||
.id = qs(tl.data().vid()),
|
.id = qs(tl.data().vid()),
|
||||||
.title = qs(tl.data().vtitle().value_or_empty()),
|
.title = qs(tl.data().vtitle().value_or_empty()),
|
||||||
.description = qs(tl.data().vdescription().value_or_empty()),
|
.description = { qs(tl.data().vdescription().value_or_empty()) },
|
||||||
.date = base::unixtime::parse(tl.data().vdate().v),
|
.date = base::unixtime::parse(tl.data().vdate().v),
|
||||||
.photoId = photo ? photo->id : 0,
|
.photoId = photo ? photo->id : 0,
|
||||||
.extended = std::move(extended),
|
.extended = std::move(extended),
|
||||||
|
|
|
@ -612,6 +612,7 @@ auto PremiumGiftCodeOptions::requestStarGifts()
|
||||||
gifts.push_back(StarGift{
|
gifts.push_back(StarGift{
|
||||||
.id = uint64(data.vid().v),
|
.id = uint64(data.vid().v),
|
||||||
.stars = int64(data.vstars().v),
|
.stars = int64(data.vstars().v),
|
||||||
|
.convertStars = int64(data.vconvert_stars().v),
|
||||||
.document = document,
|
.document = document,
|
||||||
.limitedLeft = remaining.value_or_empty(),
|
.limitedLeft = remaining.value_or_empty(),
|
||||||
.limitedCount = total.value_or_empty(),
|
.limitedCount = total.value_or_empty(),
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct GiftOptionData {
|
||||||
struct StarGift {
|
struct StarGift {
|
||||||
uint64 id = 0;
|
uint64 id = 0;
|
||||||
int64 stars = 0;
|
int64 stars = 0;
|
||||||
|
int64 convertStars = 0;
|
||||||
not_null<DocumentData*> document;
|
not_null<DocumentData*> document;
|
||||||
int limitedLeft = 0;
|
int limitedLeft = 0;
|
||||||
int limitedCount = 0;
|
int limitedCount = 0;
|
||||||
|
|
|
@ -100,6 +100,7 @@ struct PremiumGiftsDescriptor {
|
||||||
struct GiftTypeStars {
|
struct GiftTypeStars {
|
||||||
uint64 id = 0;
|
uint64 id = 0;
|
||||||
int64 stars = 0;
|
int64 stars = 0;
|
||||||
|
int64 convertStars = 0;
|
||||||
DocumentData *document = nullptr;
|
DocumentData *document = nullptr;
|
||||||
bool limited = false;
|
bool limited = false;
|
||||||
|
|
||||||
|
@ -240,7 +241,7 @@ auto GenerateGiftMedia(
|
||||||
auto textFallback = tr::lng_action_gift_got_stars_text(
|
auto textFallback = tr::lng_action_gift_got_stars_text(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count,
|
lt_count,
|
||||||
v::get<GiftTypeStars>(descriptor).stars,
|
v::get<GiftTypeStars>(descriptor).convertStars,
|
||||||
Ui::Text::RichLangValue);
|
Ui::Text::RichLangValue);
|
||||||
auto description = data.text.isEmpty()
|
auto description = data.text.isEmpty()
|
||||||
? std::move(textFallback)
|
? std::move(textFallback)
|
||||||
|
@ -519,6 +520,7 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
|
||||||
list.push_back({
|
list.push_back({
|
||||||
.id = gift.id,
|
.id = gift.id,
|
||||||
.stars = gift.stars,
|
.stars = gift.stars,
|
||||||
|
.convertStars = gift.convertStars,
|
||||||
.document = gift.document,
|
.document = gift.document,
|
||||||
.limited = (gift.limitedCount > 0),
|
.limited = (gift.limitedCount > 0),
|
||||||
});
|
});
|
||||||
|
@ -1428,8 +1430,7 @@ void GiftBox(
|
||||||
const auto &stUser = st::premiumGiftsUserpicButton;
|
const auto &stUser = st::premiumGiftsUserpicButton;
|
||||||
const auto content = box->verticalLayout();
|
const auto content = box->verticalLayout();
|
||||||
|
|
||||||
AddSkip(content);
|
AddSkip(content, st::defaultVerticalListSkip * 5);
|
||||||
AddSkip(content);
|
|
||||||
|
|
||||||
content->add(
|
content->add(
|
||||||
object_ptr<CenterWrap<>>(
|
object_ptr<CenterWrap<>>(
|
||||||
|
|
|
@ -799,10 +799,12 @@ void AddTableRow(
|
||||||
object_ptr<Ui::RpWidget> value,
|
object_ptr<Ui::RpWidget> value,
|
||||||
style::margins valueMargins) {
|
style::margins valueMargins) {
|
||||||
table->addRow(
|
table->addRow(
|
||||||
object_ptr<Ui::FlatLabel>(
|
(label
|
||||||
table,
|
? object_ptr<Ui::FlatLabel>(
|
||||||
std::move(label),
|
table,
|
||||||
st::giveawayGiftCodeLabel),
|
std::move(label),
|
||||||
|
st::giveawayGiftCodeLabel)
|
||||||
|
: object_ptr<Ui::FlatLabel>(nullptr)),
|
||||||
std::move(value),
|
std::move(value),
|
||||||
st::giveawayGiftCodeLabelMargin,
|
st::giveawayGiftCodeLabelMargin,
|
||||||
valueMargins);
|
valueMargins);
|
||||||
|
@ -1708,6 +1710,59 @@ void ResolveGiveawayInfo(
|
||||||
crl::guard(controller, show));
|
crl::guard(controller, show));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddStarGiftTable(
|
||||||
|
not_null<Window::SessionNavigation*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
const Data::CreditsHistoryEntry &entry) {
|
||||||
|
auto table = container->add(
|
||||||
|
object_ptr<Ui::TableLayout>(
|
||||||
|
container,
|
||||||
|
st::giveawayGiftCodeTable),
|
||||||
|
st::giveawayGiftCodeTableMargin);
|
||||||
|
const auto peerId = PeerId(entry.barePeerId);
|
||||||
|
if (peerId) {
|
||||||
|
auto text = entry.in
|
||||||
|
? tr::lng_credits_box_history_entry_peer_in()
|
||||||
|
: tr::lng_credits_box_history_entry_peer();
|
||||||
|
AddTableRow(table, std::move(text), controller, peerId);
|
||||||
|
}
|
||||||
|
if (!entry.date.isNull()) {
|
||||||
|
AddTableRow(
|
||||||
|
table,
|
||||||
|
tr::lng_gift_link_label_date(),
|
||||||
|
rpl::single(Ui::Text::WithEntities(langDateTime(entry.date))));
|
||||||
|
}
|
||||||
|
if (entry.limitedCount > 0) {
|
||||||
|
auto amount = rpl::single(TextWithEntities{
|
||||||
|
QString::number(entry.limitedCount)
|
||||||
|
});
|
||||||
|
AddTableRow(
|
||||||
|
table,
|
||||||
|
tr::lng_gift_availability(),
|
||||||
|
((entry.limitedLeft > 0)
|
||||||
|
? tr::lng_gift_availability_left(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(entry.limitedLeft * 1.),
|
||||||
|
lt_amount,
|
||||||
|
std::move(amount),
|
||||||
|
Ui::Text::WithEntities)
|
||||||
|
: tr::lng_gift_availability_none(
|
||||||
|
lt_amount,
|
||||||
|
std::move(amount),
|
||||||
|
Ui::Text::WithEntities)));
|
||||||
|
}
|
||||||
|
if (!entry.description.empty()) {
|
||||||
|
table->addRow(
|
||||||
|
nullptr,
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
table,
|
||||||
|
rpl::single(entry.description),
|
||||||
|
st::giveawayGiftCodeValue),
|
||||||
|
st::giveawayGiftCodeLabelMargin,
|
||||||
|
st::giveawayGiftCodeValueMargin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddCreditsHistoryEntryTable(
|
void AddCreditsHistoryEntryTable(
|
||||||
not_null<Window::SessionNavigation*> controller,
|
not_null<Window::SessionNavigation*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
|
|
@ -76,6 +76,10 @@ void ResolveGiveawayInfo(
|
||||||
std::optional<Data::GiveawayStart> start,
|
std::optional<Data::GiveawayStart> start,
|
||||||
std::optional<Data::GiveawayResults> results);
|
std::optional<Data::GiveawayResults> results);
|
||||||
|
|
||||||
|
void AddStarGiftTable(
|
||||||
|
not_null<Window::SessionNavigation*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
const Data::CreditsHistoryEntry &entry);
|
||||||
void AddCreditsHistoryEntryTable(
|
void AddCreditsHistoryEntryTable(
|
||||||
not_null<Window::SessionNavigation*> controller,
|
not_null<Window::SessionNavigation*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct CreditsHistoryEntry final {
|
||||||
|
|
||||||
QString id;
|
QString id;
|
||||||
QString title;
|
QString title;
|
||||||
QString description;
|
TextWithEntities description;
|
||||||
QDateTime date;
|
QDateTime date;
|
||||||
PhotoId photoId = 0;
|
PhotoId photoId = 0;
|
||||||
std::vector<CreditsHistoryMedia> extended;
|
std::vector<CreditsHistoryMedia> extended;
|
||||||
|
@ -58,10 +58,17 @@ struct CreditsHistoryEntry final {
|
||||||
uint64 bareMsgId = 0;
|
uint64 bareMsgId = 0;
|
||||||
uint64 barePeerId = 0;
|
uint64 barePeerId = 0;
|
||||||
uint64 bareGiveawayMsgId = 0;
|
uint64 bareGiveawayMsgId = 0;
|
||||||
|
uint64 bareGiftStickerId = 0;
|
||||||
PeerType peerType;
|
PeerType peerType;
|
||||||
QDateTime subscriptionUntil;
|
QDateTime subscriptionUntil;
|
||||||
QDateTime successDate;
|
QDateTime successDate;
|
||||||
QString successLink;
|
QString successLink;
|
||||||
|
int limitedCount = 0;
|
||||||
|
int limitedLeft = 0;
|
||||||
|
int convertStars = 0;
|
||||||
|
bool converted = false;
|
||||||
|
bool anonymous = false;
|
||||||
|
bool savedToProfile = false;
|
||||||
bool reaction = false;
|
bool reaction = false;
|
||||||
bool refunded = false;
|
bool refunded = false;
|
||||||
bool pending = false;
|
bool pending = false;
|
||||||
|
|
|
@ -141,6 +141,7 @@ struct GiftCode {
|
||||||
MsgId giveawayMsgId = 0;
|
MsgId giveawayMsgId = 0;
|
||||||
int convertStars = 0;
|
int convertStars = 0;
|
||||||
int limitedCount = 0;
|
int limitedCount = 0;
|
||||||
|
int limitedLeft = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
GiftType type = GiftType::Premium;
|
GiftType type = GiftType::Premium;
|
||||||
bool viaGiveaway : 1 = false;
|
bool viaGiveaway : 1 = false;
|
||||||
|
|
|
@ -5490,6 +5490,7 @@ void HistoryItem::applyAction(const MTPMessageAction &action) {
|
||||||
: TextWithEntities()),
|
: TextWithEntities()),
|
||||||
.convertStars = int(data.vconvert_stars().v),
|
.convertStars = int(data.vconvert_stars().v),
|
||||||
.limitedCount = gift.vavailability_total().value_or_empty(),
|
.limitedCount = gift.vavailability_total().value_or_empty(),
|
||||||
|
.limitedLeft = gift.vavailability_remains().value_or_empty(),
|
||||||
.count = int(gift.vstars().v),
|
.count = int(gift.vstars().v),
|
||||||
.type = Data::GiftType::StarGift,
|
.type = Data::GiftType::StarGift,
|
||||||
.anonymous = data.is_name_hidden(),
|
.anonymous = data.is_name_hidden(),
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_credits.h"
|
#include "data/data_credits.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
@ -79,14 +80,14 @@ TextWithEntities PremiumGift::subtitle() {
|
||||||
? tr::lng_action_gift_sent_text(
|
? tr::lng_action_gift_sent_text(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count,
|
lt_count,
|
||||||
_data.count,
|
_data.convertStars,
|
||||||
lt_user,
|
lt_user,
|
||||||
Ui::Text::Bold(_parent->history()->peer->shortName()),
|
Ui::Text::Bold(_parent->history()->peer->shortName()),
|
||||||
Ui::Text::RichLangValue)
|
Ui::Text::RichLangValue)
|
||||||
: tr::lng_action_gift_got_stars_text(
|
: tr::lng_action_gift_got_stars_text(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count,
|
lt_count,
|
||||||
_data.count,
|
_data.convertStars,
|
||||||
Ui::Text::RichLangValue);
|
Ui::Text::RichLangValue);
|
||||||
}
|
}
|
||||||
const auto isCreditsPrize = creditsPrize();
|
const auto isCreditsPrize = creditsPrize();
|
||||||
|
@ -149,6 +150,7 @@ ClickHandlerPtr PremiumGift::createViewLink() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const auto from = _gift->from();
|
const auto from = _gift->from();
|
||||||
|
const auto itemId = _parent->data()->fullId();
|
||||||
const auto peer = _parent->history()->peer;
|
const auto peer = _parent->history()->peer;
|
||||||
const auto date = _parent->data()->date();
|
const auto date = _parent->data()->date();
|
||||||
const auto data = _gift->data();
|
const auto data = _gift->data();
|
||||||
|
@ -157,25 +159,21 @@ ClickHandlerPtr PremiumGift::createViewLink() {
|
||||||
if (const auto controller = my.sessionWindow.get()) {
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
const auto selfId = controller->session().userPeerId();
|
const auto selfId = controller->session().userPeerId();
|
||||||
const auto sent = (from->id == selfId);
|
const auto sent = (from->id == selfId);
|
||||||
if (creditsPrize()) {
|
if (starGift()) {
|
||||||
using Type = Data::CreditsHistoryEntry::PeerType;
|
const auto item = controller->session().data().message(itemId);
|
||||||
|
if (item) {
|
||||||
|
controller->show(Box(
|
||||||
|
Settings::StarGiftViewBox,
|
||||||
|
controller,
|
||||||
|
data,
|
||||||
|
item));
|
||||||
|
}
|
||||||
|
} else if (creditsPrize()) {
|
||||||
controller->show(Box(
|
controller->show(Box(
|
||||||
Settings::ReceiptCreditsBox,
|
Settings::CreditsPrizeBox,
|
||||||
controller,
|
controller,
|
||||||
Data::CreditsHistoryEntry{
|
data,
|
||||||
.id = data.slug,
|
date));
|
||||||
.title = QString(),
|
|
||||||
.description = QString(),
|
|
||||||
.date = base::unixtime::parse(date),
|
|
||||||
.credits = uint64(data.count),
|
|
||||||
.barePeerId = data.channel
|
|
||||||
? data.channel->id.value
|
|
||||||
: 0,
|
|
||||||
.bareGiveawayMsgId = uint64(data.giveawayMsgId.bare),
|
|
||||||
.peerType = Type::Peer,
|
|
||||||
.in = true,
|
|
||||||
},
|
|
||||||
Data::SubscriptionEntry()));
|
|
||||||
} else if (data.type == Data::GiftType::Credits) {
|
} else if (data.type == Data::GiftType::Credits) {
|
||||||
const auto to = sent ? peer : peer->session().user();
|
const auto to = sent ? peer : peer->session().user();
|
||||||
controller->show(Box(
|
controller->show(Box(
|
||||||
|
@ -212,6 +210,20 @@ void PremiumGift::draw(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PremiumGift::cornerTagText() {
|
||||||
|
if (const auto count = _data.limitedCount) {
|
||||||
|
return (count == 1)
|
||||||
|
? tr::lng_gift_limited_of_one(tr::now)
|
||||||
|
: tr::lng_gift_limited_of_count(
|
||||||
|
tr::now,
|
||||||
|
lt_amount,
|
||||||
|
((count % 1000)
|
||||||
|
? Lang::FormatCountDecimal(count)
|
||||||
|
: Lang::FormatCountToShort(count).string));
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
bool PremiumGift::hideServiceText() {
|
bool PremiumGift::hideServiceText() {
|
||||||
return !gift();
|
return !gift();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
QString title() override;
|
QString title() override;
|
||||||
TextWithEntities subtitle() override;
|
TextWithEntities subtitle() override;
|
||||||
rpl::producer<QString> button() override;
|
rpl::producer<QString> button() override;
|
||||||
|
QString cornerTagText() override;
|
||||||
int buttonSkip() override;
|
int buttonSkip() override;
|
||||||
void draw(
|
void draw(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
|
|
|
@ -151,6 +151,30 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const {
|
||||||
|
|
||||||
_content->draw(p, context, content);
|
_content->draw(p, context, content);
|
||||||
|
|
||||||
|
if (const auto tag = _content->cornerTagText(); !tag.isEmpty()) {
|
||||||
|
const auto font = st::semiboldFont;
|
||||||
|
p.setFont(font);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
const auto twidth = font->width(tag);
|
||||||
|
const auto pos = QPoint(_innerSize.width() - twidth, font->height);
|
||||||
|
const auto add = style::ConvertScale(2);
|
||||||
|
p.save();
|
||||||
|
p.setClipRect(
|
||||||
|
-add,
|
||||||
|
-add,
|
||||||
|
_innerSize.width() + 2 * add,
|
||||||
|
_innerSize.height() + 2 * add);
|
||||||
|
p.translate(pos);
|
||||||
|
p.rotate(45.);
|
||||||
|
p.translate(-pos);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.setBrush(context.st->msgServiceBg()); // ?
|
||||||
|
p.drawRect(-5 * twidth, 0, twidth * 12, font->height);
|
||||||
|
p.setPen(context.st->msgServiceFg());
|
||||||
|
p.drawText(pos - QPoint(0, font->descent), tag);
|
||||||
|
p.restore();
|
||||||
|
}
|
||||||
|
|
||||||
p.translate(0, -st::msgServiceGiftBoxTopSkip);
|
p.translate(0, -st::msgServiceGiftBoxTopSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ public:
|
||||||
return top();
|
return top();
|
||||||
}
|
}
|
||||||
[[nodiscard]] virtual rpl::producer<QString> button() = 0;
|
[[nodiscard]] virtual rpl::producer<QString> button() = 0;
|
||||||
|
[[nodiscard]] virtual QString cornerTagText() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
virtual void draw(
|
virtual void draw(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
|
|
|
@ -16,11 +16,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/gift_premium_box.h"
|
#include "boxes/gift_premium_box.h"
|
||||||
#include "chat_helpers/stickers_gift_box_pack.h"
|
#include "chat_helpers/stickers_gift_box_pack.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "core/click_handler_types.h" // UrlClickHandler
|
#include "core/click_handler_types.h" // UrlClickHandler
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "data/components/credits.h"
|
#include "data/components/credits.h"
|
||||||
#include "data/data_boosts.h"
|
#include "data/data_boosts.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
|
@ -35,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
||||||
#include "info/settings/info_settings_widget.h" // SectionCustomTopBarData.
|
#include "info/settings/info_settings_widget.h" // SectionCustomTopBarData.
|
||||||
#include "info/statistics/info_statistics_list_controllers.h"
|
#include "info/statistics/info_statistics_list_controllers.h"
|
||||||
|
#include "iv/iv_instance.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "lottie/lottie_single_player.h"
|
#include "lottie/lottie_single_player.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
|
@ -657,6 +660,10 @@ void ReceiptCreditsBox(
|
||||||
const auto &stUser = st::boostReplaceUserpic;
|
const auto &stUser = st::boostReplaceUserpic;
|
||||||
const auto session = &controller->session();
|
const auto session = &controller->session();
|
||||||
const auto isPrize = e.bareGiveawayMsgId > 0;
|
const auto isPrize = e.bareGiveawayMsgId > 0;
|
||||||
|
const auto isStarGift = (e.convertStars > 0);
|
||||||
|
const auto starGiftSticker = (isStarGift && e.bareGiftStickerId)
|
||||||
|
? session->data().document(e.bareGiftStickerId).get()
|
||||||
|
: nullptr;
|
||||||
const auto peer = isPrize
|
const auto peer = isPrize
|
||||||
? nullptr
|
? nullptr
|
||||||
: (s.barePeerId)
|
: (s.barePeerId)
|
||||||
|
@ -682,14 +689,15 @@ void ReceiptCreditsBox(
|
||||||
std::unique_ptr<Lottie::SinglePlayer> lottie;
|
std::unique_ptr<Lottie::SinglePlayer> lottie;
|
||||||
rpl::lifetime downloadLifetime;
|
rpl::lifetime downloadLifetime;
|
||||||
};
|
};
|
||||||
Ui::AddSkip(
|
Ui::AddSkip(content, st::creditsHistoryEntryGiftStickerSpace
|
||||||
content,
|
- (isStarGift ? st::creditsHistoryEntryGiftStickerSkip : 0));
|
||||||
st::creditsHistoryEntryGiftStickerSpace);
|
|
||||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(content);
|
const auto icon = Ui::CreateChild<Ui::RpWidget>(content);
|
||||||
icon->resize(Size(st::creditsHistoryEntryGiftStickerSize));
|
icon->resize(Size(st::creditsHistoryEntryGiftStickerSize));
|
||||||
const auto state = icon->lifetime().make_state<State>();
|
const auto state = icon->lifetime().make_state<State>();
|
||||||
auto &packs = session->giftBoxStickersPacks();
|
auto &packs = session->giftBoxStickersPacks();
|
||||||
const auto document = packs.lookup(packs.monthsForStars(e.credits));
|
const auto document = starGiftSticker
|
||||||
|
? starGiftSticker
|
||||||
|
: packs.lookup(packs.monthsForStars(e.credits));
|
||||||
if (document && document->sticker()) {
|
if (document && document->sticker()) {
|
||||||
state->sticker = document;
|
state->sticker = document;
|
||||||
state->media = document->createMediaView();
|
state->media = document->createMediaView();
|
||||||
|
@ -729,7 +737,7 @@ void ReceiptCreditsBox(
|
||||||
) | rpl::start_with_next([=](const QSize &size) {
|
) | rpl::start_with_next([=](const QSize &size) {
|
||||||
icon->move(
|
icon->move(
|
||||||
(size.width() - icon->width()) / 2,
|
(size.width() - icon->width()) / 2,
|
||||||
st::creditsHistoryEntryGiftStickerSkip);
|
isStarGift ? 0 : st::creditsHistoryEntryGiftStickerSkip);
|
||||||
}, icon->lifetime());
|
}, icon->lifetime());
|
||||||
} else {
|
} else {
|
||||||
const auto widget = content->add(
|
const auto widget = content->add(
|
||||||
|
@ -810,7 +818,11 @@ void ReceiptCreditsBox(
|
||||||
context);
|
context);
|
||||||
} else {
|
} else {
|
||||||
auto t = TextWithEntities()
|
auto t = TextWithEntities()
|
||||||
.append(e.in ? u"+"_q : e.gift ? QString() : QString(kMinus))
|
.append((e.in && !isStarGift)
|
||||||
|
? u"+"_q
|
||||||
|
: e.gift
|
||||||
|
? QString()
|
||||||
|
: QString(kMinus))
|
||||||
.append(Lang::FormatCountDecimal(std::abs(int64(e.credits))))
|
.append(Lang::FormatCountDecimal(std::abs(int64(e.credits))))
|
||||||
.append(QChar(' '))
|
.append(QChar(' '))
|
||||||
.append(session->data().customEmojiManager().creditsEmoji());
|
.append(session->data().customEmojiManager().creditsEmoji());
|
||||||
|
@ -882,7 +894,7 @@ void ReceiptCreditsBox(
|
||||||
}, amount->lifetime());
|
}, amount->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.description.isEmpty()) {
|
if (!isStarGift && !e.description.empty()) {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||||
box,
|
box,
|
||||||
|
@ -891,7 +903,30 @@ void ReceiptCreditsBox(
|
||||||
rpl::single(e.description),
|
rpl::single(e.description),
|
||||||
st::creditsBoxAbout)));
|
st::creditsBoxAbout)));
|
||||||
}
|
}
|
||||||
if (e.gift || isPrize) {
|
if (isStarGift) {
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
const auto about = box->addRow(
|
||||||
|
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||||
|
box,
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
box,
|
||||||
|
rpl::combine(
|
||||||
|
tr::lng_action_gift_got_stars_text(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(e.convertStars * 1.),
|
||||||
|
Ui::Text::RichLangValue),
|
||||||
|
tr::lng_paid_about_link()
|
||||||
|
) | rpl::map([](TextWithEntities text, QString link) {
|
||||||
|
return text.append(' ').append(Ui::Text::Link(link));
|
||||||
|
}),
|
||||||
|
st::creditsBoxAbout)))->entity();
|
||||||
|
about->setClickHandlerFilter([=](const auto &...) {
|
||||||
|
Core::App().iv().openWithIvPreferred(
|
||||||
|
session,
|
||||||
|
tr::lng_paid_about_link_url(tr::now));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else if (e.gift || isPrize) {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
const auto arrow = Ui::Text::SingleCustomEmoji(
|
const auto arrow = Ui::Text::SingleCustomEmoji(
|
||||||
session->data().customEmojiManager().registerInternalEmoji(
|
session->data().customEmojiManager().registerInternalEmoji(
|
||||||
|
@ -929,23 +964,35 @@ void ReceiptCreditsBox(
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
AddCreditsHistoryEntryTable(controller, content, e);
|
if (isStarGift) {
|
||||||
AddSubscriptionEntryTable(controller, content, s);
|
AddStarGiftTable(controller, content, e);
|
||||||
|
} else {
|
||||||
|
AddCreditsHistoryEntryTable(controller, content, e);
|
||||||
|
AddSubscriptionEntryTable(controller, content, s);
|
||||||
|
}
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
if (!isStarGift) {
|
||||||
box,
|
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
box,
|
||||||
tr::lng_credits_box_out_about(
|
object_ptr<Ui::FlatLabel>(
|
||||||
lt_link,
|
box,
|
||||||
tr::lng_payments_terms_link(
|
tr::lng_credits_box_out_about(
|
||||||
) | Ui::Text::ToLink(
|
lt_link,
|
||||||
tr::lng_credits_box_out_about_link(tr::now)),
|
tr::lng_payments_terms_link(
|
||||||
Ui::Text::WithEntities),
|
) | Ui::Text::ToLink(
|
||||||
st::creditsBoxAboutDivider)));
|
tr::lng_credits_box_out_about_link(tr::now)),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
st::creditsBoxAboutDivider)));
|
||||||
|
} else if (e.anonymous) {
|
||||||
|
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||||
|
box,
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
box,
|
||||||
|
tr::lng_gift_anonymous_hint(),
|
||||||
|
st::creditsBoxAboutDivider)));
|
||||||
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||||
|
@ -1085,6 +1132,60 @@ void GiftedCreditsBox(
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreditsPrizeBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const Data::GiftCode &data,
|
||||||
|
TimeId date) {
|
||||||
|
using Type = Data::CreditsHistoryEntry::PeerType;
|
||||||
|
Settings::ReceiptCreditsBox(
|
||||||
|
box,
|
||||||
|
controller,
|
||||||
|
Data::CreditsHistoryEntry{
|
||||||
|
.id = data.slug,
|
||||||
|
.title = QString(),
|
||||||
|
.description = QString(),
|
||||||
|
.date = base::unixtime::parse(date),
|
||||||
|
.credits = uint64(data.count),
|
||||||
|
.barePeerId = data.channel
|
||||||
|
? data.channel->id.value
|
||||||
|
: 0,
|
||||||
|
.bareGiveawayMsgId = uint64(data.giveawayMsgId.bare),
|
||||||
|
.peerType = Type::Peer,
|
||||||
|
.in = true,
|
||||||
|
},
|
||||||
|
Data::SubscriptionEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StarGiftViewBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const Data::GiftCode &data,
|
||||||
|
not_null<HistoryItem*> item) {
|
||||||
|
Settings::ReceiptCreditsBox(
|
||||||
|
box,
|
||||||
|
controller,
|
||||||
|
Data::CreditsHistoryEntry{
|
||||||
|
.id = data.slug,
|
||||||
|
.description = data.message,
|
||||||
|
.date = base::unixtime::parse(item->date()),
|
||||||
|
.credits = uint64(data.count),
|
||||||
|
.bareMsgId = uint64(item->id.bare),
|
||||||
|
.barePeerId = item->history()->peer->id.value,
|
||||||
|
.bareGiftStickerId = data.document ? data.document->id : 0,
|
||||||
|
.peerType = Data::CreditsHistoryEntry::PeerType::Peer,
|
||||||
|
.limitedCount = data.limitedCount,
|
||||||
|
.limitedLeft = data.limitedLeft,
|
||||||
|
.convertStars = data.convertStars,
|
||||||
|
.converted = data.converted,
|
||||||
|
.anonymous = data.anonymous,
|
||||||
|
.savedToProfile = data.saved,
|
||||||
|
.in = true,
|
||||||
|
.gift = true,
|
||||||
|
},
|
||||||
|
Data::SubscriptionEntry());
|
||||||
|
}
|
||||||
|
|
||||||
void ShowRefundInfoBox(
|
void ShowRefundInfoBox(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
FullMsgId refundItemId) {
|
FullMsgId refundItemId) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Data {
|
||||||
struct Boost;
|
struct Boost;
|
||||||
struct CreditsHistoryEntry;
|
struct CreditsHistoryEntry;
|
||||||
struct SubscriptionEntry;
|
struct SubscriptionEntry;
|
||||||
|
struct GiftCode;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
|
@ -86,6 +87,16 @@ void GiftedCreditsBox(
|
||||||
not_null<PeerData*> to,
|
not_null<PeerData*> to,
|
||||||
int count,
|
int count,
|
||||||
TimeId date);
|
TimeId date);
|
||||||
|
void CreditsPrizeBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const Data::GiftCode &data,
|
||||||
|
TimeId date);
|
||||||
|
void StarGiftViewBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const Data::GiftCode &data,
|
||||||
|
not_null<HistoryItem*> item);
|
||||||
void ShowRefundInfoBox(
|
void ShowRefundInfoBox(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
FullMsgId refundItemId);
|
FullMsgId refundItemId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue