From 4148099115a6c3e7e235d1159df0f936655a2699 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 19 Mar 2019 17:45:28 +0300 Subject: [PATCH] Redesigned Delete Button in EditPeerInfoBox. --- .../boxes/peers/edit_peer_info_box.cpp | 73 +++++++++++++++---- Telegram/SourceFiles/info/info.style | 11 +++ 2 files changed, 70 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 4cd1eec687..9af937ab53 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -103,6 +103,19 @@ Info::Profile::Button *AddButtonWithText( nullptr); } +Info::Profile::Button *AddButtonDelete( + not_null parent, + rpl::producer &&text, + Fn callback) { + return EditPeerInfoBox::CreateButton( + parent, + std::move(text), + rpl::single(QString()), + std::move(callback), + st::manageDeleteGroupButton, + nullptr); +} + void ShowEditPermissions(not_null peer) { const auto box = Ui::show( Box(peer), @@ -258,8 +271,8 @@ object_ptr Controller::createContent() { _wrap->add(createPhotoAndTitleEdit()); _wrap->add(createDescriptionEdit()); _wrap->add(createManageGroupButtons()); - _wrap->add(createStickersEdit()); - _wrap->add(createDeleteButton()); + // _wrap->add(createStickersEdit()); + // _wrap->add(createDeleteButton()); return result; } @@ -403,9 +416,9 @@ object_ptr Controller::createStickersEdit() { Expects(_wrap != nullptr); const auto channel = _peer->asChannel(); - if (!channel || !channel->canEditStickers()) { - return nullptr; - } + // if (!channel || !channel->canEditStickers()) { + // return nullptr; + // } auto result = object_ptr>( _wrap, @@ -556,10 +569,11 @@ void Controller::fillSignaturesButton() { void Controller::fillHistoryVisibilityButton() { Expects(_controls.buttonsLayout != nullptr); - const auto wrapLayout = _controls.buttonsLayout->add(object_ptr>( - _controls.buttonsLayout, - object_ptr(_controls.buttonsLayout), - st::boxOptionListPadding)); // Empty margins. + const auto wrapLayout = _controls.buttonsLayout->add( + object_ptr>( + _controls.buttonsLayout, + object_ptr(_controls.buttonsLayout), + st::boxOptionListPadding)); // Empty margins. _controls.historyVisibilityWrap = wrapLayout; const auto channel = _peer->asChannel(); @@ -569,7 +583,8 @@ void Controller::fillHistoryVisibilityButton() { ? HistoryVisibility::Hidden : HistoryVisibility::Visible; - const auto updateHistoryVisibility = std::make_shared>(); + const auto updateHistoryVisibility = + std::make_shared>(); const auto boxCallback = [=](HistoryVisibility checked) { updateHistoryVisibility->fire(std::move(checked)); @@ -617,8 +632,10 @@ void Controller::fillManageSection() { }(); const auto canEditInviteLink = [=] { return isChannel - ? (channel->amCreator() || (channel->adminRights() & ChatAdminRight::f_invite_users)) - : (chat->amCreator() || (chat->adminRights() & ChatAdminRight::f_invite_users)); + ? (channel->amCreator() + || (channel->adminRights() & ChatAdminRight::f_invite_users)) + : (chat->amCreator() + || (chat->adminRights() & ChatAdminRight::f_invite_users)); }(); const auto canEditSignatures = [=] { return isChannel @@ -658,6 +675,18 @@ void Controller::fillManageSection() { : false; }(); + const auto canEditStickers = [=] { + // return true; + return isChannel + ? channel->canEditStickers() + : false; + }(); + const auto canDeleteChannel = [=] { + return isChannel + ? channel->canDelete() + : false; + }(); + AddSkip(_controls.buttonsLayout, 0); if (canEditUsername) { @@ -743,8 +772,24 @@ void Controller::fillManageSection() { st::infoIconRecentActions); } - AddSkip(_controls.buttonsLayout, - st::editPeerTopButtonsLayoutSkipCustomTop); + if (canEditStickers || canDeleteChannel) { + AddSkip(_controls.buttonsLayout, + st::editPeerTopButtonsLayoutSkipCustomTop); + } + + if (canEditStickers) { + _controls.buttonsLayout->add(createStickersEdit()); + } + + if (canDeleteChannel) { + AddButtonDelete( + _controls.buttonsLayout, + std::move(Lang::Viewer(_isGroup + ? lng_profile_delete_group + : lng_profile_delete_channel)), + [=]{ deleteWithConfirmation(); } + ); + } } void Controller::submitTitle() { diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 21ee4a7cd4..d21d6d4a2f 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -617,6 +617,17 @@ manageGroupTopButtonWithText: InfoProfileCountButton(manageGroupButton) { iconPosition: point(0px, 0px); } +manageDeleteGroupButton: InfoProfileCountButton(manageGroupTopButtonWithText) { + button: InfoProfileButton(infoProfileButton) { + padding: margins(25px, 11px, 24px, 8px); + font: font(14px); + textFg: attentionButtonFg; + textFgOver: attentionButtonFg; + } + labelPosition: point(22px, 11px); + iconPosition: point(0px, 0px); +} + editPeerSkip: 7px; editPeerHistoryVisibilityMargins: margins(15px, 0px, 20px, 16px);