Redesigned Delete Button in EditPeerInfoBox.

This commit is contained in:
23rd 2019-03-19 17:45:28 +03:00 committed by John Preston
parent 5edf200157
commit 4148099115
2 changed files with 70 additions and 14 deletions

View File

@ -103,6 +103,19 @@ Info::Profile::Button *AddButtonWithText(
nullptr); nullptr);
} }
Info::Profile::Button *AddButtonDelete(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> &&text,
Fn<void()> callback) {
return EditPeerInfoBox::CreateButton(
parent,
std::move(text),
rpl::single(QString()),
std::move(callback),
st::manageDeleteGroupButton,
nullptr);
}
void ShowEditPermissions(not_null<PeerData*> peer) { void ShowEditPermissions(not_null<PeerData*> peer) {
const auto box = Ui::show( const auto box = Ui::show(
Box<EditPeerPermissionsBox>(peer), Box<EditPeerPermissionsBox>(peer),
@ -258,8 +271,8 @@ object_ptr<Ui::VerticalLayout> Controller::createContent() {
_wrap->add(createPhotoAndTitleEdit()); _wrap->add(createPhotoAndTitleEdit());
_wrap->add(createDescriptionEdit()); _wrap->add(createDescriptionEdit());
_wrap->add(createManageGroupButtons()); _wrap->add(createManageGroupButtons());
_wrap->add(createStickersEdit()); // _wrap->add(createStickersEdit());
_wrap->add(createDeleteButton()); // _wrap->add(createDeleteButton());
return result; return result;
} }
@ -403,9 +416,9 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
Expects(_wrap != nullptr); Expects(_wrap != nullptr);
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
if (!channel || !channel->canEditStickers()) { // if (!channel || !channel->canEditStickers()) {
return nullptr; // return nullptr;
} // }
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_wrap, _wrap,
@ -556,10 +569,11 @@ void Controller::fillSignaturesButton() {
void Controller::fillHistoryVisibilityButton() { void Controller::fillHistoryVisibilityButton() {
Expects(_controls.buttonsLayout != nullptr); Expects(_controls.buttonsLayout != nullptr);
const auto wrapLayout = _controls.buttonsLayout->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( const auto wrapLayout = _controls.buttonsLayout->add(
_controls.buttonsLayout, object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
object_ptr<Ui::VerticalLayout>(_controls.buttonsLayout), _controls.buttonsLayout,
st::boxOptionListPadding)); // Empty margins. object_ptr<Ui::VerticalLayout>(_controls.buttonsLayout),
st::boxOptionListPadding)); // Empty margins.
_controls.historyVisibilityWrap = wrapLayout; _controls.historyVisibilityWrap = wrapLayout;
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
@ -569,7 +583,8 @@ void Controller::fillHistoryVisibilityButton() {
? HistoryVisibility::Hidden ? HistoryVisibility::Hidden
: HistoryVisibility::Visible; : HistoryVisibility::Visible;
const auto updateHistoryVisibility = std::make_shared<rpl::event_stream<HistoryVisibility>>(); const auto updateHistoryVisibility =
std::make_shared<rpl::event_stream<HistoryVisibility>>();
const auto boxCallback = [=](HistoryVisibility checked) { const auto boxCallback = [=](HistoryVisibility checked) {
updateHistoryVisibility->fire(std::move(checked)); updateHistoryVisibility->fire(std::move(checked));
@ -617,8 +632,10 @@ void Controller::fillManageSection() {
}(); }();
const auto canEditInviteLink = [=] { const auto canEditInviteLink = [=] {
return isChannel return isChannel
? (channel->amCreator() || (channel->adminRights() & ChatAdminRight::f_invite_users)) ? (channel->amCreator()
: (chat->amCreator() || (chat->adminRights() & ChatAdminRight::f_invite_users)); || (channel->adminRights() & ChatAdminRight::f_invite_users))
: (chat->amCreator()
|| (chat->adminRights() & ChatAdminRight::f_invite_users));
}(); }();
const auto canEditSignatures = [=] { const auto canEditSignatures = [=] {
return isChannel return isChannel
@ -658,6 +675,18 @@ void Controller::fillManageSection() {
: false; : false;
}(); }();
const auto canEditStickers = [=] {
// return true;
return isChannel
? channel->canEditStickers()
: false;
}();
const auto canDeleteChannel = [=] {
return isChannel
? channel->canDelete()
: false;
}();
AddSkip(_controls.buttonsLayout, 0); AddSkip(_controls.buttonsLayout, 0);
if (canEditUsername) { if (canEditUsername) {
@ -743,8 +772,24 @@ void Controller::fillManageSection() {
st::infoIconRecentActions); st::infoIconRecentActions);
} }
AddSkip(_controls.buttonsLayout, if (canEditStickers || canDeleteChannel) {
st::editPeerTopButtonsLayoutSkipCustomTop); 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() { void Controller::submitTitle() {

View File

@ -617,6 +617,17 @@ manageGroupTopButtonWithText: InfoProfileCountButton(manageGroupButton) {
iconPosition: point(0px, 0px); 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; editPeerSkip: 7px;
editPeerHistoryVisibilityMargins: margins(15px, 0px, 20px, 16px); editPeerHistoryVisibilityMargins: margins(15px, 0px, 20px, 16px);