Improve group stickers choose process.

Allow to choose from featured if used has no his own sets.
Allow to choose group sticker set from group info box.
This commit is contained in:
John Preston 2017-11-22 13:03:36 +04:00
parent 542ba89f25
commit f6ba59ed14
5 changed files with 70 additions and 12 deletions

View File

@ -930,6 +930,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_stickers_group_set" = "Group sticker set";
"lng_stickers_remove_group_set" = "Remove group sticker set?";
"lng_stickers_group_from_your" = "Choose from your stickers";
"lng_stickers_group_from_featured" = "Choose from featured stickers";
"lng_in_dlg_photo" = "Photo";
"lng_in_dlg_video" = "Video";

View File

@ -34,6 +34,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "boxes/confirm_box.h"
#include "boxes/photo_crop_box.h"
#include "boxes/add_contact_box.h"
#include "boxes/stickers_box.h"
#include "mtproto/sender.h"
#include "lang/lang_keys.h"
#include "mainwidget.h"
@ -121,6 +122,7 @@ private:
object_ptr<Ui::RpWidget> createHistoryVisibilityEdit();
object_ptr<Ui::RpWidget> createSignaturesEdit();
object_ptr<Ui::RpWidget> createInvitesEdit();
object_ptr<Ui::RpWidget> createStickersEdit();
object_ptr<Ui::RpWidget> createDeleteButton();
void submitTitle();
@ -217,6 +219,7 @@ object_ptr<Ui::VerticalLayout> Controller::createContent() {
_wrap->add(createHistoryVisibilityEdit());
_wrap->add(createSignaturesEdit());
_wrap->add(createInvitesEdit());
_wrap->add(createStickersEdit());
_wrap->add(createDeleteButton());
_wrap->resizeToWidth(st::boxWideWidth);
@ -878,9 +881,6 @@ object_ptr<Ui::RpWidget> Controller::createInvitesEdit() {
container,
Lang::Viewer(lng_edit_group_who_invites),
st::editPeerSectionLabel));
container->add(object_ptr<Ui::FixedHeightWidget>(
container,
st::editPeerInvitesTopSkip));
_controls.invites = std::make_shared<Ui::RadioenumGroup<Invites>>(
_channel->anyoneCanAddMembers()
@ -891,7 +891,7 @@ object_ptr<Ui::RpWidget> Controller::createInvitesEdit() {
LangKey textKey) {
container->add(object_ptr<Ui::FixedHeightWidget>(
container,
st::editPeerInvitesSkip));
st::editPeerInvitesTopSkip + st::editPeerInvitesSkip));
container->add(object_ptr<Ui::Radioenum<Invites>>(
container,
_controls.invites,
@ -905,6 +905,49 @@ object_ptr<Ui::RpWidget> Controller::createInvitesEdit() {
addButton(
Invites::OnlyAdmins,
lng_edit_group_invites_only_admins);
container->add(object_ptr<Ui::FixedHeightWidget>(
container,
st::editPeerInvitesSkip));
return std::move(result);
}
object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
Expects(_wrap != nullptr);
if (!_channel->canEditStickers()) {
return nullptr;
}
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_wrap,
object_ptr<Ui::VerticalLayout>(_wrap),
st::editPeerInviteLinkMargins);
auto container = result->entity();
container->add(object_ptr<Ui::FlatLabel>(
container,
Lang::Viewer(lng_group_stickers),
st::editPeerSectionLabel));
container->add(object_ptr<Ui::FixedHeightWidget>(
container,
st::editPeerInviteLinkSkip));
container->add(object_ptr<Ui::FlatLabel>(
container,
Lang::Viewer(lng_group_stickers_description),
st::editPeerPrivacyLabel));
container->add(object_ptr<Ui::FixedHeightWidget>(
container,
st::editPeerInviteLinkSkip));
container->add(object_ptr<Ui::LinkButton>(
_wrap,
lang(lng_group_stickers_add),
st::editPeerInviteLinkButton)
)->addClickHandler([this] {
Ui::show(Box<StickersBox>(_channel), LayerOption::KeepOther);
});
return std::move(result);
}

View File

@ -704,6 +704,7 @@ void StickersBox::Inner::updateControlsGeometry() {
}
_megagroupDivider->setGeometryToLeft(0, top, width(), _megagroupDivider->height());
top += _megagroupDivider->height();
_megagroupSubTitle->resizeToNaturalWidth(width() - 2 * st::boxLayerTitlePosition.x());
_megagroupSubTitle->moveToLeft(st::boxLayerTitlePosition.x(), top + st::boxLayerTitlePosition.y());
}
}
@ -1370,9 +1371,13 @@ void StickersBox::Inner::rebuild() {
auto maxNameWidth = countMaxNameWidth();
clear();
auto &order = ([this]() -> const Stickers::Order & {
auto &order = ([&]() -> const Stickers::Order & {
if (_section == Section::Installed) {
return Auth().data().stickerSetsOrder();
auto &result = Auth().data().stickerSetsOrder();
if (_megagroupSet && result.empty()) {
return Auth().data().featuredStickerSetsOrder();
}
return result;
} else if (_section == Section::Featured) {
return Auth().data().featuredStickerSetsOrder();
}
@ -1382,7 +1387,13 @@ void StickersBox::Inner::rebuild() {
_animStartTimes.reserve(order.size() + 1);
auto &sets = Auth().data().stickerSets();
if (!_megagroupSet && _section == Section::Installed) {
if (_megagroupSet) {
auto usingFeatured = Auth().data().stickerSetsOrder().empty();
_megagroupSubTitle->setText(lang(usingFeatured
? lng_stickers_group_from_featured
: lng_stickers_group_from_your));
updateControlsGeometry();
} else if (_section == Section::Installed) {
auto cloudIt = sets.constFind(Stickers::CloudRecentSetId);
if (cloudIt != sets.cend() && !cloudIt->stickers.isEmpty()) {
rebuildAppendSet(cloudIt.value(), maxNameWidth);
@ -1419,6 +1430,7 @@ void StickersBox::Inner::setMinHeight(int newWidth, int minHeight) {
void StickersBox::Inner::updateSize(int newWidth) {
auto naturalHeight = _itemsTop + int(_rows.size()) * _rowHeight + st::membersMarginBottom;
resize(newWidth ? newWidth : width(), qMax(_minHeight, naturalHeight));
updateControlsGeometry();
checkLoadMore();
}

View File

@ -716,7 +716,9 @@ not_null<GifsListWidget*> TabbedSelector::gifs() const {
void TabbedSelector::setWidgetToScrollArea() {
auto inner = _scroll->setOwnedWidget(currentTab()->takeWidget());
inner->resizeToWidth(_scroll->width() - st::emojiScroll.width);
auto innerWidth = _scroll->width() - st::emojiScroll.width;
auto scrollHeight = _scroll->height();
inner->setMinimalHeight(innerWidth, scrollHeight);
inner->moveToLeft(0, 0);
inner->show();

View File

@ -589,7 +589,7 @@ editPeerInviteLink: FlatLabel(defaultFlatLabel) {
style: boxTextStyle;
}
editPeerInviteLinkButton: boxLinkButton;
editPeerUsernameMargins: margins(0px, 10px, 0px, 0px);
editPeerUsernameMargins: margins(0px, 10px, 0px, 13px);
editPeerUsernameGood: FlatLabel(defaultFlatLabel) {
textFg: boxTextFgGood;
style: boxTextStyle;
@ -599,9 +599,9 @@ editPeerUsernameError: FlatLabel(editPeerUsernameGood) {
}
editPeerUsernamePosition: point(0px, 10px);
editPeerInviteLinkSkip: 10px;
editPeerInviteLinkMargins: margins(23px, 10px, 14px, 0px);
editPeerSignaturesMargins: margins(23px, 16px, 23px, 8px);
editPeerInvitesMargins: margins(23px, 18px, 23px, 16px);
editPeerInviteLinkMargins: margins(23px, 10px, 14px, 16px);
editPeerSignaturesMargins: margins(23px, 10px, 23px, 16px);
editPeerInvitesMargins: margins(23px, 10px, 23px, 16px);
editPeerInvitesTopSkip: 10px;
editPeerInvitesSkip: 10px;