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

View File

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