Added administrators button to profile section of owned channels.

This commit is contained in:
23rd 2024-10-04 08:55:46 +03:00
parent d56f3cfecf
commit 3cb0be5be5
5 changed files with 84 additions and 23 deletions

View file

@ -1379,6 +1379,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_copy_fullname" = "Copy Name";
"lng_profile_photo_by_you" = "photo set by you";
"lng_profile_public_photo" = "public photo";
"lng_profile_administrators#one" = "{count} administrator";
"lng_profile_administrators#other" = "{count} administrators";
"lng_invite_upgrade_title" = "Upgrade to Premium";
"lng_invite_upgrade_group_invite#one" = "{users} only accepts invitations to groups from Contacts and **Premium** users.";

View file

@ -488,7 +488,8 @@ infoInformationIconPosition: point(25px, 12px);
infoNotificationsIconPosition: point(20px, 5px);
infoSharedMediaButtonIconPosition: point(20px, 3px);
infoGroupMembersIconPosition: point(20px, 10px);
infoChannelMembersIconPosition: point(20px, 19px);
infoChannelMembersIconPosition: point(20px, 4px);
infoChannelAdminsIconPosition: point(24px, 7px);
infoOpenApp: RoundButton(defaultActiveButton) {
textTop: 11px;

View file

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h"
#include "boxes/peers/add_bot_to_chat_box.h"
#include "boxes/peers/edit_contact_box.h"
#include "boxes/peers/edit_participants_box.h"
#include "boxes/report_messages_box.h"
#include "boxes/share_box.h"
#include "boxes/star_gift_box.h"
@ -2243,7 +2244,7 @@ void SetupAddChannelMember(
}, add->lifetime());
}
object_ptr<Ui::RpWidget> SetupChannelMembers(
object_ptr<Ui::RpWidget> SetupChannelMembersAndManage(
not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent,
not_null<PeerData*> peer) {
@ -2254,6 +2255,12 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
return { nullptr };
}
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
parent,
object_ptr<Ui::VerticalLayout>(parent));
result->entity()->add(object_ptr<Ui::BoxContentDivider>(result));
result->entity()->add(CreateSkipWidget(result));
auto membersShown = rpl::combine(
MembersCountValue(channel),
Data::PeerFlagValue(
@ -2269,32 +2276,77 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
Section::Type::Members));
};
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
parent,
object_ptr<Ui::VerticalLayout>(parent));
result->setDuration(
const auto membersWrap = result->entity()->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
result->entity(),
object_ptr<Ui::VerticalLayout>(result->entity())));
membersWrap->setDuration(
st::infoSlideDuration
)->toggleOn(
std::move(membersShown)
);
)->toggleOn(rpl::duplicate(membersShown));
auto members = result->entity();
members->add(object_ptr<Ui::BoxContentDivider>(members));
members->add(CreateSkipWidget(members));
auto button = AddActionButton(
members,
std::move(membersText),
rpl::single(true),
std::move(membersCallback),
nullptr)->entity();
const auto members = membersWrap->entity();
{
auto button = AddActionButton(
members,
std::move(membersText),
rpl::single(true),
std::move(membersCallback),
nullptr)->entity();
SetupAddChannelMember(controller, button, channel);
SetupAddChannelMember(controller, button, channel);
}
object_ptr<FloatingIcon>(
members,
st::infoIconMembers,
st::infoChannelMembersIconPosition);
members->add(CreateSkipWidget(members));
auto adminsShown = peer->session().changes().peerFlagsValue(
channel,
Data::PeerUpdate::Flag::Rights
) | rpl::map([=] { return channel->canViewAdmins(); });
auto adminsText = tr::lng_profile_administrators(
lt_count_decimal,
Info::Profile::MigratedOrMeValue(
channel
) | rpl::map(
Info::Profile::AdminsCountValue
) | rpl::flatten_latest() | tr::to_count());
auto adminsCallback = [=] {
ParticipantsBoxController::Start(
controller,
channel,
ParticipantsBoxController::Role::Admins);
};
const auto adminsWrap = result->entity()->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
result->entity(),
object_ptr<Ui::VerticalLayout>(result->entity())));
adminsWrap->setDuration(
st::infoSlideDuration
)->toggleOn(rpl::duplicate(adminsShown));
const auto admins = adminsWrap->entity();
AddActionButton(
admins,
std::move(adminsText),
rpl::single(true),
std::move(adminsCallback),
nullptr);
object_ptr<FloatingIcon>(
admins,
st::menuIconAdmin,
st::infoChannelAdminsIconPosition);
result->setDuration(st::infoSlideDuration)->toggleOn(
rpl::combine(
std::move(membersShown),
std::move(adminsShown)
) | rpl::map(rpl::mappers::_1 || rpl::mappers::_2));
result->entity()->add(CreateSkipWidget(result));
return result;
}

View file

@ -43,7 +43,7 @@ object_ptr<Ui::RpWidget> SetupActions(
not_null<Ui::RpWidget*> parent,
not_null<PeerData*> peer);
object_ptr<Ui::RpWidget> SetupChannelMembers(
object_ptr<Ui::RpWidget> SetupChannelMembersAndManage(
not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent,
not_null<PeerData*> peer);

View file

@ -113,8 +113,14 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
if (_topic) {
return result;
}
if (auto members = SetupChannelMembers(_controller, result.data(), _peer)) {
result->add(std::move(members));
{
auto buttons = SetupChannelMembersAndManage(
_controller,
result.data(),
_peer);
if (buttons) {
result->add(std::move(buttons));
}
}
if (auto actions = SetupActions(_controller, result.data(), _peer)) {
result->add(object_ptr<Ui::BoxContentDivider>(result));