Add content to feed info cover widget.

This commit is contained in:
John Preston 2018-02-06 17:46:00 +03:00
parent 5a5c5782a9
commit a144e35f84
4 changed files with 60 additions and 121 deletions

View File

@ -1425,6 +1425,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_feed_channel_added" = "Channel added to your feed."; "lng_feed_channel_added" = "Channel added to your feed.";
"lng_feed_channel_removed" = "Channel removed from your feed."; "lng_feed_channel_removed" = "Channel removed from your feed.";
"lng_feed_no_messages" = "No messages in this feed yet"; "lng_feed_no_messages" = "No messages in this feed yet";
"lng_feed_channels#one" = "{count} channel";
"lng_feed_channels#other" = "{count} channels";
"lng_info_feed_title" = "Feed Info"; "lng_info_feed_title" = "Feed Info";

View File

@ -8,9 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/feed/info_feed_cover.h" #include "info/feed/info_feed_cover.h"
#include "data/data_feed.h" #include "data/data_feed.h"
#include "data/data_session.h"
#include "info/info_controller.h" #include "info/info_controller.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/special_buttons.h"
#include "auth_session.h"
#include "styles/style_info.h" #include "styles/style_info.h"
namespace Info { namespace Info {
@ -26,88 +29,43 @@ Cover::Cover(
+ st::infoProfilePhotoBottom) + st::infoProfilePhotoBottom)
, _controller(controller) , _controller(controller)
, _feed(_controller->key().feed()) , _feed(_controller->key().feed())
//, _userpic( , _userpic(
// this, this,
// controller->parentController(), controller->parentController(),
// _peer, _feed,
// Ui::UserpicButton::Role::OpenPhoto, st::infoFeedProfilePhoto)
// st::infoProfilePhoto)
, _name(this, st::infoProfileNameLabel) , _name(this, st::infoProfileNameLabel)
, _status( , _status(
this, this,
st::infoProfileMegagroupStatusLabel) { st::infoProfileMegagroupStatusLabel) {
_userpic->setPointerCursor(false);
_name->setSelectable(true); _name->setSelectable(true);
_name->setContextCopyText(lang(lng_profile_copy_fullname)); _name->setContextCopyText(lang(lng_profile_copy_fullname));
refreshNameText();
initViewers(); initViewers();
setupChildGeometry(); setupChildGeometry();
} }
void Cover::setupChildGeometry() { void Cover::setupChildGeometry() {
using namespace rpl::mappers; widthValue(
// ) | rpl::start_with_next([=](int newWidth) {
// Visual Studio 2017 15.5.1 internal compiler error here. _userpic->moveToLeft(
// See https://developercommunity.visualstudio.com/content/problem/165155/ice-regression-in-1551-after-successfull-build-in.html st::infoProfilePhotoLeft,
// st::infoProfilePhotoTop,
//rpl::combine( newWidth);
// toggleShownValue(), refreshNameGeometry(newWidth);
// widthValue(), refreshStatusGeometry(newWidth);
// _2 }, lifetime());
//) | rpl::map([](bool shown, int width) {
//rpl::combine(
// toggleShownValue(),
// widthValue()
//) | rpl::map([](bool shown, int width) {
// return width;
//}) | rpl::start_with_next([this](int newWidth) {
// _userpic->moveToLeft(
// st::infoProfilePhotoLeft,
// st::infoProfilePhotoTop,
// newWidth);
// refreshNameGeometry(newWidth);
// refreshStatusGeometry(newWidth);
//}, lifetime());
} }
void Cover::initViewers() { void Cover::initViewers() {
//using Flag = Notify::PeerUpdate::Flag; Auth().data().feedUpdated(
//Notify::PeerUpdateValue( ) | rpl::filter([](const Data::FeedUpdate &update) {
// _peer, return update.flag == Data::FeedUpdateFlag::Channels;
// Flag::NameChanged }) | rpl::start_with_next(
//) | rpl::start_with_next( [=] { refreshStatusText(); },
// [this] { refreshNameText(); }, lifetime());
// lifetime());
//Notify::PeerUpdateValue(
// _peer,
// Flag::UserOnlineChanged | Flag::MembersChanged
//) | rpl::start_with_next(
// [this] { refreshStatusText(); },
// lifetime());
//if (!_peer->isUser()) {
// Notify::PeerUpdateValue(
// _peer,
// Flag::ChannelRightsChanged | Flag::ChatCanEdit
// ) | rpl::start_with_next(
// [this] { refreshUploadPhotoOverlay(); },
// lifetime());
//}
//VerifiedValue(
// _peer
//) | rpl::start_with_next(
// [this](bool verified) { setVerified(verified); },
// lifetime());
}
void Cover::refreshUploadPhotoOverlay() {
//_userpic->switchChangePhotoOverlay([&] {
// if (auto chat = _peer->asChat()) {
// return chat->canEdit();
// } else if (auto channel = _peer->asChannel()) {
// return channel->canEditInformation();
// }
// return false;
//}());
} }
void Cover::refreshNameText() { void Cover::refreshNameText() {
@ -116,56 +74,21 @@ void Cover::refreshNameText() {
} }
void Cover::refreshStatusText() { void Cover::refreshStatusText() {
//auto hasMembersLink = [&] { const auto statusText = [&] {
// if (auto megagroup = _peer->asMegagroup()) { if (!_feed->channelsLoaded() || _feed->channels().empty()) {
// return megagroup->canViewMembers(); return QString();
// } }
// return false; return lng_feed_channels(lt_count, _feed->channels().size());
//}(); }();
//auto statusText = [&] { _status->setRichText(statusText);
// auto currentTime = unixtime(); //_status->setLink(1, std::make_shared<LambdaClickHandler>([=] {
// if (auto user = _peer->asUser()) { // _controller->showSection(Info::Memento(
// const auto result = Data::OnlineTextFull(user, currentTime); // _feed,
// const auto showOnline = Data::OnlineTextActive(user, currentTime); // Section::Type::Channels));
// const auto updateIn = Data::OnlineChangeTimeout(user, currentTime); //})); // #TODO channels list
// if (showOnline) {
// _refreshStatusTimer.callOnce(updateIn);
// }
// return showOnline
// ? textcmdLink(1, result)
// : result;
// } else if (auto chat = _peer->asChat()) {
// if (!chat->amIn()) {
// return lang(lng_chat_status_unaccessible);
// }
// auto fullCount = std::max(
// chat->count,
// int(chat->participants.size()));
// return ChatStatusText(fullCount, _onlineCount, true);
// } else if (auto channel = _peer->asChannel()) {
// auto fullCount = qMax(channel->membersCount(), 1);
// auto result = ChatStatusText(
// fullCount,
// _onlineCount,
// channel->isMegagroup());
// return hasMembersLink ? textcmdLink(1, result) : result;
// }
// return lang(lng_chat_status_unaccessible);
//}();
//_status->setRichText(statusText);
//if (hasMembersLink) {
// _status->setLink(1, std::make_shared<LambdaClickHandler>([=] {
// _controller->showSection(Info::Memento(
// _controller->peerId(),
// Section::Type::Members));
// }));
//}
refreshStatusGeometry(width()); refreshStatusGeometry(width());
} }
Cover::~Cover() {
}
void Cover::refreshNameGeometry(int newWidth) { void Cover::refreshNameGeometry(int newWidth) {
auto nameLeft = st::infoProfileNameLeft; auto nameLeft = st::infoProfileNameLeft;
auto nameTop = st::infoProfileNameTop; auto nameTop = st::infoProfileNameTop;
@ -187,5 +110,7 @@ void Cover::refreshStatusGeometry(int newWidth) {
newWidth); newWidth);
} }
Cover::~Cover() = default;
} // namespace FeedProfile } // namespace FeedProfile
} // namespace Info } // namespace Info

