Added support for credits gift options to list of credit options.

This commit is contained in:
23rd 2024-07-17 15:32:16 +03:00 committed by John Preston
parent 127f651d5e
commit 24b93a5eff
3 changed files with 10 additions and 4 deletions

View file

@ -289,7 +289,8 @@ void Credits::setupContent() {
Ui::StartFireworks(_parent); Ui::StartFireworks(_parent);
} }
}; };
FillCreditOptions(_controller->uiShow(), content, 0, paid); const auto self = _controller->session().user();
FillCreditOptions(_controller->uiShow(), content, self, 0, paid);
setupHistory(content); setupHistory(content);
Ui::ResizeFitChild(this, content); Ui::ResizeFitChild(this, content);

View file

@ -231,6 +231,7 @@ void AddViewMediaHandler(
void FillCreditOptions( void FillCreditOptions(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
int minimumCredits, int minimumCredits,
Fn<void()> paid) { Fn<void()> paid) {
const auto options = container->add( const auto options = container->add(
@ -351,8 +352,7 @@ void FillCreditOptions(
}; };
using ApiOptions = Api::CreditsTopupOptions; using ApiOptions = Api::CreditsTopupOptions;
const auto apiCredits = content->lifetime().make_state<ApiOptions>( const auto apiCredits = content->lifetime().make_state<ApiOptions>(peer);
show->session().user());
if (show->session().premiumPossible()) { if (show->session().premiumPossible()) {
apiCredits->request( apiCredits->request(
@ -864,7 +864,11 @@ void SmallBalanceBox(
})); }));
}(); }();
FillCreditOptions(show, box->verticalLayout(), creditsNeeded, done); {
const auto content = box->verticalLayout();
const auto self = show->session().user();
FillCreditOptions(show, content, self, creditsNeeded, done);
}
content->setMaximumHeight(st::creditsLowBalancePremiumCoverHeight); content->setMaximumHeight(st::creditsLowBalancePremiumCoverHeight);
content->setMinimumHeight(st::infoLayerTopBarHeight); content->setMinimumHeight(st::infoLayerTopBarHeight);

View file

@ -35,6 +35,7 @@ namespace Settings {
void FillCreditOptions( void FillCreditOptions(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
int minCredits, int minCredits,
Fn<void()> paid); Fn<void()> paid);