mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added boost badge to buttons for prepaid giveaways.
This commit is contained in:
parent
97bd865916
commit
ca1a548fb8
4 changed files with 38 additions and 7 deletions
|
@ -312,7 +312,8 @@ void CreateGiveawayBox(
|
|||
lt_duration,
|
||||
tr::lng_premium_gift_duration_months(
|
||||
lt_count,
|
||||
rpl::single(prepaid->months) | tr::to_count())))
|
||||
rpl::single(prepaid->months) | tr::to_count())),
|
||||
QImage())
|
||||
)->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
if (!prepaid) {
|
||||
|
|
|
@ -36,7 +36,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
|||
: (type == Type::AllMembers)
|
||||
? tr::lng_giveaway_users_all()
|
||||
: tr::lng_giveaway_users_new(),
|
||||
std::move(subtitle)) {
|
||||
std::move(subtitle),
|
||||
QImage()) {
|
||||
}
|
||||
|
||||
GiveawayTypeRow::GiveawayTypeRow(
|
||||
|
@ -44,7 +45,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
|||
Type type,
|
||||
int colorIndex,
|
||||
rpl::producer<QString> title,
|
||||
rpl::producer<QString> subtitle)
|
||||
rpl::producer<QString> subtitle,
|
||||
QImage badge)
|
||||
: RippleButton(parent, st::defaultRippleAnimation)
|
||||
, _type(type)
|
||||
, _st((_type == Type::SpecificUsers || _type == Type::Random)
|
||||
|
@ -54,7 +56,8 @@ GiveawayTypeRow::GiveawayTypeRow(
|
|||
: st::giveawayGiftCodeMembersPeerList.item)
|
||||
, _userpic(
|
||||
Ui::EmptyUserpic::UserpicColor(Ui::EmptyUserpic::ColorIndex(colorIndex)),
|
||||
QString()) {
|
||||
QString())
|
||||
, _badge(std::move(badge)) {
|
||||
std::move(
|
||||
subtitle
|
||||
) | rpl::start_with_next([=] (const QString &s) {
|
||||
|
@ -111,8 +114,19 @@ void GiveawayTypeRow::paintEvent(QPaintEvent *e) {
|
|||
const auto namey = _st.namePosition.y();
|
||||
const auto namew = outerWidth - namex - skipRight;
|
||||
|
||||
const auto badgew = _badge.width() / style::DevicePixelRatio();
|
||||
|
||||
p.setPen(_st.nameFg);
|
||||
_name.drawLeftElided(p, namex, namey, namew, width());
|
||||
_name.drawLeftElided(p, namex, namey, namew - badgew, width());
|
||||
|
||||
if (!_badge.isNull()) {
|
||||
p.drawImage(
|
||||
std::min(
|
||||
namex + _name.maxWidth() + st::boostsListBadgePadding.left(),
|
||||
outerWidth - badgew - skipRight),
|
||||
namey + st::boostsListMiniIconSkip,
|
||||
_badge);
|
||||
}
|
||||
|
||||
const auto statusx = _st.statusPosition.x();
|
||||
const auto statusy = _st.statusPosition.y();
|
||||
|
|
|
@ -39,7 +39,8 @@ public:
|
|||
Type type,
|
||||
int colorIndex,
|
||||
rpl::producer<QString> title,
|
||||
rpl::producer<QString> subtitle);
|
||||
rpl::producer<QString> subtitle,
|
||||
QImage badge);
|
||||
|
||||
void addRadio(std::shared_ptr<Ui::RadioenumGroup<Type>> typeGroup);
|
||||
|
||||
|
@ -56,6 +57,8 @@ private:
|
|||
Ui::Text::String _status;
|
||||
Ui::Text::String _name;
|
||||
|
||||
QImage _badge;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Giveaway
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "info/boosts/create_giveaway_box.h"
|
||||
#include "info/boosts/giveaway/boost_badge.h"
|
||||
#include "info/boosts/giveaway/giveaway_type_row.h"
|
||||
#include "info/boosts/info_boosts_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
|
@ -326,6 +327,8 @@ void InnerWidget::fill() {
|
|||
::Settings::AddSkip(inner);
|
||||
|
||||
if (!status.prepaidGiveaway.empty()) {
|
||||
const auto multiplier = Api::PremiumGiftCodeOptions(_peer)
|
||||
.giveawayBoostsPerPremium();
|
||||
::Settings::AddSkip(inner);
|
||||
AddHeader(inner, tr::lng_boosts_prepaid_giveaway_title);
|
||||
::Settings::AddSkip(inner);
|
||||
|
@ -340,7 +343,17 @@ void InnerWidget::fill() {
|
|||
rpl::single(g.quantity) | tr::to_count()),
|
||||
tr::lng_boosts_prepaid_giveaway_moths(
|
||||
lt_count,
|
||||
rpl::single(g.months) | tr::to_count())));
|
||||
rpl::single(g.months) | tr::to_count()),
|
||||
Info::Statistics::CreateBadge(
|
||||
st::statisticsDetailsBottomCaptionStyle,
|
||||
QString::number(g.quantity * multiplier),
|
||||
st::boostsListBadgeHeight,
|
||||
st::boostsListBadgeTextPadding,
|
||||
st::premiumButtonBg2,
|
||||
st::premiumButtonFg,
|
||||
1.,
|
||||
st::boostsListMiniIconPadding,
|
||||
st::boostsListMiniIcon)));
|
||||
button->setClickedCallback([=] {
|
||||
_controller->uiShow()->showBox(Box(
|
||||
CreateGiveawayBox,
|
||||
|
|
Loading…
Add table
Reference in a new issue