mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Improve resale unique gift display.
This commit is contained in:
parent
e629460942
commit
284f7fc4f7
4 changed files with 34 additions and 14 deletions
|
@ -856,6 +856,7 @@ std::optional<Data::StarGift> FromTL(
|
||||||
.model = *model,
|
.model = *model,
|
||||||
.pattern = *pattern,
|
.pattern = *pattern,
|
||||||
}),
|
}),
|
||||||
|
.starsResellMin = int64(data.vresell_stars().value_or_empty()),
|
||||||
.document = model->document,
|
.document = model->document,
|
||||||
.limitedLeft = (total - data.vavailability_issued().v),
|
.limitedLeft = (total - data.vavailability_issued().v),
|
||||||
.limitedCount = total,
|
.limitedCount = total,
|
||||||
|
|
|
@ -3005,10 +3005,18 @@ void GiftResaleBox(
|
||||||
ResaleGiftsDescriptor data;
|
ResaleGiftsDescriptor data;
|
||||||
rpl::variable<ResaleFilter> filter;
|
rpl::variable<ResaleFilter> filter;
|
||||||
rpl::lifetime loading;
|
rpl::lifetime loading;
|
||||||
|
int lastMinHeight = 0;
|
||||||
};
|
};
|
||||||
const auto state = content->lifetime().make_state<State>();
|
const auto state = content->lifetime().make_state<State>();
|
||||||
state->data = std::move(descriptor);
|
state->data = std::move(descriptor);
|
||||||
|
|
||||||
|
box->heightValue() | rpl::start_with_next([=](int height) {
|
||||||
|
if (height > state->lastMinHeight) {
|
||||||
|
state->lastMinHeight = height;
|
||||||
|
box->setMinHeight(height);
|
||||||
|
}
|
||||||
|
}, content->lifetime());
|
||||||
|
|
||||||
auto tabs = MakeResaleTabs(
|
auto tabs = MakeResaleTabs(
|
||||||
window,
|
window,
|
||||||
peer,
|
peer,
|
||||||
|
@ -3041,7 +3049,10 @@ void GiftResaleBox(
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
auto result = GiftsDescriptor();
|
auto result = GiftsDescriptor();
|
||||||
for (const auto &gift : state->data.list) {
|
for (const auto &gift : state->data.list) {
|
||||||
result.list.push_back(GiftTypeStars{ .info = gift });
|
result.list.push_back(GiftTypeStars{
|
||||||
|
.info = gift,
|
||||||
|
.resale = true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}), [=] {
|
}), [=] {
|
||||||
|
|
|
@ -142,9 +142,11 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor, Mode mode) {
|
||||||
_price.setMarkedText(
|
_price.setMarkedText(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
(data.resale
|
(data.resale
|
||||||
? _delegate->star().append(' ').append(
|
? (unique
|
||||||
Lang::FormatCountDecimal(data.info.starsResellMin)
|
? _delegate->monostar()
|
||||||
).append(data.info.resellCount > 0 ? "+" : "")
|
: _delegate->star()).append(' ').append(
|
||||||
|
Lang::FormatCountDecimal(data.info.starsResellMin)
|
||||||
|
).append(data.info.resellCount > 1 ? "+" : "")
|
||||||
: unique
|
: unique
|
||||||
? tr::lng_gift_transfer_button(
|
? tr::lng_gift_transfer_button(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
@ -156,15 +158,15 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor, Mode mode) {
|
||||||
if (!_stars) {
|
if (!_stars) {
|
||||||
_stars.emplace(this, true, starsType);
|
_stars.emplace(this, true, starsType);
|
||||||
}
|
}
|
||||||
if (data.resale) {
|
if (unique) {
|
||||||
_stars->setColorOverride(
|
|
||||||
Ui::Premium::CreditsIconGradientStops());
|
|
||||||
} else if (unique) {
|
|
||||||
const auto white = QColor(255, 255, 255);
|
const auto white = QColor(255, 255, 255);
|
||||||
_stars->setColorOverride(QGradientStops{
|
_stars->setColorOverride(QGradientStops{
|
||||||
{ 0., anim::with_alpha(white, .3) },
|
{ 0., anim::with_alpha(white, .3) },
|
||||||
{ 1., white },
|
{ 1., white },
|
||||||
});
|
});
|
||||||
|
} else if (data.resale) {
|
||||||
|
_stars->setColorOverride(
|
||||||
|
Ui::Premium::CreditsIconGradientStops());
|
||||||
} else if (soldOut) {
|
} else if (soldOut) {
|
||||||
_stars.reset();
|
_stars.reset();
|
||||||
} else {
|
} else {
|
||||||
|
@ -498,10 +500,10 @@ void GiftButton::paintEvent(QPaintEvent *e) {
|
||||||
&& !data.userpic
|
&& !data.userpic
|
||||||
&& !data.info.limitedLeft;
|
&& !data.info.limitedLeft;
|
||||||
return GiftBadge{
|
return GiftBadge{
|
||||||
.text = (data.resale
|
.text = ((unique && (data.resale || pinned))
|
||||||
? tr::lng_gift_stars_resale(tr::now)
|
|
||||||
: (unique && pinned)
|
|
||||||
? ('#' + QString::number(unique->number))
|
? ('#' + QString::number(unique->number))
|
||||||
|
: data.resale
|
||||||
|
? tr::lng_gift_stars_resale(tr::now)
|
||||||
: soldOut
|
: soldOut
|
||||||
? tr::lng_gift_stars_sold_out(tr::now)
|
? tr::lng_gift_stars_sold_out(tr::now)
|
||||||
: (!data.userpic && !data.info.unique)
|
: (!data.userpic && !data.info.unique)
|
||||||
|
@ -514,10 +516,10 @@ void GiftButton::paintEvent(QPaintEvent *e) {
|
||||||
(((count % 1000) && (count < 10'000))
|
(((count % 1000) && (count < 10'000))
|
||||||
? Lang::FormatCountDecimal(count)
|
? Lang::FormatCountDecimal(count)
|
||||||
: Lang::FormatCountToShort(count).string))),
|
: Lang::FormatCountToShort(count).string))),
|
||||||
.bg1 = (data.resale
|
.bg1 = (unique
|
||||||
? st::boxTextFgGood->c
|
|
||||||
: unique
|
|
||||||
? unique->backdrop.edgeColor
|
? unique->backdrop.edgeColor
|
||||||
|
: data.resale
|
||||||
|
? st::boxTextFgGood->c
|
||||||
: soldOut
|
: soldOut
|
||||||
? st::attentionButtonFg->c
|
? st::attentionButtonFg->c
|
||||||
: st::windowActiveTextFg->c),
|
: st::windowActiveTextFg->c),
|
||||||
|
@ -645,6 +647,10 @@ TextWithEntities Delegate::star() {
|
||||||
return _session->data().customEmojiManager().creditsEmoji();
|
return _session->data().customEmojiManager().creditsEmoji();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextWithEntities Delegate::monostar() {
|
||||||
|
return Ui::Text::IconEmoji(&st::starIconEmoji);
|
||||||
|
}
|
||||||
|
|
||||||
TextWithEntities Delegate::ministar() {
|
TextWithEntities Delegate::ministar() {
|
||||||
const auto owner = &_session->data();
|
const auto owner = &_session->data();
|
||||||
const auto top = st::giftBoxByStarsStarTop;
|
const auto top = st::giftBoxByStarsStarTop;
|
||||||
|
|
|
@ -113,6 +113,7 @@ enum class GiftButtonMode {
|
||||||
class GiftButtonDelegate {
|
class GiftButtonDelegate {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] virtual TextWithEntities star() = 0;
|
[[nodiscard]] virtual TextWithEntities star() = 0;
|
||||||
|
[[nodiscard]] virtual TextWithEntities monostar() = 0;
|
||||||
[[nodiscard]] virtual TextWithEntities ministar() = 0;
|
[[nodiscard]] virtual TextWithEntities ministar() = 0;
|
||||||
[[nodiscard]] virtual Ui::Text::MarkedContext textContext() = 0;
|
[[nodiscard]] virtual Ui::Text::MarkedContext textContext() = 0;
|
||||||
[[nodiscard]] virtual QSize buttonSize() = 0;
|
[[nodiscard]] virtual QSize buttonSize() = 0;
|
||||||
|
@ -193,6 +194,7 @@ public:
|
||||||
~Delegate();
|
~Delegate();
|
||||||
|
|
||||||
TextWithEntities star() override;
|
TextWithEntities star() override;
|
||||||
|
TextWithEntities monostar() override;
|
||||||
TextWithEntities ministar() override;
|
TextWithEntities ministar() override;
|
||||||
Ui::Text::MarkedContext textContext() override;
|
Ui::Text::MarkedContext textContext() override;
|
||||||
QSize buttonSize() override;
|
QSize buttonSize() override;
|
||||||
|
|
Loading…
Add table
Reference in a new issue