Improve premium preview boxes close buttons.
This commit is contained in:
parent
629574685e
commit
6260f258bb
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_message_reactions.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/data_streaming.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_domain.h" // kMaxAccounts
|
||||
|
@ -42,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "apiwrap.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
|
||||
|
@ -1241,6 +1243,15 @@ void PreviewBox(
|
|||
const auto outer = box->addRow(
|
||||
ChatBackPreview(box, size.height(), back),
|
||||
{});
|
||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
||||
box->verticalLayout().get(),
|
||||
st::settingsPremiumTopBarClose);
|
||||
box->verticalLayout()->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
close->moveToRight(0, 0, width);
|
||||
}, close->lifetime());
|
||||
close->setClickedCallback([=] { box->closeBox(); });
|
||||
|
||||
struct Hiding {
|
||||
not_null<Ui::RpWidget*> widget;
|
||||
int leftFrom = 0;
|
||||
|
@ -1304,16 +1315,8 @@ void PreviewBox(
|
|||
switch (descriptor.section) {
|
||||
case PremiumPreview::Stickers:
|
||||
state->content = media
|
||||
? StickerPreview(
|
||||
outer,
|
||||
controller,
|
||||
media,
|
||||
state->preload)
|
||||
: GenericPreview(
|
||||
outer,
|
||||
controller,
|
||||
descriptor.section,
|
||||
state->preload);
|
||||
? StickerPreview(outer, controller, media, state->preload)
|
||||
: StickersPreview(outer, controller, state->preload);
|
||||
break;
|
||||
case PremiumPreview::Reactions:
|
||||
state->content = ReactionsPreview(
|
||||
|
@ -1437,6 +1440,9 @@ void PreviewBox(
|
|||
box->addRow(
|
||||
CreateSwitch(box->verticalLayout(), &state->selected),
|
||||
st::premiumDotsMargin);
|
||||
if (descriptor.fromSettings && controller->session().premium()) {
|
||||
box->addButton(tr::lng_close(), [=] { box->closeBox(); });
|
||||
} else {
|
||||
box->setStyle(st::premiumPreviewBox);
|
||||
const auto buttonPadding = st::premiumPreviewBox.buttonPadding;
|
||||
const auto width = size.width()
|
||||
|
@ -1471,6 +1477,15 @@ void PreviewBox(
|
|||
raw->startGlareAnimation();
|
||||
});
|
||||
box->addButton(std::move(button));
|
||||
}
|
||||
|
||||
if (descriptor.fromSettings) {
|
||||
Data::AmPremiumValue(
|
||||
&controller->session()
|
||||
) | rpl::skip(1) | rpl::start_with_next([=](bool premium) {
|
||||
box->closeBox();
|
||||
}, box->lifetime());
|
||||
}
|
||||
|
||||
if (const auto &hidden = descriptor.hiddenCallback) {
|
||||
box->boxClosing() | rpl::start_with_next(hidden, box->lifetime());
|
||||
|
|
|
@ -770,7 +770,14 @@ void Premium::setupContent() {
|
|||
}
|
||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
DoubledLimitsPreviewBox(box, &controller->session());
|
||||
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
if (controller->session().premium()) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
} else {
|
||||
const auto button = CreateSubscribeButton(
|
||||
controller,
|
||||
box,
|
||||
|
@ -795,6 +802,7 @@ void Premium::setupContent() {
|
|||
}, button->lifetime());
|
||||
box->addButton(
|
||||
object_ptr<Ui::AbstractButton>::fromRaw(button));
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1679da738b2739820287fbf810981c91de48b73d
|
||||
Subproject commit 3aa78fb00043e83bb000cec091bdbd93a8233794
|
Loading…
Reference in New Issue