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