diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 3ce00a4aa0..89e52b633a 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -454,6 +454,10 @@ infoProfileTopBarActionReport: icon{{ "profile/report-22x22", windowBoldFg }}; infoProfileTopBarActionLeave: icon{{ "profile/leave-22x22", windowBoldFg }}; infoProfileTopBarActionMore: icon{{ "profile/profile_more", windowBoldFg }}; +infoProfileTopBarTopicStatusButton: RoundButton(defaultTableSmallButton) { + radius: 4px; +} + infoProfileTopBarBoostFooter: FlatLabel(defaultFlatLabel) { textFg: windowSubTextFg; style: TextStyle(defaultTextStyle) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index abaa804e61..e995e4263d 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document_media.h" #include "data/data_document.h" #include "data/data_emoji_statuses.h" +#include "data/data_forum.h" #include "data/data_forum_topic.h" #include "data/data_peer_values.h" #include "data/data_peer.h" @@ -247,7 +248,7 @@ TopBar::TopBar( ? 0 : st::infoProfileTopBarActionButtonsHeight); }()) -, _title(this, Info::Profile::NameValue(_peer), _st.title) +, _title(this, nameValue(), _st.title) , _starsRating(_peer->isUser() ? std::make_unique( this, @@ -261,9 +262,41 @@ TopBar::TopBar( , _status(this, QString(), statusStyle()) , _statusLabel(std::make_unique(_status.data(), _peer)) , _showLastSeen( + this, + tr::lng_status_lastseen_when(), + st::infoProfileCover.showLastSeen) +, _forumButton([&, controller = descriptor.controller] { + const auto topic = _key.topic(); + if (!topic) { + return object_ptr{ nullptr }; + } + auto owned = object_ptr( this, - tr::lng_status_lastseen_when(), - st::infoProfileCover.showLastSeen) { + rpl::single(QString()), + st::infoProfileTopBarTopicStatusButton); + owned->setText(Info::Profile::NameValue( + _peer + ) | rpl::map([=](const QString &name) { + return TextWithEntities(name) + .append(' ') + .append(Ui::Text::IconEmoji(&st::textMoreIconEmoji, QString())); + })); + owned->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); + owned->setClickedCallback([=, peer = _peer] { + if (const auto forum = peer->forum()) { + if (peer->useSubsectionTabs()) { + controller->searchInChat(forum->history()); + } else if (controller->adaptive().isOneColumn()) { + controller->showForum(forum); + } else { + controller->showPeerHistory(peer->id); + } + } else { + controller->showPeerHistory(peer->id); + } + }); + return owned; +}()) { const auto controller = descriptor.controller; if (_peer->isMegagroup() || _peer->isChat()) { @@ -279,11 +312,13 @@ TopBar::TopBar( : std::make_shared(shown, section)); }); } - if (!_peer->isMegagroup()) { + if (!_peer->isMegagroup() && !_topic) { setupStatusWithRating(); } - setupShowLastSeen(controller); + if (!_topic) { + setupShowLastSeen(controller); + } _peer->session().changes().peerFlagsValue( _peer, @@ -317,7 +352,7 @@ TopBar::TopBar( } badgeUpdates = rpl::merge( std::move(badgeUpdates), - Info::Profile::NameValue(_peer) | rpl::map([=](const QString &name) { + nameValue() | rpl::map([=](const QString &name) { _title->resizeToWidth(_title->st().style.font->width(name)); return rpl::empty_value(); }), @@ -389,6 +424,10 @@ TopBar::TopBar( ) | rpl::take(1) | rpl::start_with_next([=] { setupPinnedToTopGifts(controller); }, lifetime()); + + if (_forumButton) { + _forumButton->show(); + } } void TopBar::adjustColors(const std::optional &edgeColor) { @@ -421,7 +460,7 @@ void TopBar::adjustColors(const std::optional &edgeColor) { _status.create(this, QString(), statusStyle()); } _status->show(); - if (!_peer->isMegagroup()) { + if (!_peer->isMegagroup() && !_topic) { setupStatusWithRating(); } _status->widthValue() | rpl::start_with_next([=] { @@ -1165,6 +1204,24 @@ void TopBar::updateLabelsPosition() { } void TopBar::updateStatusPosition(float64 progressCurrent) { + if (_forumButton) { + const auto buttonTop = anim::interpolate( + _st.subtitlePosition.y(), + st::infoProfileTopBarStatusTop, + progressCurrent); + const auto buttonLeft = anim::interpolate( + statusMostLeft(), + (width() - _forumButton->width()) / 2, + progressCurrent); + _forumButton->moveToLeft(buttonLeft, buttonTop); + _forumButton->setVisible(true); + + _status->hide(); + // _starsRating->hide(); + _showLastSeen->hide(); + return; + } + const auto statusTop = anim::interpolate( _st.subtitlePosition.y(), st::infoProfileTopBarStatusTop, @@ -2215,4 +2272,11 @@ const style::FlatLabel &TopBar::statusStyle() const { : st::infoProfileCover.status; } +rpl::producer TopBar::nameValue() const { + if (const auto topic = _key.topic()) { + return Info::Profile::TitleValue(topic); + } + return Info::Profile::NameValue(_peer); +} + } // namespace Info::Profile diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h index 8fd2c3539d..ec2ef6765c 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.h +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.h @@ -189,6 +189,8 @@ private: [[nodiscard]] const style::FlatLabel &statusStyle() const; void setupStatusWithRating(); + [[nodiscard]] rpl::producer nameValue() const; + [[nodiscard]] auto effectiveColorProfile() const -> std::optional; [[nodiscard]] auto effectiveCollectible() @@ -221,6 +223,7 @@ private: std::unique_ptr _statusLabel; rpl::variable _statusShift = 0; object_ptr _showLastSeen = { nullptr }; + object_ptr _forumButton = { nullptr }; QGraphicsOpacityEffect *_showLastSeenOpacity = nullptr; std::shared_ptr _statusSt;