Skip to content

Commit d7639a1

Browse files
committed
Slightly improved style of last seen button in profile top bar.
1 parent 01a140e commit d7639a1

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

Telegram/SourceFiles/info/info.style

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ infoProfileTopBarPhotoTop: 24px;
413413
infoProfileTopBarPhotoBgShift: 55px;
414414
infoProfileTopBarPhotoBgNoActionsShift: 30px;
415415
infoProfileTopBarPhotoSize: 80px;
416-
infoProfileTopBarLastSeenSkip: 8px;
416+
infoProfileTopBarLastSeenSkip: point(8px, 1px);
417417

418418
infoProfileTopBarGiftSize: 20px;
419419

@@ -477,6 +477,20 @@ infoProfileTopBarBoostFooterColored: FlatLabel(infoProfileTopBarBoostFooter) {
477477
}
478478
}
479479

480+
infoProfileTopBarShowLastSeen: RoundButton(defaultActiveButton) {
481+
textFg: windowBoldFg;
482+
textFgOver: windowBoldFg;
483+
textBg: windowBg;
484+
textBgOver: windowBgOver;
485+
width: -12px;
486+
height: 18px;
487+
textTop: 0px;
488+
style: TextStyle(defaultTextStyle) {
489+
font: font(12px);
490+
}
491+
ripple: universalRippleAnimation;
492+
}
493+
480494
infoMinimalWidth: 324px;
481495
infoDesiredWidth: 392px;
482496
infoMinimalLayerMargin: 48px;

Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ TopBar::TopBar(
283283
, _showLastSeen(
284284
this,
285285
tr::lng_status_lastseen_when(),
286-
st::infoProfileCover.showLastSeen)
286+
st::infoProfileTopBarShowLastSeen)
287287
, _forumButton([&, controller = descriptor.controller] {
288288
const auto topic = _key.topic();
289289
if (!topic) {
@@ -465,6 +465,16 @@ void TopBar::adjustColors(const std::optional<QColor> &edgeColor) {
465465
_title->setTextColorOverride(shouldOverrideTitle
466466
? std::optional<QColor>(st::groupCallMembersFg->c)
467467
: std::nullopt);
468+
if (!_showLastSeen->isHidden()) {
469+
if (shouldOverrideTitle) {
470+
const auto st = mapActionStyle(edgeColor);
471+
_showLastSeen->setBrushOverride(st.bgColor);
472+
_showLastSeen->setTextFgOverride(st.fgColor);
473+
} else {
474+
_showLastSeen->setBrushOverride(std::nullopt);
475+
_showLastSeen->setTextFgOverride(std::nullopt);
476+
}
477+
}
468478
{
469479
const auto membersLinkCallback = _statusLabel->membersLinkCallback();
470480
{
@@ -607,27 +617,7 @@ void TopBar::setupActions(not_null<Window::SessionController*> controller) {
607617
const auto topic = _key.topic();
608618
const auto sublist = _key.sublist();
609619
const auto isSide = (_wrap.current() == Wrap::Side);
610-
const auto mapped = [=](std::optional<QColor> c) {
611-
if (c) {
612-
return TopBarActionButtonStyle{
613-
.bgColor = Ui::BlendColors(
614-
*c,
615-
Qt::black,
616-
st::infoProfileTopBarActionButtonBgOpacity),
617-
.fgColor = std::make_optional(st::premiumButtonFg->c),
618-
.shadowColor = std::nullopt,
619-
};
620-
} else {
621-
return TopBarActionButtonStyle{
622-
.bgColor = anim::with_alpha(
623-
st::boxBg->c,
624-
1. - st::infoProfileTopBarActionButtonBgOpacity),
625-
.fgColor = std::nullopt,
626-
.shadowColor = std::make_optional(
627-
st::windowShadowFgFallback->c),
628-
};
629-
}
630-
};
620+
631621
auto buttons = std::vector<not_null<TopBarActionButton*>>();
632622
_actions = base::make_unique_q<Ui::HorizontalFitContainer>(
633623
this,
@@ -663,7 +653,9 @@ void TopBar::setupActions(not_null<Window::SessionController*> controller) {
663653
const auto current = _edgeColor.current();
664654
_edgeColor.force_assign(current);
665655
}, _actions->lifetime());
666-
_edgeColor.value() | rpl::map(mapped) | rpl::start_with_next([=](
656+
_edgeColor.value() | rpl::map([=](std::optional<QColor> c) {
657+
return mapActionStyle(c);
658+
}) | rpl::start_with_next([=](
667659
TopBarActionButtonStyle st) {
668660
for (const auto &button : buttons) {
669661
button->setStyle(st);
@@ -1450,8 +1442,8 @@ void TopBar::updateStatusPosition(float64 progressCurrent) {
14501442
statusLeft
14511443
+ statusShift
14521444
+ _status->textMaxWidth()
1453-
+ st::infoProfileTopBarLastSeenSkip,
1454-
statusTop);
1445+
+ st::infoProfileTopBarLastSeenSkip.x(),
1446+
statusTop + st::infoProfileTopBarLastSeenSkip.y());
14551447
if (_showLastSeenOpacity) {
14561448
_showLastSeenOpacity->setOpacity(progressCurrent);
14571449
}
@@ -2481,4 +2473,26 @@ rpl::producer<QString> TopBar::nameValue() const {
24812473
return Info::Profile::NameValue(_peer);
24822474
}
24832475

2476+
TopBarActionButtonStyle TopBar::mapActionStyle(
2477+
std::optional<QColor> c) const {
2478+
if (c) {
2479+
return TopBarActionButtonStyle{
2480+
.bgColor = Ui::BlendColors(
2481+
*c,
2482+
Qt::black,
2483+
st::infoProfileTopBarActionButtonBgOpacity),
2484+
.fgColor = std::make_optional(st::premiumButtonFg->c),
2485+
.shadowColor = std::nullopt,
2486+
};
2487+
} else {
2488+
return TopBarActionButtonStyle{
2489+
.bgColor = anim::with_alpha(
2490+
st::boxBg->c,
2491+
1. - st::infoProfileTopBarActionButtonBgOpacity),
2492+
.fgColor = std::nullopt,
2493+
.shadowColor = std::make_optional(st::windowShadowFgFallback->c),
2494+
};
2495+
}
2496+
}
2497+
24842498
} // namespace Info::Profile

Telegram/SourceFiles/info/profile/info_profile_top_bar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ namespace Info::Profile {
8282
class Badge;
8383
class StatusLabel;
8484

85+
struct TopBarActionButtonStyle;
86+
8587
class TopBar final : public Ui::RpWidget {
8688
public:
8789
enum class Source {
@@ -188,6 +190,8 @@ class TopBar final : public Ui::RpWidget {
188190
void updateStatusPosition(float64 progressCurrent);
189191
[[nodiscard]] const style::FlatLabel &statusStyle() const;
190192
void setupStatusWithRating();
193+
[[nodiscard]] TopBarActionButtonStyle mapActionStyle(
194+
std::optional<QColor> c) const;
191195

192196
[[nodiscard]] rpl::producer<QString> nameValue() const;
193197

0 commit comments

Comments
 (0)