feat: new badges

This commit is contained in:
AlexeyZavar 2024-11-11 16:37:55 +03:00
parent 96c10be293
commit 38b5cab006
10 changed files with 28 additions and 14 deletions

View file

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 312 B

View file

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 517 B

View file

Before

Width:  |  Height:  |  Size: 754 B

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -30,6 +30,7 @@ inChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgInDateFgSelected }};
outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }};
outChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgOutDateFgSelected }};
infoExteraBadge: icon {{ "ayu/exterabadge", profileVerifiedCheckBg }};
infoExteraOfficialBadge: icon {{ "ayu/extera_official", profileVerifiedCheckBg }};
infoExteraSupporterBadge: icon {{ "ayu/extera_badge", profileVerifiedCheckBg }};
winEnterWithGuestIcon: icon {{ "ayu/ghost_tray", windowFg }};

View file

@ -187,14 +187,19 @@ void Badge::setContent(Content content) {
st::attentionButtonFg);
}, _view->lifetime());
} break;
case BadgeType::AyuGram:
case BadgeType::Extera: {
const auto icon = &st::infoExteraBadge;
_view->resize(icon->size());
case BadgeType::Extera:
case BadgeType::ExteraSupporter: {
const auto icon = (_content.badge == BadgeType::Extera
? &st::infoExteraOfficialBadge
: &st::infoExteraSupporterBadge);
const auto skip = st::infoVerifiedCheckPosition.x();
_view->resize(
icon->width() + skip,
icon->height());
_view->paintRequest(
) | rpl::start_with_next([=, check = _view.data()]{
Painter p(check);
icon->paint(p, 0, 0, check->width());
icon->paint(p, skip, 0, check->width());
}, _view->lifetime());
} break;
}

View file

@ -42,8 +42,8 @@ enum class BadgeType {
Premium = 0x04,
Scam = 0x08,
Fake = 0x10,
AyuGram = 0x20,
Extera = 0x40,
Extera = 0x20,
ExteraSupporter = 0x40,
};
inline constexpr bool is_flag_type(BadgeType) { return true; }

View file

@ -369,7 +369,7 @@ Cover::Cover(
Window::GifPauseReason::Layer);
},
0,
BadgeType::None | BadgeType::AyuGram | BadgeType::Extera))
BadgeType::None | BadgeType::Extera | BadgeType::ExteraSupporter))
, _userpic(topic
? nullptr
: object_ptr<Ui::UserpicButton>(
@ -418,10 +418,10 @@ Cover::Cover(
refreshNameGeometry(width());
}, _name->lifetime());
if (isAyuGramRelated(getBareID(_peer))) {
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::AyuGram});
} else if (isExteraRelated(getBareID(_peer))) {
if (isExteraRelated(getBareID(_peer)) || isAyuGramRelated(getBareID(_peer))) {
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::Extera});
} else if (false) {
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::ExteraSupporter});
} else {
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::None});
}
@ -770,7 +770,12 @@ void Cover::refreshNameGeometry(int newWidth) {
nameWidth -= st::infoVerifiedCheckPosition.x() + widget->width();
}
if (const auto widget = _devBadge->widget()) {
nameWidth -= st::infoVerifiedCheckPosition.x() + widget->width();
nameWidth -= st::infoVerifiedCheckPosition.x()
+ widget->width()
+ (_badge->widget()
? (_badge->widget()->width() +
st::infoVerifiedCheckPosition.x())
: 0);
}
auto nameLeft = _st.nameLeft;
const auto badgeTop = _st.nameTop;
@ -789,7 +794,10 @@ void Cover::refreshNameGeometry(int newWidth) {
const auto badgeLeft = nameLeft + _name->width();
_badge->move(badgeLeft, badgeTop, badgeBottom);
const auto devBadgeLeft = badgeLeft + (_badge->widget() ? (_badge->widget()->width() + 2) : 0) + 4;
const auto devBadgeLeft = badgeLeft
+ (_badge->widget()
? (_badge->widget()->width() + st::infoVerifiedCheckPosition.x())
: 0);
const auto devBadgeTop = _st.nameTop;
const auto devBadgeBottom = _st.nameTop + _name->height();
_devBadge->move(devBadgeLeft, devBadgeTop, devBadgeBottom);