mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved style of box for credits history entries for refunded entry.
This commit is contained in:
parent
cd7507fb23
commit
58c060c59d
1 changed files with 54 additions and 19 deletions
|
@ -437,23 +437,38 @@ void ReceiptCreditsBox(
|
||||||
auto &lifetime = content->lifetime();
|
auto &lifetime = content->lifetime();
|
||||||
const auto text = lifetime.make_state<Ui::Text::String>(
|
const auto text = lifetime.make_state<Ui::Text::String>(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
(!e.bareId ? QChar('+') : kMinus)
|
((!e.bareId || e.refunded) ? QChar('+') : kMinus)
|
||||||
+ Lang::FormatCountDecimal(std::abs(int64(e.credits))));
|
+ Lang::FormatCountDecimal(std::abs(int64(e.credits))));
|
||||||
|
const auto refundedText = tr::lng_channel_earn_history_return(
|
||||||
|
tr::now);
|
||||||
|
const auto refunded = e.refunded
|
||||||
|
? lifetime.make_state<Ui::Text::String>(
|
||||||
|
st::defaultTextStyle,
|
||||||
|
refundedText)
|
||||||
|
: (Ui::Text::String*)(nullptr);
|
||||||
|
|
||||||
const auto amount = content->add(
|
const auto amount = content->add(
|
||||||
object_ptr<Ui::FixedHeightWidget>(
|
object_ptr<Ui::FixedHeightWidget>(
|
||||||
content,
|
content,
|
||||||
star.height() / style::DevicePixelRatio()));
|
star.height() / style::DevicePixelRatio()));
|
||||||
const auto font = text->style()->font;
|
const auto font = text->style()->font;
|
||||||
|
const auto refundedFont = st::defaultTextStyle.font;
|
||||||
|
const auto starWidth = star.width()
|
||||||
|
/ style::DevicePixelRatio();
|
||||||
|
const auto refundedSkip = refundedFont->spacew * 2;
|
||||||
|
const auto refundedWidth = refunded
|
||||||
|
? refundedFont->width(refundedText)
|
||||||
|
+ refundedSkip
|
||||||
|
+ refundedFont->height
|
||||||
|
: 0;
|
||||||
|
const auto fullWidth = text->maxWidth()
|
||||||
|
+ font->spacew * 1
|
||||||
|
+ starWidth
|
||||||
|
+ refundedWidth;
|
||||||
amount->paintRequest(
|
amount->paintRequest(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
auto p = Painter(amount);
|
auto p = Painter(amount);
|
||||||
const auto starWidth = star.width()
|
p.setPen((!e.bareId || e.refunded)
|
||||||
/ style::DevicePixelRatio();
|
|
||||||
const auto fullWidth = text->maxWidth()
|
|
||||||
+ font->spacew * 2
|
|
||||||
+ starWidth;
|
|
||||||
p.setPen(!e.bareId
|
|
||||||
? st::boxTextFgGood
|
? st::boxTextFgGood
|
||||||
: st::menuIconAttentionColor);
|
: st::menuIconAttentionColor);
|
||||||
const auto x = (amount->width() - fullWidth) / 2;
|
const auto x = (amount->width() - fullWidth) / 2;
|
||||||
|
@ -463,11 +478,41 @@ void ReceiptCreditsBox(
|
||||||
(amount->height() - font->height) / 2),
|
(amount->height() - font->height) / 2),
|
||||||
.outerWidth = amount->width(),
|
.outerWidth = amount->width(),
|
||||||
.availableWidth = amount->width(),
|
.availableWidth = amount->width(),
|
||||||
});;
|
});
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
x + fullWidth - starWidth,
|
x + fullWidth - starWidth - refundedWidth,
|
||||||
0,
|
0,
|
||||||
star);
|
star);
|
||||||
|
|
||||||
|
if (refunded) {
|
||||||
|
const auto refundedLeft = fullWidth
|
||||||
|
+ x
|
||||||
|
- refundedWidth
|
||||||
|
+ refundedSkip;
|
||||||
|
const auto pen = p.pen();
|
||||||
|
auto color = pen.color();
|
||||||
|
color.setAlphaF(color.alphaF() * 0.15);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.setBrush(color);
|
||||||
|
{
|
||||||
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
|
p.drawRoundedRect(
|
||||||
|
refundedLeft,
|
||||||
|
(amount->height() - refundedFont->height) / 2,
|
||||||
|
refundedWidth - refundedSkip,
|
||||||
|
refundedFont->height,
|
||||||
|
refundedFont->height / 2,
|
||||||
|
refundedFont->height / 2);
|
||||||
|
}
|
||||||
|
p.setPen(pen);
|
||||||
|
refunded->draw(p, Ui::Text::PaintContext{
|
||||||
|
.position = QPoint(
|
||||||
|
refundedLeft + refundedFont->height / 2,
|
||||||
|
(amount->height() - refundedFont->height) / 2),
|
||||||
|
.outerWidth = refundedWidth,
|
||||||
|
.availableWidth = refundedWidth,
|
||||||
|
});
|
||||||
|
}
|
||||||
}, amount->lifetime());
|
}, amount->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,16 +526,6 @@ void ReceiptCreditsBox(
|
||||||
st::defaultFlatLabel)));
|
st::defaultFlatLabel)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.refunded) {
|
|
||||||
Ui::AddSkip(content);
|
|
||||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
|
||||||
box,
|
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
tr::lng_channel_earn_history_return_about(),
|
|
||||||
st::defaultFlatLabel)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue