2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Feed info profile placeholder.

This commit is contained in:
John Preston
2018-01-22 22:51:38 +03:00
parent b9ad8bb700
commit a47981054f
37 changed files with 1336 additions and 104 deletions

View File

@@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rpl/take.h>
#include <rpl/combine.h>
#include "info/profile/info_profile_widget.h"
#include "info/profile/info_profile_members.h"
#include "info/profile/info_profile_values.h"
#include "info/media/info_media_widget.h"
#include "info/info_content_widget.h"
@@ -119,7 +118,7 @@ void WrapWidget::injectActiveProfile(Dialogs::Key key) {
if (const auto peer = key.peer()) {
injectActivePeerProfile(peer);
} else if (const auto feed = key.feed()) {
// #TODO feed profile
injectActiveFeedProfile(feed);
}
}
@@ -147,19 +146,40 @@ void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
if (firstSectionType != expectedType
|| firstSectionMediaType != expectedMediaType
|| firstPeerId != peer->id) {
auto injected = StackItem();
auto section = peer->isSelf()
? Section(Section::MediaType::Photo)
: Section(Section::Type::Profile);
injected.section = std::move(
Memento(peer->id, section).takeStack().front());
_historyStack.insert(
_historyStack.begin(),
std::move(injected));
if (_content) {
setupTop();
finishShowContent();
}
injectActiveProfileMemento(std::move(
Memento(peer->id, section).takeStack().front()));
}
}
void WrapWidget::injectActiveFeedProfile(not_null<Data::Feed*> feed) {
const auto firstFeed = hasStackHistory()
? _historyStack.front().section->feed()
: _controller->feed();
const auto firstSectionType = hasStackHistory()
? _historyStack.front().section->section().type()
: _controller->section().type();
const auto expectedType = Section::Type::Profile;
if (firstSectionType != expectedType
|| firstFeed != feed) {
auto section = Section(Section::Type::Profile);
injectActiveProfileMemento(std::move(
Memento(feed, section).takeStack().front()));
}
}
void WrapWidget::injectActiveProfileMemento(
std::unique_ptr<ContentMemento> memento) {
auto injected = StackItem();
injected.section = std::move(memento);
_historyStack.insert(
_historyStack.begin(),
std::move(injected));
if (_content) {
setupTop();
finishShowContent();
}
}
@@ -173,12 +193,17 @@ std::unique_ptr<Controller> WrapWidget::createController(
return result;
}
not_null<PeerData*> WrapWidget::peer() const {
return _controller->peer();
Key WrapWidget::key() const {
return _controller->key();
}
Dialogs::RowDescriptor WrapWidget::activeChat() const {
return Dialogs::RowDescriptor(App::history(peer()), MsgId(0));
if (const auto peer = key().peer()) {
return Dialogs::RowDescriptor(App::history(peer), MsgId(0));
} else if (const auto feed = key().feed()) {
return Dialogs::RowDescriptor(feed, MsgId(0));
}
Unexpected("Owner in WrapWidget::activeChat().");
}
// This was done for tabs support.
@@ -320,7 +345,7 @@ void WrapWidget::createTopBar() {
_topBar->setTitle(TitleValue(
_controller->section(),
_controller->peer(),
_controller->key(),
!hasStackHistory()));
if (wrapValue == Wrap::Narrow || hasStackHistory()) {
_topBar->enableBackButton();
@@ -383,7 +408,8 @@ void WrapWidget::addProfileMenuButton() {
void WrapWidget::addProfileCallsButton() {
Expects(_topBar != nullptr);
const auto user = _controller->peer()->asUser();
const auto peer = key().peer();
const auto user = peer ? peer->asUser() : nullptr;
if (!user || user->isSelf() || !Global::PhoneCallsEnabled()) {
return;
}
@@ -415,7 +441,10 @@ void WrapWidget::addProfileCallsButton() {
void WrapWidget::addProfileNotificationsButton() {
Expects(_topBar != nullptr);
const auto peer = _controller->peer();
const auto peer = key().peer();
if (!peer) {
return;
}
auto notifications = _topBar->addButton(
base::make_unique_q<Ui::IconButton>(
_topBar,
@@ -468,9 +497,14 @@ void WrapWidget::showProfileMenu() {
});
_topBarMenuToggle->installEventFilter(_topBarMenu.get());
// #TODO feeds menu
const auto peer = key().peer();
if (!peer) {
return;
}
Window::FillPeerMenu(
_controller->parentController(),
_controller->peer(),
peer,
[this](const QString &text, base::lambda<void()> callback) {
return _topBarMenu->addAction(text, std::move(callback));
},