mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Moved out to single place ministars creation in top of box.
This commit is contained in:
parent
c3f354826d
commit
2532a0ff59
5 changed files with 35 additions and 89 deletions
|
@ -207,32 +207,12 @@ void ConfirmSubscriptionBox(
|
|||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
{
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||
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(
|
||||
st::boxWideWidth - photoSize,
|
||||
photoSize * 2);
|
||||
content->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
widget->moveToLeft(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());
|
||||
}
|
||||
Settings::AddMiniStars(
|
||||
content,
|
||||
Ui::CreateChild<Ui::RpWidget>(content),
|
||||
photoSize,
|
||||
box->width(),
|
||||
2.);
|
||||
|
||||
box->addRow(
|
||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||
|
|
|
@ -47,6 +47,7 @@ void GiftCreditsBox(
|
|||
const auto content = box->setPinnedToTopContent(
|
||||
object_ptr<Ui::VerticalLayout>(box));
|
||||
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
const auto &stUser = st::premiumGiftsUserpicButton;
|
||||
|
@ -58,32 +59,12 @@ void GiftCreditsBox(
|
|||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
{
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||
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(
|
||||
st::boxWidth - 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());
|
||||
}
|
||||
Settings::AddMiniStars(
|
||||
content,
|
||||
Ui::CreateChild<Ui::RpWidget>(content),
|
||||
stUser.photoSize,
|
||||
box->width(),
|
||||
2.);
|
||||
{
|
||||
Ui::AddSkip(content);
|
||||
const auto arrow = Ui::Text::SingleCustomEmoji(
|
||||
|
|
|
@ -1325,32 +1325,12 @@ void GiftBox(
|
|||
AddSkip(content);
|
||||
AddSkip(content);
|
||||
|
||||
{
|
||||
const auto widget = CreateChild<RpWidget>(content);
|
||||
using ColoredMiniStars = Premium::ColoredMiniStars;
|
||||
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
||||
widget,
|
||||
false,
|
||||
Premium::MiniStars::Type::BiStars);
|
||||
stars->setColorOverride(Premium::CreditsIconGradientStops());
|
||||
widget->resize(
|
||||
st::boxWidth - stUser.photoSize,
|
||||
stUser.photoSize * 2);
|
||||
content->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
widget->moveToLeft((size.width() - widget->width()) / 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());
|
||||
}
|
||||
Settings::AddMiniStars(
|
||||
content,
|
||||
Ui::CreateChild<Ui::RpWidget>(content),
|
||||
stUser.photoSize,
|
||||
box->width(),
|
||||
2.);
|
||||
AddSkip(content);
|
||||
AddSkip(box->verticalLayout());
|
||||
|
||||
|
|
|
@ -348,10 +348,12 @@ void AddViewMediaHandler(
|
|||
}, thumb->lifetime());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AddMiniStars(
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
const style::UserpicButton &stUser,
|
||||
int photoSize,
|
||||
int boxWidth,
|
||||
float64 heightRatio) {
|
||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
||||
|
@ -360,12 +362,10 @@ void AddMiniStars(
|
|||
false,
|
||||
Ui::Premium::MiniStars::Type::BiStars);
|
||||
stars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
||||
widget->resize(
|
||||
boxWidth - stUser.photoSize,
|
||||
stUser.photoSize * heightRatio);
|
||||
widget->resize(boxWidth - photoSize, photoSize * heightRatio);
|
||||
content->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
widget->moveToLeft(stUser.photoSize / 2, 0);
|
||||
widget->moveToLeft(photoSize / 2, 0);
|
||||
const auto starsRect = Rect(widget->size());
|
||||
stars->setPosition(starsRect.topLeft());
|
||||
stars->setSize(starsRect.size());
|
||||
|
@ -379,8 +379,6 @@ void AddMiniStars(
|
|||
}, widget->lifetime());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SubscriptionRightLabel PaintSubscriptionRightLabelCallback(
|
||||
not_null<Main::Session*> session,
|
||||
const style::PeerListItem &st,
|
||||
|
@ -699,7 +697,7 @@ void BoostCreditsBox(
|
|||
{
|
||||
const auto &stUser = st::premiumGiftsUserpicButton;
|
||||
const auto widget = content->add(object_ptr<Ui::RpWidget>(content));
|
||||
AddMiniStars(content, widget, stUser, st::boxWidth, 1.3);
|
||||
AddMiniStars(content, widget, stUser.photoSize, st::boxWidth, 1.3);
|
||||
const auto svg = std::make_shared<QSvgRenderer>(
|
||||
Ui::Premium::ColorizedSvg(
|
||||
Ui::Premium::CreditsIconGradientStops()));
|
||||
|
@ -893,7 +891,8 @@ void ReceiptCreditsBox(
|
|||
} 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 photoSize = stUser.photoSize;
|
||||
AddMiniStars(content, widget, photoSize, st::boxWideWidth, 1.5);
|
||||
}
|
||||
const auto photoId = s.photoId ? s.photoId : e.photoId;
|
||||
const auto callback = [=](Fn<void()> update) {
|
||||
|
@ -1427,7 +1426,7 @@ void ReceiptCreditsBox(
|
|||
|
||||
if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) {
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||
AddMiniStars(content, widget, stUser, st::boxWideWidth, 2);
|
||||
AddMiniStars(content, widget, stUser.photoSize, st::boxWideWidth, 2);
|
||||
}
|
||||
|
||||
const auto rejoinByApi = base::unixtime::serialize(s.until)
|
||||
|
|
|
@ -179,5 +179,11 @@ void MaybeRequestBalanceIncrease(
|
|||
SmallBalanceSource source,
|
||||
Fn<void(SmallBalanceResult)> done);
|
||||
|
||||
} // namespace Settings
|
||||
void AddMiniStars(
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
int photoSize,
|
||||
int boxWidth,
|
||||
float64 heightRatio);
|
||||
|
||||
} // namespace Settings
|
||||
|
|
Loading…
Add table
Reference in a new issue