View File

@ -20,7 +20,7 @@ class Feed;
} // namespace Data } // namespace Data
namespace Ui { namespace Ui {
class UserpicButton; class FeedUserpicButton;
class FlatLabel; class FlatLabel;
template <typename Widget> template <typename Widget>
class SlideWrap; class SlideWrap;
@ -48,12 +48,11 @@ private:
void refreshStatusText(); void refreshStatusText();
void refreshNameGeometry(int newWidth); void refreshNameGeometry(int newWidth);
void refreshStatusGeometry(int newWidth); void refreshStatusGeometry(int newWidth);
void refreshUploadPhotoOverlay();
not_null<Controller*> _controller; not_null<Controller*> _controller;
not_null<Data::Feed*> _feed; not_null<Data::Feed*> _feed;
//object_ptr<Ui::UserpicButton> _userpic; object_ptr<Ui::FeedUserpicButton> _userpic;
object_ptr<Ui::FlatLabel> _name = { nullptr }; object_ptr<Ui::FlatLabel> _name = { nullptr };
object_ptr<Ui::FlatLabel> _status = { nullptr }; object_ptr<Ui::FlatLabel> _status = { nullptr };
//object_ptr<CoverDropArea> _dropArea = { nullptr }; //object_ptr<CoverDropArea> _dropArea = { nullptr };

View File

@ -260,9 +260,22 @@ infoTabs: SettingsSlider(defaultTabsSlider) {
labelTop: 19px; labelTop: 19px;
} }
infoProfilePhotoInnerSize: 72px;
infoProfilePhotoSize: size(
infoProfilePhotoInnerSize,
infoProfilePhotoInnerSize);
infoProfilePhoto: UserpicButton(defaultUserpicButton) { infoProfilePhoto: UserpicButton(defaultUserpicButton) {
size: size(72px, 72px); size: infoProfilePhotoSize;
photoSize: 72px; photoSize: infoProfilePhotoInnerSize;
}
infoFeedProfilePhoto: FeedUserpicButton(defaultFeedUserpicButton) {
size: infoProfilePhotoSize;
innerSize: infoProfilePhotoInnerSize;
innerPart: UserpicButton(defaultUserpicButton) {
size: size(35px, 35px);
photoSize: 35px;
}
} }
infoProfilePhotoLeft: 19px; infoProfilePhotoLeft: 19px;
infoProfilePhotoTop: 18px; infoProfilePhotoTop: 18px;