mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added mini stars to subscriptions with details in ReceiptCreditsBox.
This commit is contained in:
parent
213274e96c
commit
73936dca73
1 changed files with 38 additions and 44 deletions
|
@ -346,6 +346,37 @@ void AddViewMediaHandler(
|
||||||
}, thumb->lifetime());
|
}, thumb->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddMiniStars(
|
||||||
|
not_null<Ui::VerticalLayout*> content,
|
||||||
|
not_null<Ui::RpWidget*> widget,
|
||||||
|
const style::UserpicButton &stUser,
|
||||||
|
int boxWidth,
|
||||||
|
float64 heightRatio) {
|
||||||
|
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
||||||
|
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
||||||
|
widget,
|
||||||
|
false,
|
||||||
|
Ui::Premium::MiniStars::Type::BiStars);
|
||||||
|
stars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
||||||
|
widget->resize(
|
||||||
|
boxWidth - stUser.photoSize,
|
||||||
|
stUser.photoSize * heightRatio);
|
||||||
|
content->sizeValue(
|
||||||
|
) | rpl::start_with_next([=](const QSize &size) {
|
||||||
|
widget->moveToLeft(stUser.photoSize / 2, 0);
|
||||||
|
const auto starsRect = Rect(widget->size());
|
||||||
|
stars->setPosition(starsRect.topLeft());
|
||||||
|
stars->setSize(starsRect.size());
|
||||||
|
widget->lower();
|
||||||
|
}, widget->lifetime());
|
||||||
|
widget->paintRequest(
|
||||||
|
) | rpl::start_with_next([=](const QRect &r) {
|
||||||
|
auto p = QPainter(widget);
|
||||||
|
p.fillRect(r, Qt::transparent);
|
||||||
|
stars->paint(p);
|
||||||
|
}, widget->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SubscriptionRightLabel PaintSubscriptionRightLabelCallback(
|
SubscriptionRightLabel PaintSubscriptionRightLabelCallback(
|
||||||
|
@ -664,31 +695,12 @@ void BoostCreditsBox(
|
||||||
{
|
{
|
||||||
const auto &stUser = st::premiumGiftsUserpicButton;
|
const auto &stUser = st::premiumGiftsUserpicButton;
|
||||||
const auto widget = content->add(object_ptr<Ui::RpWidget>(content));
|
const auto widget = content->add(object_ptr<Ui::RpWidget>(content));
|
||||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
AddMiniStars(content, widget, stUser, st::boxWidth, 1.3);
|
||||||
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
|
||||||
widget,
|
|
||||||
false,
|
|
||||||
Ui::Premium::MiniStars::Type::BiStars);
|
|
||||||
stars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
|
||||||
widget->resize(
|
|
||||||
st::boxWidth - stUser.photoSize,
|
|
||||||
stUser.photoSize * 1.3);
|
|
||||||
const auto svg = std::make_shared<QSvgRenderer>(
|
const auto svg = std::make_shared<QSvgRenderer>(
|
||||||
Ui::Premium::ColorizedSvg(
|
Ui::Premium::ColorizedSvg(
|
||||||
Ui::Premium::CreditsIconGradientStops()));
|
Ui::Premium::CreditsIconGradientStops()));
|
||||||
content->sizeValue(
|
widget->paintRequest() | rpl::start_with_next([=](const QRect &r) {
|
||||||
) | rpl::start_with_next([=](const QSize &size) {
|
|
||||||
widget->moveToLeft(stUser.photoSize / 2, 0);
|
|
||||||
const auto starsRect = Rect(widget->size());
|
|
||||||
stars->setPosition(starsRect.topLeft());
|
|
||||||
stars->setSize(starsRect.size());
|
|
||||||
widget->lower();
|
|
||||||
}, widget->lifetime());
|
|
||||||
widget->paintRequest(
|
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
|
||||||
auto p = QPainter(widget);
|
auto p = QPainter(widget);
|
||||||
p.fillRect(r, Qt::transparent);
|
|
||||||
stars->paint(p);
|
|
||||||
svg->render(
|
svg->render(
|
||||||
&p,
|
&p,
|
||||||
QRectF(
|
QRectF(
|
||||||
|
@ -853,6 +865,10 @@ void ReceiptCreditsBox(
|
||||||
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())) {
|
} else if (s.photoId || (e.photoId && !e.subscriptionUntil.isNull())) {
|
||||||
|
if (!(s.cancelled || s.expired || s.cancelledByBot)) {
|
||||||
|
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||||
|
AddMiniStars(content, widget, stUser, st::boxWideWidth, 1.5);
|
||||||
|
}
|
||||||
const auto photoId = s.photoId ? s.photoId : e.photoId;
|
const auto photoId = s.photoId ? s.photoId : e.photoId;
|
||||||
const auto callback = [=](Fn<void()> update) {
|
const auto callback = [=](Fn<void()> update) {
|
||||||
return Ui::GenerateCreditsPaintEntryCallback(
|
return Ui::GenerateCreditsPaintEntryCallback(
|
||||||
|
@ -1337,29 +1353,7 @@ void ReceiptCreditsBox(
|
||||||
|
|
||||||
if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) {
|
if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) {
|
||||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
AddMiniStars(content, widget, stUser, st::boxWideWidth, 2);
|
||||||
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
|
||||||
widget,
|
|
||||||
false,
|
|
||||||
Ui::Premium::MiniStars::Type::BiStars);
|
|
||||||
stars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
|
||||||
widget->resize(
|
|
||||||
st::boxWideWidth - stUser.photoSize,
|
|
||||||
stUser.photoSize * 2);
|
|
||||||
content->sizeValue(
|
|
||||||
) | rpl::start_with_next([=](const QSize &size) {
|
|
||||||
widget->moveToLeft(stUser.photoSize / 2, 0);
|
|
||||||
const auto starsRect = Rect(widget->size());
|
|
||||||
stars->setPosition(starsRect.topLeft());
|
|
||||||
stars->setSize(starsRect.size());
|
|
||||||
widget->lower();
|
|
||||||
}, widget->lifetime());
|
|
||||||
widget->paintRequest(
|
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
|
||||||
auto p = QPainter(widget);
|
|
||||||
p.fillRect(r, Qt::transparent);
|
|
||||||
stars->paint(p);
|
|
||||||
}, widget->lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto toRenew = (s.cancelled || s.expired)
|
const auto toRenew = (s.cancelled || s.expired)
|
||||||
|
|
Loading…
Add table
Reference in a new issue