mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added rpl support to label with icon in section of channel earn.
This commit is contained in:
parent
c6e322de86
commit
ae1f364730
1 changed files with 13 additions and 9 deletions
|
@ -315,7 +315,7 @@ void InnerWidget::fill() {
|
||||||
};
|
};
|
||||||
const auto addEmojiToMajor = [=](
|
const auto addEmojiToMajor = [=](
|
||||||
not_null<Ui::FlatLabel*> label,
|
not_null<Ui::FlatLabel*> label,
|
||||||
EarnInt value,
|
rpl::producer<EarnInt> value,
|
||||||
std::optional<bool> isIn,
|
std::optional<bool> isIn,
|
||||||
std::optional<QMargins> margins) {
|
std::optional<QMargins> margins) {
|
||||||
const auto &st = label->st();
|
const auto &st = label->st();
|
||||||
|
@ -330,12 +330,16 @@ void InnerWidget::fill() {
|
||||||
: st::menuIconAttentionColor->c),
|
: st::menuIconAttentionColor->c),
|
||||||
margins ? *margins : st::channelEarnCurrencyCommonMargins,
|
margins ? *margins : st::channelEarnCurrencyCommonMargins,
|
||||||
false));
|
false));
|
||||||
auto prepended = !isIn
|
const auto prepended = !isIn
|
||||||
? TextWithEntities()
|
? TextWithEntities()
|
||||||
: TextWithEntities::Simple((*isIn) ? QChar('+') : kMinus);
|
: TextWithEntities::Simple((*isIn) ? QChar('+') : kMinus);
|
||||||
label->setMarkedText(
|
std::move(
|
||||||
prepended.append(icon).append(MajorPart(value)),
|
value
|
||||||
makeContext(label));
|
) | rpl::start_with_next([=](EarnInt v) {
|
||||||
|
label->setMarkedText(
|
||||||
|
base::duplicate(prepended).append(icon).append(MajorPart(v)),
|
||||||
|
makeContext(label));
|
||||||
|
}, label->lifetime());
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto bigCurrencyIcon = Ui::Text::SingleCustomEmoji(
|
const auto bigCurrencyIcon = Ui::Text::SingleCustomEmoji(
|
||||||
|
@ -589,7 +593,7 @@ void InnerWidget::fill() {
|
||||||
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
st::channelEarnOverviewMajorLabel);
|
st::channelEarnOverviewMajorLabel);
|
||||||
addEmojiToMajor(majorLabel, value, {}, {});
|
addEmojiToMajor(majorLabel, rpl::single(value), {}, {});
|
||||||
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
MinorPart(value),
|
MinorPart(value),
|
||||||
|
@ -704,7 +708,7 @@ void InnerWidget::fill() {
|
||||||
{
|
{
|
||||||
const auto &m = st::channelEarnCurrencyCommonMargins;
|
const auto &m = st::channelEarnCurrencyCommonMargins;
|
||||||
const auto p = QMargins(m.left(), 0, m.right(), m.bottom());
|
const auto p = QMargins(m.left(), 0, m.right(), m.bottom());
|
||||||
addEmojiToMajor(majorLabel, value, {}, p);
|
addEmojiToMajor(majorLabel, rpl::single(value), {}, p);
|
||||||
}
|
}
|
||||||
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
@ -855,7 +859,7 @@ void InnerWidget::fill() {
|
||||||
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
wrap,
|
wrap,
|
||||||
st::channelEarnHistoryMajorLabel);
|
st::channelEarnHistoryMajorLabel);
|
||||||
addEmojiToMajor(majorLabel, entry.amount, isIn, {});
|
addEmojiToMajor(majorLabel, rpl::single(entry.amount), isIn, {});
|
||||||
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
majorLabel->setTextColorOverride(color);
|
majorLabel->setTextColorOverride(color);
|
||||||
const auto minorText = MinorPart(entry.amount);
|
const auto minorText = MinorPart(entry.amount);
|
||||||
|
@ -885,7 +889,7 @@ void InnerWidget::fill() {
|
||||||
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
labels,
|
labels,
|
||||||
st::channelEarnOverviewMajorLabel);
|
st::channelEarnOverviewMajorLabel);
|
||||||
addEmojiToMajor(majorLabel, amount, isIn, {});
|
addEmojiToMajor(majorLabel, rpl::single(amount), isIn, {});
|
||||||
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
majorLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
majorLabel->setTextColorOverride(color);
|
majorLabel->setTextColorOverride(color);
|
||||||
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
|
Loading…
Add table
Reference in a new issue