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);
}
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) {
const auto box = Ui::show(
Box<EditPeerPermissionsBox>(peer),
@ -258,8 +271,8 @@ object_ptr<Ui::VerticalLayout> 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<Ui::RpWidget> 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<Ui::SlideWrap<Ui::VerticalLayout>>(
_wrap,
@ -556,7 +569,8 @@ void Controller::fillSignaturesButton() {
void Controller::fillHistoryVisibilityButton() {
Expects(_controls.buttonsLayout != nullptr);
const auto wrapLayout = _controls.buttonsLayout->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
const auto wrapLayout = _controls.buttonsLayout->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_controls.buttonsLayout,
object_ptr<Ui::VerticalLayout>(_controls.buttonsLayout),
st::boxOptionListPadding)); // Empty margins.
@ -569,7 +583,8 @@ void Controller::fillHistoryVisibilityButton() {
? HistoryVisibility::Hidden
: 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) {
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);
}
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() {

View File

@ -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);