diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp index 34eb034e9e..c5a2d9f429 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp @@ -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)); });