mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-03 12:58:11 +00:00
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,40 +1440,52 @@ void PreviewBox(
|
||||
box->addRow(
|
||||
CreateSwitch(box->verticalLayout(), &state->selected),
|
||||
st::premiumDotsMargin);
|
||||
box->setStyle(st::premiumPreviewBox);
|
||||
const auto buttonPadding = st::premiumPreviewBox.buttonPadding;
|
||||
const auto width = size.width()
|
||||
- buttonPadding.left()
|
||||
- buttonPadding.right();
|
||||
const auto computeRef = [=] {
|
||||
return Settings::LookupPremiumRef(state->selected.current());
|
||||
};
|
||||
auto unlock = state->selected.value(
|
||||
) | rpl::map([=](PremiumPreview section) {
|
||||
return (section == PremiumPreview::Reactions)
|
||||
? tr::lng_premium_unlock_reactions()
|
||||
: (section == PremiumPreview::Stickers)
|
||||
? tr::lng_premium_unlock_stickers()
|
||||
: tr::lng_premium_more_about();
|
||||
}) | rpl::flatten_latest();
|
||||
auto button = descriptor.fromSettings
|
||||
? object_ptr<Ui::GradientButton>::fromRaw(
|
||||
Settings::CreateSubscribeButton(controller, box, computeRef))
|
||||
: CreateUnlockButton(box, std::move(unlock));
|
||||
button->resizeToWidth(width);
|
||||
button->setClickedCallback([=] {
|
||||
Settings::ShowPremium(
|
||||
controller,
|
||||
Settings::LookupPremiumRef(state->selected.current()));
|
||||
});
|
||||
box->setShowFinishedCallback([=, raw = button.data()] {
|
||||
state->showFinished = true;
|
||||
if (base::take(state->preloadScheduled)) {
|
||||
state->preload();
|
||||
}
|
||||
raw->startGlareAnimation();
|
||||
});
|
||||
box->addButton(std::move(button));
|
||||
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()
|
||||
- buttonPadding.left()
|
||||
- buttonPadding.right();
|
||||
const auto computeRef = [=] {
|
||||
return Settings::LookupPremiumRef(state->selected.current());
|
||||
};
|
||||
auto unlock = state->selected.value(
|
||||
) | rpl::map([=](PremiumPreview section) {
|
||||
return (section == PremiumPreview::Reactions)
|
||||
? tr::lng_premium_unlock_reactions()
|
||||
: (section == PremiumPreview::Stickers)
|
||||
? tr::lng_premium_unlock_stickers()
|
||||
: tr::lng_premium_more_about();
|
||||
}) | rpl::flatten_latest();
|
||||
auto button = descriptor.fromSettings
|
||||
? object_ptr<Ui::GradientButton>::fromRaw(
|
||||
Settings::CreateSubscribeButton(controller, box, computeRef))
|
||||
: CreateUnlockButton(box, std::move(unlock));
|
||||
button->resizeToWidth(width);
|
||||
button->setClickedCallback([=] {
|
||||
Settings::ShowPremium(
|
||||
controller,
|
||||
Settings::LookupPremiumRef(state->selected.current()));
|
||||
});
|
||||
box->setShowFinishedCallback([=, raw = button.data()] {
|
||||
state->showFinished = true;
|
||||
if (base::take(state->preloadScheduled)) {
|
||||
state->preload();
|
||||
}
|
||||
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,31 +770,39 @@ void Premium::setupContent() {
|
||||
}
|
||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
DoubledLimitsPreviewBox(box, &controller->session());
|
||||
|
||||
const auto button = CreateSubscribeButton(
|
||||
controller,
|
||||
box,
|
||||
[] { return u"double_limits"_q; });
|
||||
|
||||
box->boxClosing(
|
||||
) | rpl::start_with_next(hidden, box->lifetime());
|
||||
|
||||
box->setShowFinishedCallback([=] {
|
||||
button->startGlareAnimation();
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
if (controller->session().premium()) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
} else {
|
||||
const auto button = CreateSubscribeButton(
|
||||
controller,
|
||||
box,
|
||||
[] { return u"double_limits"_q; });
|
||||
|
||||
box->setStyle(st::premiumPreviewDoubledLimitsBox);
|
||||
box->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
const auto &padding =
|
||||
st::premiumPreviewDoubledLimitsBox.buttonPadding;
|
||||
button->resizeToWidth(width
|
||||
- padding.left()
|
||||
- padding.right());
|
||||
button->moveToLeft(padding.left(), padding.top());
|
||||
}, button->lifetime());
|
||||
box->addButton(
|
||||
object_ptr<Ui::AbstractButton>::fromRaw(button));
|
||||
box->boxClosing(
|
||||
) | rpl::start_with_next(hidden, box->lifetime());
|
||||
|
||||
box->setShowFinishedCallback([=] {
|
||||
button->startGlareAnimation();
|
||||
});
|
||||
|
||||
box->setStyle(st::premiumPreviewDoubledLimitsBox);
|
||||
box->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
const auto &padding =
|
||||
st::premiumPreviewDoubledLimitsBox.buttonPadding;
|
||||
button->resizeToWidth(width
|
||||
- padding.left()
|
||||
- padding.right());
|
||||
button->moveToLeft(padding.left(), padding.top());
|
||||
}, button->lifetime());
|
||||
box->addButton(
|
||||
object_ptr<Ui::AbstractButton>::fromRaw(button));
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1679da738b2739820287fbf810981c91de48b73d
|
||||
Subproject commit 3aa78fb00043e83bb000cec091bdbd93a8233794
|
Loading…
Reference in New Issue
Block a user