feat: add mutual contact indicator to contacts list

This commit is contained in:
Ireina
2026-04-02 18:28:01 +08:00
committed by AlexeyZavar
parent 2c16e4b897
commit 10bb323eb5
5 changed files with 55 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

@@ -18,6 +18,8 @@ ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }};
ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }};
ayuToBeginningMenuIcon: icon {{ "ayu/to_beginning", menuIconColor }};
ayuRepeatMenuIcon: icon {{ "ayu/repeat", menuIconColor }};
ayuContactsMutualIcon: icon {{ "ayu/contacts_mutual", contactsStatusFg }};
ayuContactsMutualIconOver: icon {{ "ayu/contacts_mutual", contactsStatusFgOver }};
messageFieldAttachIcon: icon {{ "ayu/message_field/attach", menuIconColor }};
messageFieldCommandsIcon: icon {{ "ayu/message_field/commands", menuIconColor }};
@@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" // showAddContact()
#include "base/unixtime.h"
#include "styles/style_boxes.h"
#include "styles/style_ayu_icons.h"
#include "styles/style_profile.h"
#include "styles/style_dialogs.h"
#include "styles/style_chat_helpers.h"
@@ -61,6 +62,57 @@ namespace {
constexpr auto kSortByOnlineThrottle = 3 * crl::time(1000);
constexpr auto kSearchPerPage = 50;
class ContactsMutualRow final : public PeerListRow {
public:
using PeerListRow::PeerListRow;
protected:
QSize rightActionSize() const override {
return isMutualContact()
? QSize(st::ayuContactsMutualIcon.width(), st::ayuContactsMutualIcon.height())
: QSize();
}
QMargins rightActionMargins() const override {
const auto size = rightActionSize();
if (size.isEmpty()) {
return QMargins();
}
const auto right = st::contactsWithStories.item.photoPosition.x();
return QMargins(
right,
(st::contactsWithStories.item.height - size.height()) / 2,
right,
0);
}
bool rightActionDisabled() const override {
return true;
}
void rightActionPaint(
Painter &p,
int x,
int y,
int outerWidth,
bool selected,
bool actionSelected) override {
if (!isMutualContact()) {
return;
}
(selected
? st::ayuContactsMutualIconOver
: st::ayuContactsMutualIcon).paint(p, x, y, outerWidth);
}
private:
[[nodiscard]] bool isMutualContact() const {
const auto user = peer()->asUser();
return user && (user->flags() & UserDataFlag::MutualContact);
}
};
} // namespace
object_ptr<Ui::BoxContent> PrepareContactsBox(
@@ -78,7 +130,7 @@ object_ptr<Ui::BoxContent> PrepareContactsBox(
std::unique_ptr<PeerListRow> createRow(
not_null<UserData*> user) override {
return !user->isSelf()
? ContactsBoxController::createRow(user)
? std::make_unique<ContactsMutualRow>(user)
: nullptr;
}