2017-11-07 11:53:05 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-11-07 11:53:05 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-11-07 11:53:05 +00:00
|
|
|
*/
|
|
|
|
#include "info/profile/info_profile_actions.h"
|
|
|
|
|
2017-11-10 19:19:43 +00:00
|
|
|
#include "data/data_peer_values.h"
|
2018-02-08 09:20:14 +00:00
|
|
|
#include "data/data_session.h"
|
2019-04-15 11:54:03 +00:00
|
|
|
#include "data/data_folder.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_channel.h"
|
|
|
|
#include "data/data_user.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "ui/wrap/vertical_layout.h"
|
|
|
|
#include "ui/wrap/padding_wrap.h"
|
|
|
|
#include "ui/wrap/slide_wrap.h"
|
|
|
|
#include "ui/widgets/shadow.h"
|
2017-11-10 17:51:59 +00:00
|
|
|
#include "ui/widgets/labels.h"
|
2019-11-02 17:06:47 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/widgets/box_content_divider.h"
|
|
|
|
#include "ui/layers/generic_box.h"
|
2017-11-10 17:51:59 +00:00
|
|
|
#include "ui/toast/toast.h"
|
2019-06-17 16:59:43 +00:00
|
|
|
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
2019-06-21 12:27:46 +00:00
|
|
|
#include "history/history_location_manager.h" // LocationClickHandler.
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "boxes/peer_list_box.h"
|
|
|
|
#include "boxes/peer_list_controllers.h"
|
|
|
|
#include "boxes/add_contact_box.h"
|
|
|
|
#include "boxes/report_box.h"
|
2019-06-12 14:13:49 +00:00
|
|
|
#include "boxes/peers/edit_contact_box.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "info/info_controller.h"
|
2017-11-17 16:06:20 +00:00
|
|
|
#include "info/info_memento.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "info/profile/info_profile_icon.h"
|
|
|
|
#include "info/profile/info_profile_values.h"
|
|
|
|
#include "info/profile/info_profile_text.h"
|
2018-11-20 15:36:36 +00:00
|
|
|
#include "support/support_helper.h"
|
2019-06-06 10:21:40 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2019-06-12 14:13:49 +00:00
|
|
|
#include "window/window_controller.h" // Window::Controller::show.
|
2017-11-07 13:13:41 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "mainwidget.h"
|
2019-06-12 13:26:04 +00:00
|
|
|
#include "mainwindow.h" // MainWindow::controller.
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "apiwrap.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "facades.h"
|
2017-11-07 11:53:05 +00:00
|
|
|
#include "styles/style_info.h"
|
|
|
|
#include "styles/style_boxes.h"
|
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtGui/QGuiApplication>
|
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
|
2017-11-07 11:53:05 +00:00
|
|
|
namespace Info {
|
|
|
|
namespace Profile {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> CreateSkipWidget(
|
|
|
|
not_null<Ui::RpWidget*> parent) {
|
|
|
|
return Ui::CreateSkipWidget(parent, st::infoProfileSkip);
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::SlideWrap<>> CreateSlideSkipWidget(
|
|
|
|
not_null<Ui::RpWidget*> parent) {
|
2017-11-19 11:37:15 +00:00
|
|
|
auto result = Ui::CreateSlideSkipWidget(
|
|
|
|
parent,
|
|
|
|
st::infoProfileSkip);
|
|
|
|
result->setDuration(st::infoSlideDuration);
|
|
|
|
return result;
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Text, typename ToggleOn, typename Callback>
|
|
|
|
auto AddActionButton(
|
|
|
|
not_null<Ui::VerticalLayout*> parent,
|
|
|
|
Text &&text,
|
|
|
|
ToggleOn &&toggleOn,
|
|
|
|
Callback &&callback,
|
2019-11-02 17:06:47 +00:00
|
|
|
const style::SettingsButton &st
|
2017-11-07 11:53:05 +00:00
|
|
|
= st::infoSharedMediaButton) {
|
2019-11-02 17:06:47 +00:00
|
|
|
auto result = parent->add(object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
2017-11-07 11:53:05 +00:00
|
|
|
parent,
|
2019-11-02 17:06:47 +00:00
|
|
|
object_ptr<Ui::SettingsButton>(
|
2017-11-07 11:53:05 +00:00
|
|
|
parent,
|
|
|
|
std::move(text),
|
|
|
|
st))
|
|
|
|
);
|
2017-11-19 11:37:15 +00:00
|
|
|
result->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
)->toggleOn(
|
2017-11-07 11:53:05 +00:00
|
|
|
std::move(toggleOn)
|
|
|
|
)->entity()->addClickHandler(std::move(callback));
|
2017-11-17 17:02:49 +00:00
|
|
|
result->finishAnimating();
|
2017-11-07 11:53:05 +00:00
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Text, typename ToggleOn, typename Callback>
|
|
|
|
auto AddMainButton(
|
|
|
|
not_null<Ui::VerticalLayout*> parent,
|
|
|
|
Text &&text,
|
|
|
|
ToggleOn &&toggleOn,
|
|
|
|
Callback &&callback,
|
|
|
|
Ui::MultiSlideTracker &tracker) {
|
|
|
|
tracker.track(AddActionButton(
|
|
|
|
parent,
|
2019-06-17 16:59:43 +00:00
|
|
|
std::move(text) | Ui::Text::ToUpper(),
|
2017-11-07 11:53:05 +00:00
|
|
|
std::move(toggleOn),
|
|
|
|
std::move(callback),
|
|
|
|
st::infoMainButton));
|
|
|
|
}
|
|
|
|
|
|
|
|
class DetailsFiller {
|
|
|
|
public:
|
|
|
|
DetailsFiller(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer);
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> fill();
|
|
|
|
|
|
|
|
private:
|
|
|
|
object_ptr<Ui::RpWidget> setupInfo();
|
|
|
|
object_ptr<Ui::RpWidget> setupMuteToggle();
|
|
|
|
void setupMainButtons();
|
|
|
|
Ui::MultiSlideTracker fillUserButtons(
|
|
|
|
not_null<UserData*> user);
|
|
|
|
Ui::MultiSlideTracker fillChannelButtons(
|
|
|
|
not_null<ChannelData*> channel);
|
|
|
|
|
|
|
|
template <
|
|
|
|
typename Widget,
|
|
|
|
typename = std::enable_if_t<
|
|
|
|
std::is_base_of_v<Ui::RpWidget, Widget>>>
|
|
|
|
Widget *add(
|
|
|
|
object_ptr<Widget> &&child,
|
|
|
|
const style::margins &margin = style::margins()) {
|
|
|
|
return _wrap->add(
|
|
|
|
std::move(child),
|
|
|
|
margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
not_null<Controller*> _controller;
|
|
|
|
not_null<Ui::RpWidget*> _parent;
|
|
|
|
not_null<PeerData*> _peer;
|
|
|
|
object_ptr<Ui::VerticalLayout> _wrap;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class ActionsFiller {
|
|
|
|
public:
|
|
|
|
ActionsFiller(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer);
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> fill();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void addInviteToGroupAction(not_null<UserData*> user);
|
|
|
|
void addShareContactAction(not_null<UserData*> user);
|
|
|
|
void addEditContactAction(not_null<UserData*> user);
|
|
|
|
void addDeleteContactAction(not_null<UserData*> user);
|
|
|
|
void addClearHistoryAction(not_null<UserData*> user);
|
|
|
|
void addDeleteConversationAction(not_null<UserData*> user);
|
|
|
|
void addBotCommandActions(not_null<UserData*> user);
|
|
|
|
void addReportAction();
|
|
|
|
void addBlockAction(not_null<UserData*> user);
|
|
|
|
void addLeaveChannelAction(not_null<ChannelData*> channel);
|
|
|
|
void addJoinChannelAction(not_null<ChannelData*> channel);
|
|
|
|
void fillUserActions(not_null<UserData*> user);
|
|
|
|
void fillChannelActions(not_null<ChannelData*> channel);
|
|
|
|
|
|
|
|
not_null<Controller*> _controller;
|
|
|
|
not_null<Ui::RpWidget*> _parent;
|
|
|
|
not_null<PeerData*> _peer;
|
|
|
|
object_ptr<Ui::VerticalLayout> _wrap = { nullptr };
|
|
|
|
|
|
|
|
};
|
2019-04-15 11:54:03 +00:00
|
|
|
// // #feed
|
|
|
|
//class FeedDetailsFiller {
|
|
|
|
//public:
|
|
|
|
// FeedDetailsFiller(
|
|
|
|
// not_null<Controller*> controller,
|
|
|
|
// not_null<Ui::RpWidget*> parent,
|
|
|
|
// not_null<Data::Feed*> feed);
|
|
|
|
//
|
|
|
|
// object_ptr<Ui::RpWidget> fill();
|
|
|
|
//
|
|
|
|
//private:
|
|
|
|
// object_ptr<Ui::RpWidget> setupDefaultToggle();
|
|
|
|
//
|
|
|
|
// template <
|
|
|
|
// typename Widget,
|
|
|
|
// typename = std::enable_if_t<
|
|
|
|
// std::is_base_of_v<Ui::RpWidget, Widget>>>
|
|
|
|
// Widget *add(
|
|
|
|
// object_ptr<Widget> &&child,
|
|
|
|
// const style::margins &margin = style::margins()) {
|
|
|
|
// return _wrap->add(
|
|
|
|
// std::move(child),
|
|
|
|
// margin);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// not_null<Controller*> _controller;
|
|
|
|
// not_null<Ui::RpWidget*> _parent;
|
|
|
|
// not_null<Data::Feed*> _feed;
|
|
|
|
// object_ptr<Ui::VerticalLayout> _wrap;
|
|
|
|
//
|
|
|
|
//};
|
2018-02-07 12:40:37 +00:00
|
|
|
|
2017-11-07 11:53:05 +00:00
|
|
|
DetailsFiller::DetailsFiller(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer)
|
|
|
|
: _controller(controller)
|
|
|
|
, _parent(parent)
|
|
|
|
, _peer(peer)
|
|
|
|
, _wrap(_parent) {
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|
|
|
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
|
|
|
|
auto tracker = Ui::MultiSlideTracker();
|
2018-11-20 15:36:36 +00:00
|
|
|
auto addInfoLineGeneric = [&](
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> &&label,
|
2017-11-07 11:53:05 +00:00
|
|
|
rpl::producer<TextWithEntities> &&text,
|
|
|
|
const style::FlatLabel &textSt = st::infoLabeled) {
|
2017-11-10 17:51:59 +00:00
|
|
|
auto line = CreateTextWithLabel(
|
2017-11-07 11:53:05 +00:00
|
|
|
result,
|
2019-06-18 12:16:43 +00:00
|
|
|
std::move(label) | Ui::Text::ToWithEntities(),
|
2017-11-07 11:53:05 +00:00
|
|
|
std::move(text),
|
|
|
|
textSt,
|
2017-11-10 17:51:59 +00:00
|
|
|
st::infoProfileLabeledPadding);
|
|
|
|
tracker.track(result->add(std::move(line.wrap)));
|
|
|
|
return line.text;
|
2017-11-07 11:53:05 +00:00
|
|
|
};
|
2018-11-20 15:36:36 +00:00
|
|
|
auto addInfoLine = [&](
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> &&label,
|
2018-11-20 15:36:36 +00:00
|
|
|
rpl::producer<TextWithEntities> &&text,
|
|
|
|
const style::FlatLabel &textSt = st::infoLabeled) {
|
|
|
|
return addInfoLineGeneric(
|
2019-06-18 12:16:43 +00:00
|
|
|
std::move(label),
|
2018-11-20 15:36:36 +00:00
|
|
|
std::move(text),
|
|
|
|
textSt);
|
|
|
|
};
|
2017-11-07 11:53:05 +00:00
|
|
|
auto addInfoOneLine = [&](
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> &&label,
|
2017-11-10 17:51:59 +00:00
|
|
|
rpl::producer<TextWithEntities> &&text,
|
|
|
|
const QString &contextCopyText) {
|
|
|
|
auto result = addInfoLine(
|
2019-06-18 12:16:43 +00:00
|
|
|
std::move(label),
|
2017-11-07 11:53:05 +00:00
|
|
|
std::move(text),
|
|
|
|
st::infoLabeledOneLine);
|
2017-11-10 17:51:59 +00:00
|
|
|
result->setDoubleClickSelectsParagraph(true);
|
|
|
|
result->setContextCopyText(contextCopyText);
|
|
|
|
return result;
|
2017-11-07 11:53:05 +00:00
|
|
|
};
|
2019-06-21 12:27:46 +00:00
|
|
|
if (const auto user = _peer->asUser()) {
|
|
|
|
if (user->session().supportMode()) {
|
2018-11-20 15:36:36 +00:00
|
|
|
addInfoLineGeneric(
|
2019-06-21 12:27:46 +00:00
|
|
|
user->session().supportHelper().infoLabelValue(user),
|
|
|
|
user->session().supportHelper().infoTextValue(user));
|
2018-11-20 15:36:36 +00:00
|
|
|
}
|
|
|
|
|
2017-11-10 17:51:59 +00:00
|
|
|
addInfoOneLine(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_mobile_label(),
|
2019-07-04 10:07:32 +00:00
|
|
|
PhoneOrHiddenValue(user),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_profile_copy_phone(tr::now));
|
2019-07-18 08:51:11 +00:00
|
|
|
if (user->isBot()) {
|
2019-06-18 12:16:43 +00:00
|
|
|
addInfoLine(tr::lng_info_about_label(), AboutValue(user));
|
2017-11-07 11:53:05 +00:00
|
|
|
} else {
|
2019-06-18 12:16:43 +00:00
|
|
|
addInfoLine(tr::lng_info_bio_label(), BioValue(user));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
2017-11-10 17:51:59 +00:00
|
|
|
addInfoOneLine(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_username_label(),
|
2017-11-10 17:51:59 +00:00
|
|
|
UsernameValue(user),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_context_copy_mention(tr::now));
|
2019-07-04 10:07:32 +00:00
|
|
|
|
2019-09-03 15:24:51 +00:00
|
|
|
const auto window = &_controller->parentController()->window();
|
2019-07-04 10:07:32 +00:00
|
|
|
AddMainButton(
|
|
|
|
result,
|
|
|
|
tr::lng_info_add_as_contact(),
|
|
|
|
CanAddContactValue(user),
|
|
|
|
[=] { window->show(Box(EditContactBox, window, user)); },
|
|
|
|
tracker);
|
2017-11-07 11:53:05 +00:00
|
|
|
} else {
|
2017-12-22 07:05:20 +00:00
|
|
|
auto linkText = LinkValue(
|
|
|
|
_peer
|
|
|
|
) | rpl::map([](const QString &link) {
|
2019-06-21 12:27:46 +00:00
|
|
|
return link.isEmpty()
|
|
|
|
? TextWithEntities()
|
|
|
|
: Ui::Text::Link(
|
|
|
|
(link.startsWith(qstr("https://"))
|
|
|
|
? link.mid(qstr("https://").size())
|
|
|
|
: link),
|
|
|
|
link);
|
2017-12-22 07:05:20 +00:00
|
|
|
});
|
2017-11-10 17:51:59 +00:00
|
|
|
auto link = addInfoOneLine(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_link_label(),
|
2017-11-10 17:51:59 +00:00
|
|
|
std::move(linkText),
|
|
|
|
QString());
|
2018-06-22 19:46:20 +00:00
|
|
|
link->setClickHandlerFilter([peer = _peer](auto&&...) {
|
2019-06-21 12:27:46 +00:00
|
|
|
const auto link = Core::App().createInternalLinkFull(
|
2017-11-10 17:51:59 +00:00
|
|
|
peer->userName());
|
|
|
|
if (!link.isEmpty()) {
|
2019-09-04 07:19:15 +00:00
|
|
|
QGuiApplication::clipboard()->setText(link);
|
2019-06-19 15:09:03 +00:00
|
|
|
Ui::Toast::Show(tr::lng_username_copied(tr::now));
|
2017-11-10 17:51:59 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2019-06-21 12:27:46 +00:00
|
|
|
|
|
|
|
if (const auto channel = _peer->asChannel()) {
|
|
|
|
auto locationText = LocationValue(
|
|
|
|
channel
|
|
|
|
) | rpl::map([](const ChannelLocation *location) {
|
|
|
|
return location
|
|
|
|
? Ui::Text::Link(
|
2019-06-24 13:31:23 +00:00
|
|
|
TextUtilities::SingleLine(location->address),
|
2019-06-21 12:27:46 +00:00
|
|
|
LocationClickHandler::Url(location->point))
|
|
|
|
: TextWithEntities();
|
|
|
|
});
|
|
|
|
addInfoOneLine(
|
|
|
|
tr::lng_info_location_label(),
|
|
|
|
std::move(locationText),
|
|
|
|
QString()
|
|
|
|
)->setLinksTrusted();
|
|
|
|
}
|
|
|
|
|
2019-06-18 12:16:43 +00:00
|
|
|
addInfoLine(tr::lng_info_about_label(), AboutValue(_peer));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
2017-12-05 14:07:01 +00:00
|
|
|
if (!_peer->isSelf()) {
|
|
|
|
// No notifications toggle for Self => no separator.
|
|
|
|
result->add(object_ptr<Ui::SlideWrap<>>(
|
|
|
|
result,
|
|
|
|
object_ptr<Ui::PlainShadow>(result),
|
|
|
|
st::infoProfileSeparatorPadding)
|
|
|
|
)->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
)->toggleOn(
|
|
|
|
std::move(tracker).atLeastOneShownValue()
|
|
|
|
);
|
|
|
|
}
|
2017-11-07 11:53:05 +00:00
|
|
|
object_ptr<FloatingIcon>(
|
|
|
|
result,
|
|
|
|
st::infoIconInformation,
|
|
|
|
st::infoInformationIconPosition);
|
2019-11-12 15:15:34 +00:00
|
|
|
return result;
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
2017-12-04 17:46:03 +00:00
|
|
|
const auto peer = _peer;
|
2019-11-02 17:06:47 +00:00
|
|
|
auto result = object_ptr<Ui::SettingsButton>(
|
2017-11-07 11:53:05 +00:00
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_enable_notifications(),
|
2017-11-07 11:53:05 +00:00
|
|
|
st::infoNotificationsButton);
|
|
|
|
result->toggleOn(
|
|
|
|
NotificationsEnabledValue(peer)
|
|
|
|
)->addClickHandler([=] {
|
2019-07-24 11:13:51 +00:00
|
|
|
const auto muteForSeconds = peer->owner().notifyIsMuted(peer)
|
2018-04-09 17:48:29 +00:00
|
|
|
? 0
|
|
|
|
: Data::NotifySettings::kDefaultMutePeriod;
|
2019-07-24 11:13:51 +00:00
|
|
|
peer->owner().updateNotifySettings(peer, muteForSeconds);
|
2017-11-07 11:53:05 +00:00
|
|
|
});
|
|
|
|
object_ptr<FloatingIcon>(
|
|
|
|
result,
|
|
|
|
st::infoIconNotifications,
|
|
|
|
st::infoNotificationsIconPosition);
|
2019-11-12 15:15:34 +00:00
|
|
|
return result;
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsFiller::setupMainButtons() {
|
|
|
|
auto wrapButtons = [=](auto &&callback) {
|
|
|
|
auto topSkip = _wrap->add(CreateSlideSkipWidget(_wrap));
|
|
|
|
auto tracker = callback();
|
|
|
|
topSkip->toggleOn(std::move(tracker).atLeastOneShownValue());
|
|
|
|
};
|
|
|
|
if (auto user = _peer->asUser()) {
|
|
|
|
wrapButtons([=] {
|
|
|
|
return fillUserButtons(user);
|
|
|
|
});
|
|
|
|
} else if (auto channel = _peer->asChannel()) {
|
|
|
|
if (!channel->isMegagroup()) {
|
|
|
|
wrapButtons([=] {
|
|
|
|
return fillChannelButtons(channel);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
|
|
|
|
not_null<UserData*> user) {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
|
|
|
|
Ui::MultiSlideTracker tracker;
|
2017-12-09 15:13:06 +00:00
|
|
|
auto window = _controller->parentController();
|
2017-12-05 14:07:01 +00:00
|
|
|
|
|
|
|
auto addSendMessageButton = [&] {
|
2018-02-14 19:38:01 +00:00
|
|
|
auto activePeerValue = window->activeChatValue(
|
|
|
|
) | rpl::map([](Dialogs::Key key) {
|
|
|
|
return key.peer();
|
|
|
|
});
|
2017-12-05 14:07:01 +00:00
|
|
|
auto sendMessageVisible = rpl::combine(
|
|
|
|
_controller->wrapValue(),
|
2018-02-14 19:38:01 +00:00
|
|
|
std::move(activePeerValue),
|
2017-12-05 14:07:01 +00:00
|
|
|
(_1 != Wrap::Side) || (_2 != user));
|
|
|
|
auto sendMessage = [window, user] {
|
|
|
|
window->showPeerHistory(
|
|
|
|
user,
|
|
|
|
Window::SectionShow::Way::Forward);
|
|
|
|
};
|
|
|
|
AddMainButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_send_message(),
|
2017-12-05 14:07:01 +00:00
|
|
|
std::move(sendMessageVisible),
|
|
|
|
std::move(sendMessage),
|
|
|
|
tracker);
|
2017-11-07 11:53:05 +00:00
|
|
|
};
|
|
|
|
|
2017-12-05 14:07:01 +00:00
|
|
|
if (user->isSelf()) {
|
|
|
|
auto separator = _wrap->add(object_ptr<Ui::SlideWrap<>>(
|
|
|
|
_wrap,
|
|
|
|
object_ptr<Ui::PlainShadow>(_wrap),
|
|
|
|
st::infoProfileSeparatorPadding)
|
|
|
|
)->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
);
|
|
|
|
|
|
|
|
addSendMessageButton();
|
|
|
|
|
|
|
|
separator->toggleOn(
|
|
|
|
std::move(tracker).atLeastOneShownValue()
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
addSendMessageButton();
|
|
|
|
}
|
2017-11-07 11:53:05 +00:00
|
|
|
return tracker;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ui::MultiSlideTracker DetailsFiller::fillChannelButtons(
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
|
|
|
|
Ui::MultiSlideTracker tracker;
|
2017-12-09 15:13:06 +00:00
|
|
|
auto window = _controller->parentController();
|
2018-02-14 19:38:01 +00:00
|
|
|
auto activePeerValue = window->activeChatValue(
|
|
|
|
) | rpl::map([](Dialogs::Key key) {
|
|
|
|
return key.peer();
|
|
|
|
});
|
2017-11-17 17:02:49 +00:00
|
|
|
auto viewChannelVisible = rpl::combine(
|
|
|
|
_controller->wrapValue(),
|
2018-02-14 19:38:01 +00:00
|
|
|
std::move(activePeerValue),
|
2017-11-20 12:32:55 +00:00
|
|
|
(_1 != Wrap::Side) || (_2 != channel));
|
2017-11-07 11:53:05 +00:00
|
|
|
auto viewChannel = [=] {
|
|
|
|
window->showPeerHistory(
|
|
|
|
channel,
|
|
|
|
Window::SectionShow::Way::Forward);
|
|
|
|
};
|
|
|
|
AddMainButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_view_channel(),
|
2017-11-07 11:53:05 +00:00
|
|
|
std::move(viewChannelVisible),
|
|
|
|
std::move(viewChannel),
|
|
|
|
tracker);
|
|
|
|
|
|
|
|
return tracker;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> DetailsFiller::fill() {
|
2019-09-18 11:19:05 +00:00
|
|
|
add(object_ptr<Ui::BoxContentDivider>(_wrap));
|
2017-11-07 11:53:05 +00:00
|
|
|
add(CreateSkipWidget(_wrap));
|
|
|
|
add(setupInfo());
|
2017-12-05 14:07:01 +00:00
|
|
|
if (!_peer->isSelf()) {
|
|
|
|
add(setupMuteToggle());
|
|
|
|
}
|
2017-11-07 11:53:05 +00:00
|
|
|
setupMainButtons();
|
|
|
|
add(CreateSkipWidget(_wrap));
|
|
|
|
return std::move(_wrap);
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionsFiller::ActionsFiller(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer)
|
|
|
|
: _controller(controller)
|
|
|
|
, _parent(parent)
|
|
|
|
, _peer(peer) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addInviteToGroupAction(
|
|
|
|
not_null<UserData*> user) {
|
2019-07-25 18:55:11 +00:00
|
|
|
const auto controller = _controller;
|
2017-11-07 11:53:05 +00:00
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_invite_to_group(),
|
2017-11-07 11:53:05 +00:00
|
|
|
CanInviteBotToGroupValue(user),
|
2019-07-25 18:55:11 +00:00
|
|
|
[=] { AddBotToGroupBoxController::Start(controller, user); });
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addShareContactAction(not_null<UserData*> user) {
|
2019-07-25 18:55:11 +00:00
|
|
|
const auto controller = _controller;
|
2017-11-07 11:53:05 +00:00
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_share_contact(),
|
2017-11-07 11:53:05 +00:00
|
|
|
CanShareContactValue(user),
|
2019-07-25 18:55:11 +00:00
|
|
|
[=] { Window::PeerMenuShareContactBox(controller, user); });
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
2019-09-03 15:24:51 +00:00
|
|
|
const auto window = &_controller->parentController()->window();
|
2017-11-07 11:53:05 +00:00
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_edit_contact(),
|
2017-11-07 11:53:05 +00:00
|
|
|
IsContactValue(user),
|
2019-06-12 14:13:49 +00:00
|
|
|
[=] { window->show(Box(EditContactBox, window, user)); });
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addDeleteContactAction(
|
|
|
|
not_null<UserData*> user) {
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_info_delete_contact(),
|
2017-11-07 11:53:05 +00:00
|
|
|
IsContactValue(user),
|
2017-11-07 13:13:41 +00:00
|
|
|
[user] { Window::PeerMenuDeleteContact(user); });
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addClearHistoryAction(not_null<UserData*> user) {
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_clear_history(),
|
2017-11-07 11:53:05 +00:00
|
|
|
rpl::single(true),
|
2017-12-06 14:39:27 +00:00
|
|
|
Window::ClearHistoryHandler(user));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addDeleteConversationAction(
|
|
|
|
not_null<UserData*> user) {
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_delete_conversation(),
|
2017-11-07 11:53:05 +00:00
|
|
|
rpl::single(true),
|
2017-12-06 14:39:27 +00:00
|
|
|
Window::DeleteAndLeaveHandler(user));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
|
|
|
auto findBotCommand = [user](const QString &command) {
|
2019-07-18 08:51:11 +00:00
|
|
|
if (!user->isBot()) {
|
2017-11-07 11:53:05 +00:00
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
for_const (auto &data, user->botInfo->commands) {
|
|
|
|
auto isSame = data.command.compare(
|
|
|
|
command,
|
|
|
|
Qt::CaseInsensitive) == 0;
|
|
|
|
if (isSame) {
|
|
|
|
return data.command;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
};
|
|
|
|
auto hasBotCommandValue = [=](const QString &command) {
|
|
|
|
return Notify::PeerUpdateValue(
|
|
|
|
user,
|
2017-12-22 07:05:20 +00:00
|
|
|
Notify::PeerUpdate::Flag::BotCommandsChanged
|
|
|
|
) | rpl::map([=] {
|
|
|
|
return !findBotCommand(command).isEmpty();
|
|
|
|
});
|
2017-11-07 11:53:05 +00:00
|
|
|
};
|
|
|
|
auto sendBotCommand = [=](const QString &command) {
|
|
|
|
auto original = findBotCommand(command);
|
|
|
|
if (!original.isEmpty()) {
|
|
|
|
Ui::showPeerHistory(user, ShowAtTheEndMsgId);
|
|
|
|
App::sendBotCommand(user, user, '/' + original);
|
|
|
|
}
|
|
|
|
};
|
2019-06-18 12:16:43 +00:00
|
|
|
auto addBotCommand = [=](
|
|
|
|
rpl::producer<QString> text,
|
|
|
|
const QString &command) {
|
2017-11-07 11:53:05 +00:00
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
std::move(text),
|
2017-11-07 11:53:05 +00:00
|
|
|
hasBotCommandValue(command),
|
|
|
|
[=] { sendBotCommand(command); });
|
|
|
|
};
|
2019-06-18 12:16:43 +00:00
|
|
|
addBotCommand(tr::lng_profile_bot_help(), qsl("help"));
|
|
|
|
addBotCommand(tr::lng_profile_bot_settings(), qsl("settings"));
|
|
|
|
addBotCommand(tr::lng_profile_bot_privacy(), qsl("privacy"));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addReportAction() {
|
2019-03-12 10:36:33 +00:00
|
|
|
const auto peer = _peer;
|
2017-11-07 11:53:05 +00:00
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_report(),
|
2017-11-07 11:53:05 +00:00
|
|
|
rpl::single(true),
|
2019-03-12 10:36:33 +00:00
|
|
|
[=] { Ui::show(Box<ReportBox>(peer)); },
|
2017-11-07 11:53:05 +00:00
|
|
|
st::infoBlockButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addBlockAction(not_null<UserData*> user) {
|
2019-09-03 15:24:51 +00:00
|
|
|
const auto window = &_controller->parentController()->window();
|
2019-06-12 13:26:04 +00:00
|
|
|
|
2017-11-07 11:53:05 +00:00
|
|
|
auto text = Notify::PeerUpdateValue(
|
|
|
|
user,
|
2017-12-22 07:05:20 +00:00
|
|
|
Notify::PeerUpdate::Flag::UserIsBlocked
|
|
|
|
) | rpl::map([user] {
|
|
|
|
switch (user->blockStatus()) {
|
|
|
|
case UserData::BlockStatus::Blocked:
|
2019-06-18 12:16:43 +00:00
|
|
|
return ((user->isBot() && !user->isSupport())
|
|
|
|
? tr::lng_profile_restart_bot
|
|
|
|
: tr::lng_profile_unblock_user)();
|
2017-12-22 07:05:20 +00:00
|
|
|
case UserData::BlockStatus::NotBlocked:
|
|
|
|
default:
|
2019-06-18 12:16:43 +00:00
|
|
|
return ((user->isBot() && !user->isSupport())
|
|
|
|
? tr::lng_profile_block_bot
|
|
|
|
: tr::lng_profile_block_user)();
|
2017-12-22 07:05:20 +00:00
|
|
|
}
|
|
|
|
}) | rpl::flatten_latest(
|
|
|
|
) | rpl::start_spawning(_wrap->lifetime());
|
2017-11-07 11:53:05 +00:00
|
|
|
|
2017-12-22 07:05:20 +00:00
|
|
|
auto toggleOn = rpl::duplicate(
|
|
|
|
text
|
|
|
|
) | rpl::map([](const QString &text) {
|
|
|
|
return !text.isEmpty();
|
|
|
|
});
|
2018-12-04 11:46:07 +00:00
|
|
|
auto callback = [=] {
|
2017-11-07 11:53:05 +00:00
|
|
|
if (user->isBlocked()) {
|
2019-07-04 14:02:22 +00:00
|
|
|
Window::PeerMenuUnblockUserWithBotRestart(user);
|
2019-07-18 08:51:11 +00:00
|
|
|
if (user->isBot()) {
|
2018-12-04 11:46:07 +00:00
|
|
|
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
|
|
|
}
|
2019-07-15 13:47:40 +00:00
|
|
|
} else if (user->isBot()) {
|
2019-07-04 14:02:22 +00:00
|
|
|
user->session().api().blockUser(user);
|
2019-07-15 13:47:40 +00:00
|
|
|
} else {
|
|
|
|
window->show(
|
|
|
|
Box(Window::PeerMenuBlockUserBox, window, user, false));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
|
|
|
rpl::duplicate(text),
|
|
|
|
std::move(toggleOn),
|
|
|
|
std::move(callback),
|
|
|
|
st::infoBlockButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addLeaveChannelAction(
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_leave_channel(),
|
2017-11-07 11:53:05 +00:00
|
|
|
AmInChannelValue(channel),
|
2018-02-08 09:20:14 +00:00
|
|
|
Window::DeleteAndLeaveHandler(channel));
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::addJoinChannelAction(
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
auto joinVisible = AmInChannelValue(channel)
|
2017-11-20 12:32:55 +00:00
|
|
|
| rpl::map(!_1)
|
2017-11-07 11:53:05 +00:00
|
|
|
| rpl::start_spawning(_wrap->lifetime());
|
|
|
|
AddActionButton(
|
|
|
|
_wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_profile_join_channel(),
|
2017-11-07 11:53:05 +00:00
|
|
|
rpl::duplicate(joinVisible),
|
2019-07-24 11:13:51 +00:00
|
|
|
[=] { channel->session().api().joinChannel(channel); });
|
2017-11-07 11:53:05 +00:00
|
|
|
_wrap->add(object_ptr<Ui::SlideWrap<Ui::FixedHeightWidget>>(
|
|
|
|
_wrap,
|
|
|
|
CreateSkipWidget(
|
|
|
|
_wrap,
|
|
|
|
st::infoBlockButtonSkip))
|
2017-11-19 11:37:15 +00:00
|
|
|
)->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::duplicate(joinVisible)
|
|
|
|
);
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::fillUserActions(not_null<UserData*> user) {
|
2019-07-18 08:51:11 +00:00
|
|
|
if (user->isBot()) {
|
2017-11-07 11:53:05 +00:00
|
|
|
addInviteToGroupAction(user);
|
|
|
|
}
|
|
|
|
addShareContactAction(user);
|
2017-12-05 14:07:01 +00:00
|
|
|
if (!user->isSelf()) {
|
|
|
|
addEditContactAction(user);
|
|
|
|
addDeleteContactAction(user);
|
|
|
|
}
|
2017-11-07 11:53:05 +00:00
|
|
|
addClearHistoryAction(user);
|
|
|
|
addDeleteConversationAction(user);
|
2019-04-03 12:14:05 +00:00
|
|
|
if (!user->isSelf() && !user->isSupport()) {
|
|
|
|
if (user->isBot()) {
|
2017-11-07 11:53:05 +00:00
|
|
|
addBotCommandActions(user);
|
|
|
|
}
|
|
|
|
_wrap->add(CreateSkipWidget(
|
|
|
|
_wrap,
|
|
|
|
st::infoBlockButtonSkip));
|
2019-04-03 12:14:05 +00:00
|
|
|
if (user->isBot()) {
|
2017-11-07 11:53:05 +00:00
|
|
|
addReportAction();
|
|
|
|
}
|
|
|
|
addBlockAction(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsFiller::fillChannelActions(
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
|
|
|
|
addJoinChannelAction(channel);
|
2017-11-10 19:19:43 +00:00
|
|
|
addLeaveChannelAction(channel);
|
2017-11-07 11:53:05 +00:00
|
|
|
if (!channel->amCreator()) {
|
|
|
|
addReportAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
|
|
|
auto wrapResult = [=](auto &&callback) {
|
|
|
|
_wrap = object_ptr<Ui::VerticalLayout>(_parent);
|
|
|
|
_wrap->add(CreateSkipWidget(_wrap));
|
|
|
|
callback();
|
|
|
|
_wrap->add(CreateSkipWidget(_wrap));
|
|
|
|
object_ptr<FloatingIcon>(
|
|
|
|
_wrap,
|
|
|
|
st::infoIconActions,
|
|
|
|
st::infoIconPosition);
|
|
|
|
return std::move(_wrap);
|
|
|
|
};
|
|
|
|
if (auto user = _peer->asUser()) {
|
|
|
|
return wrapResult([=] {
|
|
|
|
fillUserActions(user);
|
|
|
|
});
|
|
|
|
} else if (auto channel = _peer->asChannel()) {
|
2017-11-10 19:19:43 +00:00
|
|
|
if (channel->isMegagroup()) {
|
|
|
|
return { nullptr };
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
2017-11-10 19:19:43 +00:00
|
|
|
return wrapResult([=] {
|
|
|
|
fillChannelActions(channel);
|
|
|
|
});
|
2017-11-07 11:53:05 +00:00
|
|
|
}
|
|
|
|
return { nullptr };
|
|
|
|
}
|
2019-04-15 11:54:03 +00:00
|
|
|
// // #feed
|
|
|
|
//FeedDetailsFiller::FeedDetailsFiller(
|
|
|
|
// not_null<Controller*> controller,
|
|
|
|
// not_null<Ui::RpWidget*> parent,
|
|
|
|
// not_null<Data::Feed*> feed)
|
|
|
|
//: _controller(controller)
|
|
|
|
//, _parent(parent)
|
|
|
|
//, _feed(feed)
|
|
|
|
//, _wrap(_parent) {
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//object_ptr<Ui::RpWidget> FeedDetailsFiller::fill() {
|
2019-09-18 11:19:05 +00:00
|
|
|
// add(object_ptr<Ui::BoxContentDivider>(_wrap));
|
2019-04-15 11:54:03 +00:00
|
|
|
// add(CreateSkipWidget(_wrap));
|
|
|
|
// add(setupDefaultToggle());
|
|
|
|
// add(CreateSkipWidget(_wrap));
|
|
|
|
// return std::move(_wrap);
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//object_ptr<Ui::RpWidget> FeedDetailsFiller::setupDefaultToggle() {
|
|
|
|
// using namespace rpl::mappers;
|
2019-07-24 11:13:51 +00:00
|
|
|
// const auto feed = _feed;
|
|
|
|
// const auto feedId = feed->id();
|
2019-11-02 17:06:47 +00:00
|
|
|
// auto result = object_ptr<Ui::SettingsButton>(
|
2019-04-15 11:54:03 +00:00
|
|
|
// _wrap,
|
2019-06-18 12:16:43 +00:00
|
|
|
// tr::lng_info_feed_is_default(),
|
2019-04-15 11:54:03 +00:00
|
|
|
// st::infoNotificationsButton);
|
|
|
|
// result->toggleOn(
|
2019-07-24 11:13:51 +00:00
|
|
|
// feed->owner().defaultFeedIdValue(
|
2019-04-15 11:54:03 +00:00
|
|
|
// ) | rpl::map(_1 == feedId)
|
|
|
|
// )->addClickHandler([=] {
|
2019-07-24 11:13:51 +00:00
|
|
|
// const auto makeDefault = (feed->owner().defaultFeedId() != feedId);
|
2019-04-15 11:54:03 +00:00
|
|
|
// const auto defaultFeedId = makeDefault ? feedId : 0;
|
2019-07-24 11:13:51 +00:00
|
|
|
// feed->owner().setDefaultFeedId(defaultFeedId);
|
|
|
|
//// feed->session().api().saveDefaultFeedId(feedId, makeDefault); // #feed
|
2019-04-15 11:54:03 +00:00
|
|
|
// });
|
|
|
|
// object_ptr<FloatingIcon>(
|
|
|
|
// result,
|
|
|
|
// st::infoIconNotifications,
|
|
|
|
// st::infoNotificationsIconPosition);
|
2019-11-12 15:15:34 +00:00
|
|
|
// return result;
|
2019-04-15 11:54:03 +00:00
|
|
|
//}
|
2018-02-07 12:40:37 +00:00
|
|
|
|
2017-11-07 11:53:05 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> SetupDetails(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer) {
|
|
|
|
DetailsFiller filler(controller, parent, peer);
|
|
|
|
return filler.fill();
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Ui::RpWidget> SetupActions(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer) {
|
|
|
|
ActionsFiller filler(controller, parent, peer);
|
|
|
|
return filler.fill();
|
|
|
|
}
|
|
|
|
|
2017-11-17 16:06:20 +00:00
|
|
|
void SetupAddChannelMember(
|
2019-07-25 18:55:11 +00:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2017-11-17 16:06:20 +00:00
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
auto add = Ui::CreateChild<Ui::IconButton>(
|
|
|
|
parent.get(),
|
|
|
|
st::infoMembersAddMember);
|
|
|
|
add->showOn(CanAddMemberValue(channel));
|
2019-07-25 18:55:11 +00:00
|
|
|
add->addClickHandler([=] {
|
|
|
|
Window::PeerMenuAddChannelMembers(navigation, channel);
|
2017-11-17 16:06:20 +00:00
|
|
|
});
|
2017-12-22 07:05:20 +00:00
|
|
|
parent->widthValue(
|
|
|
|
) | rpl::start_with_next([add](int newWidth) {
|
|
|
|
auto availableWidth = newWidth
|
|
|
|
- st::infoMembersButtonPosition.x();
|
|
|
|
add->moveToLeft(
|
|
|
|
availableWidth - add->width(),
|
|
|
|
st::infoMembersButtonPosition.y(),
|
|
|
|
newWidth);
|
|
|
|
}, add->lifetime());
|
2017-11-17 16:06:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-10 19:19:43 +00:00
|
|
|
object_ptr<Ui::RpWidget> SetupChannelMembers(
|
|
|
|
not_null<Controller*> controller,
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
not_null<PeerData*> peer) {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
|
|
|
|
auto channel = peer->asChannel();
|
|
|
|
if (!channel || channel->isMegagroup()) {
|
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
|
|
|
|
auto membersShown = rpl::combine(
|
|
|
|
MembersCountValue(channel),
|
|
|
|
Data::PeerFullFlagValue(
|
|
|
|
channel,
|
|
|
|
MTPDchannelFull::Flag::f_can_view_participants),
|
2017-11-20 12:32:55 +00:00
|
|
|
(_1 > 0) && _2);
|
2019-06-19 16:39:25 +00:00
|
|
|
auto membersText = tr::lng_chat_status_members(
|
|
|
|
lt_count_decimal,
|
|
|
|
MembersCountValue(channel) | tr::to_count());
|
|
|
|
auto membersCallback = [=] {
|
2017-12-04 11:45:15 +00:00
|
|
|
controller->showSection(Info::Memento(
|
2017-11-17 16:06:20 +00:00
|
|
|
channel->id,
|
|
|
|
Section::Type::Members));
|
2017-11-10 19:19:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
|
|
|
parent,
|
|
|
|
object_ptr<Ui::VerticalLayout>(parent));
|
2017-11-19 11:37:15 +00:00
|
|
|
result->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
)->toggleOn(
|
|
|
|
std::move(membersShown)
|
|
|
|
);
|
2017-11-10 19:19:43 +00:00
|
|
|
|
|
|
|
auto members = result->entity();
|
2019-09-18 11:19:05 +00:00
|
|
|
members->add(object_ptr<Ui::BoxContentDivider>(members));
|
2017-11-10 19:19:43 +00:00
|
|
|
members->add(CreateSkipWidget(members));
|
2017-11-17 16:06:20 +00:00
|
|
|
auto button = AddActionButton(
|
2017-11-10 19:19:43 +00:00
|
|
|
members,
|
|
|
|
std::move(membersText),
|
|
|
|
rpl::single(true),
|
2017-11-17 16:06:20 +00:00
|
|
|
std::move(membersCallback))->entity();
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
SetupAddChannelMember(controller, button, channel);
|
2017-11-17 16:06:20 +00:00
|
|
|
|
2017-11-10 19:19:43 +00:00
|
|
|
object_ptr<FloatingIcon>(
|
|
|
|
members,
|
|
|
|
st::infoIconMembers,
|
|
|
|
st::infoChannelMembersIconPosition);
|
|
|
|
members->add(CreateSkipWidget(members));
|
|
|
|
|
2019-11-12 15:15:34 +00:00
|
|
|
return result;
|
2017-11-10 19:19:43 +00:00
|
|
|
}
|
2019-04-15 11:54:03 +00:00
|
|
|
// // #feed
|
|
|
|
//object_ptr<Ui::RpWidget> SetupFeedDetails(
|
|
|
|
// not_null<Controller*> controller,
|
|
|
|
// not_null<Ui::RpWidget*> parent,
|
|
|
|
// not_null<Data::Feed*> feed) {
|
|
|
|
// FeedDetailsFiller filler(controller, parent, feed);
|
|
|
|
// return filler.fill();
|
|
|
|
//}
|
2018-02-07 12:40:37 +00:00
|
|
|
|
2017-11-07 11:53:05 +00:00
|
|
|
} // namespace Profile
|
|
|
|
} // namespace Info
|