From 97bd8659163110b9d418341d57059642562d8321 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 9 Nov 2023 15:50:26 +0300 Subject: [PATCH] Added terms to bottom of giveaway box for prepaid giveaways. --- .../info/boosts/create_giveaway_box.cpp | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp index 605c5681b..a38a34234 100644 --- a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp @@ -648,6 +648,24 @@ void CreateGiveawayBox( Settings::AddSkip(countriesContainer); } + const auto addTerms = [=](not_null c) { + auto terms = object_ptr( + c, + tr::lng_premium_gift_terms( + lt_link, + tr::lng_premium_gift_terms_link( + ) | rpl::map([](const QString &t) { + return Ui::Text::Link(t, 1); + }), + Ui::Text::WithEntities), + st::boxDividerLabel); + terms->setLink(1, std::make_shared([=] { + box->closeBox(); + Settings::ShowPremium(&peer->session(), QString()); + })); + c->add(std::move(terms)); + }; + { const auto dateContainer = randomWrap->entity()->add( object_ptr(randomWrap)); @@ -685,12 +703,29 @@ void CreateGiveawayBox( }); Settings::AddSkip(dateContainer); - Settings::AddDividerText( - dateContainer, - tr::lng_giveaway_date_about( - lt_count, - state->sliderValue.value() | tr::to_count())); - Settings::AddSkip(dateContainer); + if (prepaid) { + auto terms = object_ptr(dateContainer); + terms->add(object_ptr( + terms, + tr::lng_giveaway_date_about( + lt_count, + state->sliderValue.value() | tr::to_count()), + st::boxDividerLabel)); + Settings::AddSkip(terms.data()); + Settings::AddSkip(terms.data()); + addTerms(terms.data()); + dateContainer->add(object_ptr( + dateContainer, + std::move(terms), + st::settingsDividerLabelPadding)); + } else { + Settings::AddDividerText( + dateContainer, + tr::lng_giveaway_date_about( + lt_count, + state->sliderValue.value() | tr::to_count())); + Settings::AddSkip(dateContainer); + } } const auto durationGroup = std::make_shared(0); @@ -718,23 +753,11 @@ void CreateGiveawayBox( Settings::AddSkip(listOptions); - auto terms = object_ptr( - listOptions, - tr::lng_premium_gift_terms( - lt_link, - tr::lng_premium_gift_terms_link( - ) | rpl::map([](const QString &t) { - return Ui::Text::Link(t, 1); - }), - Ui::Text::WithEntities), - st::boxDividerLabel); - terms->setLink(1, std::make_shared([=] { - box->closeBox(); - Settings::ShowPremium(&peer->session(), QString()); - })); + auto termsContainer = object_ptr(listOptions); + addTerms(termsContainer.data()); listOptions->add(object_ptr( listOptions, - std::move(terms), + std::move(termsContainer), st::settingsDividerLabelPadding)); box->verticalLayout()->resizeToWidth(box->width());