Added ability to hide subscription button in preview premium boxes.

This commit is contained in:
23rd 2023-12-17 12:58:47 +03:00
parent bce310d5c8
commit 8efbd7a1cb
2 changed files with 9 additions and 4 deletions

View file

@ -66,6 +66,7 @@ struct Descriptor {
bool fromSettings = false; bool fromSettings = false;
Fn<void()> hiddenCallback; Fn<void()> hiddenCallback;
Fn<void(not_null<Ui::BoxContent*>)> shownCallback; Fn<void(not_null<Ui::BoxContent*>)> shownCallback;
bool hideSubscriptionButton = false;
}; };
bool operator==(const Descriptor &a, const Descriptor &b) { bool operator==(const Descriptor &a, const Descriptor &b) {
@ -1025,7 +1026,8 @@ void PreviewBox(
state->preload(); state->preload();
} }
}; };
if (descriptor.fromSettings && show->session().premium()) { if ((descriptor.fromSettings && show->session().premium())
|| descriptor.hideSubscriptionButton) {
box->setShowFinishedCallback(showFinished); box->setShowFinishedCallback(showFinished);
box->addButton(tr::lng_close(), [=] { box->closeBox(); }); box->addButton(tr::lng_close(), [=] { box->closeBox(); });
} else { } else {
@ -1151,7 +1153,7 @@ void DecorateListPromoBox(
box->boxClosing() | rpl::start_with_next(hidden, box->lifetime()); box->boxClosing() | rpl::start_with_next(hidden, box->lifetime());
} }
if (session->premium()) { if (session->premium() || descriptor.hideSubscriptionButton) {
box->addButton(tr::lng_close(), [=] { box->addButton(tr::lng_close(), [=] {
box->closeBox(); box->closeBox();
}); });
@ -1286,10 +1288,12 @@ void ShowPremiumPreviewBox(
void ShowPremiumPreviewBox( void ShowPremiumPreviewBox(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
PremiumPreview section, PremiumPreview section,
Fn<void(not_null<Ui::BoxContent*>)> shown) { Fn<void(not_null<Ui::BoxContent*>)> shown,
bool hideSubscriptionButton) {
Show(std::move(show), Descriptor{ Show(std::move(show), Descriptor{
.section = section, .section = section,
.shownCallback = std::move(shown), .shownCallback = std::move(shown),
.hideSubscriptionButton = hideSubscriptionButton,
}); });
} }

View file

@ -73,7 +73,8 @@ void ShowPremiumPreviewBox(
void ShowPremiumPreviewBox( void ShowPremiumPreviewBox(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
PremiumPreview section, PremiumPreview section,
Fn<void(not_null<Ui::BoxContent*>)> shown = nullptr); Fn<void(not_null<Ui::BoxContent*>)> shown = nullptr,
bool hideSubscriptionButton = false);
void ShowPremiumPreviewToBuy( void ShowPremiumPreviewToBuy(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,