Added new badge to entry point for edit peer color box.

This commit is contained in:
23rd
2025-10-31 15:04:17 +03:00
parent 80dce3b65a
commit 4a8bb75851
@@ -56,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/path_shift_gradient.h"
#include "ui/effects/premium_graphics.h"
#include "ui/layers/generic_box.h"
#include "ui/new_badges.h"
#include "ui/peer/color_sample.h"
#include "ui/text/text_utilities.h"
#include "ui/widgets/buttons.h"
@@ -2666,6 +2667,32 @@ void AddPeerColorButton(
SetupPeerColorSample(button, peer, rpl::duplicate(label), style);
}
{
const auto badge = Ui::NewBadge::CreateNewBadge(
button,
tr::lng_premium_summary_new_badge()).get();
rpl::combine(
rpl::duplicate(label),
button->widthValue()
) | rpl::start_with_next([=](
const QString &text,
int width) {
const auto space = st.style.font->spacew;
const auto left = st.padding.left()
+ st.style.font->width(text)
+ space;
const auto available = width - left - st.padding.right();
badge->setVisible(available >= badge->width());
if (!badge->isHidden()) {
const auto top = st.padding.top()
+ st.style.font->ascent
- st::settingsPremiumNewBadge.style.font->ascent
- st::settingsPremiumNewBadgePadding.top();
badge->moveToLeft(left, top, width);
}
}, badge->lifetime());
}
button->setClickedCallback([=] {
show->show(Box(EditPeerColorBox, show, peer, style, theme));
});