mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Move gift_credits_box -> star_gift_box, strip old code.
This commit is contained in:
parent
3e63b40564
commit
d361d5f3b2
13 changed files with 33 additions and 881 deletions
|
@ -276,8 +276,6 @@ PRIVATE
|
||||||
boxes/edit_caption_box.h
|
boxes/edit_caption_box.h
|
||||||
boxes/edit_privacy_box.cpp
|
boxes/edit_privacy_box.cpp
|
||||||
boxes/edit_privacy_box.h
|
boxes/edit_privacy_box.h
|
||||||
boxes/gift_credits_box.cpp
|
|
||||||
boxes/gift_credits_box.h
|
|
||||||
boxes/gift_premium_box.cpp
|
boxes/gift_premium_box.cpp
|
||||||
boxes/gift_premium_box.h
|
boxes/gift_premium_box.h
|
||||||
boxes/language_box.cpp
|
boxes/language_box.cpp
|
||||||
|
@ -322,6 +320,8 @@ PRIVATE
|
||||||
boxes/sessions_box.h
|
boxes/sessions_box.h
|
||||||
boxes/share_box.cpp
|
boxes/share_box.cpp
|
||||||
boxes/share_box.h
|
boxes/share_box.h
|
||||||
|
boxes/star_gift_box.cpp
|
||||||
|
boxes/star_gift_box.h
|
||||||
boxes/sticker_set_box.cpp
|
boxes/sticker_set_box.cpp
|
||||||
boxes/sticker_set_box.h
|
boxes/sticker_set_box.h
|
||||||
boxes/stickers_box.cpp
|
boxes/stickers_box.cpp
|
||||||
|
|
|
@ -64,11 +64,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kUserpicsMax = size_t(3);
|
|
||||||
|
|
||||||
using GiftOption = Data::PremiumSubscriptionOption;
|
|
||||||
using GiftOptions = Data::PremiumSubscriptionOptions;
|
|
||||||
|
|
||||||
[[nodiscard]] QString CreateMessageLink(
|
[[nodiscard]] QString CreateMessageLink(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
|
@ -87,638 +82,6 @@ using GiftOptions = Data::PremiumSubscriptionOptions;
|
||||||
return QString();
|
return QString();
|
||||||
};
|
};
|
||||||
|
|
||||||
GiftOptions GiftOptionFromTL(const MTPDuserFull &data) {
|
|
||||||
auto result = GiftOptions();
|
|
||||||
const auto gifts = data.vpremium_gifts();
|
|
||||||
if (!gifts) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = Api::PremiumSubscriptionOptionsFromTL(gifts->v);
|
|
||||||
for (auto &option : result) {
|
|
||||||
option.costPerMonth = tr::lng_premium_gift_per(
|
|
||||||
tr::now,
|
|
||||||
lt_cost,
|
|
||||||
option.costPerMonth);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] Fn<TextWithEntities(TextWithEntities)> BoostsForGiftText(
|
|
||||||
const std::vector<not_null<UserData*>> users) {
|
|
||||||
Expects(!users.empty());
|
|
||||||
|
|
||||||
const auto session = &users.front()->session();
|
|
||||||
const auto emoji = Ui::Text::SingleCustomEmoji(
|
|
||||||
session->data().customEmojiManager().registerInternalEmoji(
|
|
||||||
st::premiumGiftsBoostIcon,
|
|
||||||
QMargins(0, st::premiumGiftsUserpicBadgeInner, 0, 0),
|
|
||||||
false));
|
|
||||||
|
|
||||||
return [=, count = users.size()](TextWithEntities text) {
|
|
||||||
text.append('\n');
|
|
||||||
text.append('\n');
|
|
||||||
text.append(tr::lng_premium_gifts_about_reward(
|
|
||||||
tr::now,
|
|
||||||
lt_count,
|
|
||||||
count * BoostsForGift(session),
|
|
||||||
lt_emoji,
|
|
||||||
emoji,
|
|
||||||
Ui::Text::RichLangValue));
|
|
||||||
return text;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
using TagUser1 = lngtag_user;
|
|
||||||
using TagUser2 = lngtag_second_user;
|
|
||||||
using TagUser3 = lngtag_name;
|
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> ComplexAboutLabel(
|
|
||||||
const std::vector<not_null<UserData*>> &users,
|
|
||||||
tr::phrase<TagUser1> phrase1,
|
|
||||||
tr::phrase<TagUser1, TagUser2> phrase2,
|
|
||||||
tr::phrase<TagUser1, TagUser2, TagUser3> phrase3,
|
|
||||||
tr::phrase<lngtag_count, TagUser1, TagUser2, TagUser3> phraseMore) {
|
|
||||||
Expects(!users.empty());
|
|
||||||
|
|
||||||
const auto count = users.size();
|
|
||||||
const auto nameValue = [&](not_null<UserData*> user) {
|
|
||||||
return user->session().changes().peerFlagsValue(
|
|
||||||
user,
|
|
||||||
Data::PeerUpdate::Flag::Name
|
|
||||||
) | rpl::map([=] { return TextWithEntities{ user->firstName }; });
|
|
||||||
};
|
|
||||||
if (count == 1) {
|
|
||||||
return phrase1(
|
|
||||||
lt_user,
|
|
||||||
nameValue(users.front()),
|
|
||||||
Ui::Text::RichLangValue);
|
|
||||||
} else if (count == 2) {
|
|
||||||
return phrase2(
|
|
||||||
lt_user,
|
|
||||||
nameValue(users.front()),
|
|
||||||
lt_second_user,
|
|
||||||
nameValue(users[1]),
|
|
||||||
Ui::Text::RichLangValue);
|
|
||||||
} else if (count == 3) {
|
|
||||||
return phrase3(
|
|
||||||
lt_user,
|
|
||||||
nameValue(users.front()),
|
|
||||||
lt_second_user,
|
|
||||||
nameValue(users[1]),
|
|
||||||
lt_name,
|
|
||||||
nameValue(users[2]),
|
|
||||||
Ui::Text::RichLangValue);
|
|
||||||
} else {
|
|
||||||
return phraseMore(
|
|
||||||
lt_count,
|
|
||||||
rpl::single(count - kUserpicsMax) | tr::to_count(),
|
|
||||||
lt_user,
|
|
||||||
nameValue(users.front()),
|
|
||||||
lt_second_user,
|
|
||||||
nameValue(users[1]),
|
|
||||||
lt_name,
|
|
||||||
nameValue(users[2]),
|
|
||||||
Ui::Text::RichLangValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] not_null<Ui::RpWidget*> CircleBadge(
|
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
const QString &text) {
|
|
||||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(parent.get());
|
|
||||||
|
|
||||||
const auto full = Rect(st::premiumGiftsUserpicBadgeSize);
|
|
||||||
const auto inner = full - Margins(st::premiumGiftsUserpicBadgeInner);
|
|
||||||
auto gradient = QLinearGradient(
|
|
||||||
QPointF(0, full.height()),
|
|
||||||
QPointF(full.width(), 0));
|
|
||||||
gradient.setStops(Ui::Premium::GiftGradientStops());
|
|
||||||
|
|
||||||
widget->paintRequest(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
auto p = QPainter(widget);
|
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.setBrush(st::boxBg);
|
|
||||||
p.drawEllipse(full);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.setBrush(gradient);
|
|
||||||
p.drawEllipse(inner);
|
|
||||||
p.setFont(st::premiumGiftsUserpicBadgeFont);
|
|
||||||
p.setPen(st::premiumButtonFg);
|
|
||||||
p.drawText(full, text, style::al_center);
|
|
||||||
}, widget->lifetime());
|
|
||||||
widget->resize(full.size());
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] not_null<Ui::RpWidget*> UserpicsContainer(
|
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
std::vector<not_null<UserData*>> users) {
|
|
||||||
Expects(!users.empty());
|
|
||||||
|
|
||||||
if (users.size() == 1) {
|
|
||||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
|
||||||
parent.get(),
|
|
||||||
users.front(),
|
|
||||||
st::defaultUserpicButton);
|
|
||||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
return userpic;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &singleSize = st::defaultUserpicButton.size;
|
|
||||||
|
|
||||||
const auto container = Ui::CreateChild<Ui::RpWidget>(parent.get());
|
|
||||||
const auto single = singleSize.width();
|
|
||||||
const auto shift = single - st::boostReplaceUserpicsShift;
|
|
||||||
const auto maxWidth = users.size() * (single - shift) + shift;
|
|
||||||
container->resize(maxWidth, singleSize.height());
|
|
||||||
container->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
|
|
||||||
const auto diff = (single - st::premiumGiftsUserpicButton.size.width())
|
|
||||||
/ 2;
|
|
||||||
for (auto i = 0; i < users.size(); i++) {
|
|
||||||
const auto bg = Ui::CreateChild<Ui::RpWidget>(container);
|
|
||||||
bg->resize(singleSize);
|
|
||||||
bg->paintRequest(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
auto p = QPainter(bg);
|
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.setBrush(st::boxBg);
|
|
||||||
p.drawEllipse(bg->rect());
|
|
||||||
}, bg->lifetime());
|
|
||||||
bg->moveToLeft(std::max(0, i * (single - shift)), 0);
|
|
||||||
|
|
||||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
|
||||||
bg,
|
|
||||||
users[i],
|
|
||||||
st::premiumGiftsUserpicButton);
|
|
||||||
userpic->moveToLeft(diff, diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftBox(
|
|
||||||
not_null<Ui::GenericBox*> box,
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<UserData*> user,
|
|
||||||
GiftOptions options) {
|
|
||||||
const auto boxWidth = st::boxWideWidth;
|
|
||||||
box->setWidth(boxWidth);
|
|
||||||
box->setNoContentMargin(true);
|
|
||||||
const auto buttonsParent = box->verticalLayout().get();
|
|
||||||
|
|
||||||
struct State {
|
|
||||||
rpl::event_stream<QString> buttonText;
|
|
||||||
};
|
|
||||||
const auto state = box->lifetime().make_state<State>();
|
|
||||||
|
|
||||||
const auto userpicPadding = st::premiumGiftUserpicPadding;
|
|
||||||
const auto top = box->addRow(object_ptr<Ui::FixedHeightWidget>(
|
|
||||||
buttonsParent,
|
|
||||||
userpicPadding.top()
|
|
||||||
+ userpicPadding.bottom()
|
|
||||||
+ st::defaultUserpicButton.size.height()));
|
|
||||||
|
|
||||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
|
||||||
const auto stars = box->lifetime().make_state<ColoredMiniStars>(
|
|
||||||
top,
|
|
||||||
true);
|
|
||||||
|
|
||||||
const auto userpic = UserpicsContainer(top, { user });
|
|
||||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
top->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
userpic->moveToLeft(
|
|
||||||
(width - userpic->width()) / 2,
|
|
||||||
userpicPadding.top());
|
|
||||||
|
|
||||||
const auto center = top->rect().center();
|
|
||||||
const auto size = QSize(
|
|
||||||
userpic->width() * Ui::Premium::MiniStars::kSizeFactor,
|
|
||||||
userpic->height());
|
|
||||||
const auto ministarsRect = QRect(
|
|
||||||
QPoint(center.x() - size.width(), center.y() - size.height()),
|
|
||||||
QPoint(center.x() + size.width(), center.y() + size.height()));
|
|
||||||
stars->setPosition(ministarsRect.topLeft());
|
|
||||||
stars->setSize(ministarsRect.size());
|
|
||||||
}, userpic->lifetime());
|
|
||||||
|
|
||||||
top->paintRequest(
|
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
|
||||||
auto p = QPainter(top);
|
|
||||||
|
|
||||||
p.fillRect(r, Qt::transparent);
|
|
||||||
stars->paint(p);
|
|
||||||
}, top->lifetime());
|
|
||||||
|
|
||||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
|
||||||
buttonsParent,
|
|
||||||
st::infoTopBarClose);
|
|
||||||
close->setClickedCallback([=] { box->closeBox(); });
|
|
||||||
|
|
||||||
buttonsParent->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
close->moveToRight(0, 0, width);
|
|
||||||
}, close->lifetime());
|
|
||||||
|
|
||||||
// Header.
|
|
||||||
const auto &padding = st::premiumGiftAboutPadding;
|
|
||||||
const auto available = boxWidth - padding.left() - padding.right();
|
|
||||||
const auto &stTitle = st::premiumPreviewAboutTitle;
|
|
||||||
auto titleLabel = object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
tr::lng_premium_gift_title(),
|
|
||||||
stTitle);
|
|
||||||
titleLabel->resizeToWidth(available);
|
|
||||||
box->addRow(
|
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
|
||||||
box,
|
|
||||||
std::move(titleLabel)),
|
|
||||||
st::premiumGiftTitlePadding);
|
|
||||||
|
|
||||||
auto textLabel = Ui::CreateLabelWithCustomEmoji(
|
|
||||||
box,
|
|
||||||
tr::lng_premium_gift_about(
|
|
||||||
lt_user,
|
|
||||||
user->session().changes().peerFlagsValue(
|
|
||||||
user,
|
|
||||||
Data::PeerUpdate::Flag::Name
|
|
||||||
) | rpl::map([=] { return TextWithEntities{ user->firstName }; }),
|
|
||||||
Ui::Text::RichLangValue
|
|
||||||
) | rpl::map(
|
|
||||||
BoostsForGiftText({ user })
|
|
||||||
),
|
|
||||||
{ .session = &user->session() },
|
|
||||||
st::premiumPreviewAbout);
|
|
||||||
textLabel->setTextColorOverride(stTitle.textFg->c);
|
|
||||||
textLabel->resizeToWidth(available);
|
|
||||||
box->addRow(
|
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(box, std::move(textLabel)),
|
|
||||||
padding);
|
|
||||||
|
|
||||||
// List.
|
|
||||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>();
|
|
||||||
const auto groupValueChangedCallback = [=](int value) {
|
|
||||||
Expects(value < options.size() && value >= 0);
|
|
||||||
auto text = tr::lng_premium_gift_button(
|
|
||||||
tr::now,
|
|
||||||
lt_cost,
|
|
||||||
options[value].costTotal);
|
|
||||||
state->buttonText.fire(std::move(text));
|
|
||||||
};
|
|
||||||
group->setChangedCallback(groupValueChangedCallback);
|
|
||||||
Ui::Premium::AddGiftOptions(
|
|
||||||
buttonsParent,
|
|
||||||
group,
|
|
||||||
options,
|
|
||||||
st::premiumGiftOption);
|
|
||||||
|
|
||||||
// Footer.
|
|
||||||
auto terms = object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
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::premiumGiftTerms);
|
|
||||||
terms->setLink(1, std::make_shared<LambdaClickHandler>([=] {
|
|
||||||
box->closeBox();
|
|
||||||
Settings::ShowPremium(&user->session(), QString());
|
|
||||||
}));
|
|
||||||
terms->resizeToWidth(available);
|
|
||||||
box->addRow(
|
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(box, std::move(terms)),
|
|
||||||
st::premiumGiftTermsPadding);
|
|
||||||
|
|
||||||
// Button.
|
|
||||||
const auto &stButton = st::premiumGiftBox;
|
|
||||||
box->setStyle(stButton);
|
|
||||||
auto raw = Settings::CreateSubscribeButton({
|
|
||||||
controller,
|
|
||||||
box,
|
|
||||||
[] { return u"gift"_q; },
|
|
||||||
state->buttonText.events(),
|
|
||||||
Ui::Premium::GiftGradientStops(),
|
|
||||||
[=] {
|
|
||||||
const auto value = group->current();
|
|
||||||
return (value < options.size() && value >= 0)
|
|
||||||
? options[value].botUrl
|
|
||||||
: QString();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
auto button = object_ptr<Ui::GradientButton>::fromRaw(raw);
|
|
||||||
button->resizeToWidth(boxWidth - rect::m::sum::h(stButton.buttonPadding));
|
|
||||||
box->setShowFinishedCallback([raw = button.data()] {
|
|
||||||
raw->startGlareAnimation();
|
|
||||||
});
|
|
||||||
box->addButton(std::move(button));
|
|
||||||
|
|
||||||
groupValueChangedCallback(0);
|
|
||||||
|
|
||||||
Data::PeerPremiumValue(
|
|
||||||
user
|
|
||||||
) | rpl::skip(1) | rpl::start_with_next([=] {
|
|
||||||
box->closeBox();
|
|
||||||
}, box->lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftsBox(
|
|
||||||
not_null<Ui::GenericBox*> box,
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
std::vector<not_null<UserData*>> users,
|
|
||||||
not_null<Api::PremiumGiftCodeOptions*> api,
|
|
||||||
const QString &ref) {
|
|
||||||
Expects(!users.empty());
|
|
||||||
|
|
||||||
const auto boxWidth = st::boxWideWidth;
|
|
||||||
box->setWidth(boxWidth);
|
|
||||||
box->setNoContentMargin(true);
|
|
||||||
const auto buttonsParent = box->verticalLayout().get();
|
|
||||||
const auto session = &users.front()->session();
|
|
||||||
|
|
||||||
struct State {
|
|
||||||
rpl::event_stream<QString> buttonText;
|
|
||||||
rpl::variable<bool> confirmButtonBusy = false;
|
|
||||||
rpl::variable<bool> isPaymentComplete = false;
|
|
||||||
};
|
|
||||||
const auto state = box->lifetime().make_state<State>();
|
|
||||||
|
|
||||||
const auto userpicPadding = st::premiumGiftUserpicPadding;
|
|
||||||
const auto top = box->addRow(object_ptr<Ui::FixedHeightWidget>(
|
|
||||||
buttonsParent,
|
|
||||||
userpicPadding.top()
|
|
||||||
+ userpicPadding.bottom()
|
|
||||||
+ st::defaultUserpicButton.size.height()));
|
|
||||||
|
|
||||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
|
||||||
const auto stars = box->lifetime().make_state<ColoredMiniStars>(
|
|
||||||
top,
|
|
||||||
true);
|
|
||||||
|
|
||||||
const auto maxWithUserpic = std::min(users.size(), kUserpicsMax);
|
|
||||||
const auto userpics = UserpicsContainer(
|
|
||||||
top,
|
|
||||||
{ users.begin(), users.begin() + maxWithUserpic });
|
|
||||||
top->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
userpics->moveToLeft(
|
|
||||||
(width - userpics->width()) / 2,
|
|
||||||
userpicPadding.top());
|
|
||||||
|
|
||||||
const auto center = top->rect().center();
|
|
||||||
const auto size = QSize(
|
|
||||||
userpics->width() * Ui::Premium::MiniStars::kSizeFactor,
|
|
||||||
userpics->height());
|
|
||||||
const auto ministarsRect = QRect(
|
|
||||||
QPoint(center.x() - size.width(), center.y() - size.height()),
|
|
||||||
QPoint(center.x() + size.width(), center.y() + size.height()));
|
|
||||||
stars->setPosition(ministarsRect.topLeft());
|
|
||||||
stars->setSize(ministarsRect.size());
|
|
||||||
}, userpics->lifetime());
|
|
||||||
if (const auto rest = users.size() - maxWithUserpic; rest > 0) {
|
|
||||||
const auto badge = CircleBadge(
|
|
||||||
userpics,
|
|
||||||
QChar('+') + QString::number(rest));
|
|
||||||
badge->moveToRight(0, userpics->height() - badge->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
top->paintRequest(
|
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
|
||||||
auto p = QPainter(top);
|
|
||||||
|
|
||||||
p.fillRect(r, Qt::transparent);
|
|
||||||
stars->paint(p);
|
|
||||||
}, top->lifetime());
|
|
||||||
|
|
||||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
|
||||||
buttonsParent,
|
|
||||||
st::infoTopBarClose);
|
|
||||||
close->setClickedCallback([=] { box->closeBox(); });
|
|
||||||
|
|
||||||
buttonsParent->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
close->moveToRight(0, 0, width);
|
|
||||||
}, close->lifetime());
|
|
||||||
|
|
||||||
// Header.
|
|
||||||
const auto &padding = st::premiumGiftAboutPadding;
|
|
||||||
const auto available = boxWidth - padding.left() - padding.right();
|
|
||||||
const auto &stTitle = st::premiumPreviewAboutTitle;
|
|
||||||
auto titleLabel = object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
rpl::conditional(
|
|
||||||
state->isPaymentComplete.value(),
|
|
||||||
tr::lng_premium_gifts_about_paid_title(),
|
|
||||||
tr::lng_premium_gift_title()),
|
|
||||||
stTitle);
|
|
||||||
titleLabel->resizeToWidth(available);
|
|
||||||
box->addRow(
|
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
|
||||||
box,
|
|
||||||
std::move(titleLabel)),
|
|
||||||
st::premiumGiftTitlePadding);
|
|
||||||
|
|
||||||
// About.
|
|
||||||
{
|
|
||||||
auto text = rpl::conditional(
|
|
||||||
state->isPaymentComplete.value(),
|
|
||||||
ComplexAboutLabel(
|
|
||||||
users,
|
|
||||||
tr::lng_premium_gifts_about_paid1,
|
|
||||||
tr::lng_premium_gifts_about_paid2,
|
|
||||||
tr::lng_premium_gifts_about_paid3,
|
|
||||||
tr::lng_premium_gifts_about_paid_more
|
|
||||||
) | rpl::map([count = users.size()](TextWithEntities text) {
|
|
||||||
text.append('\n');
|
|
||||||
text.append('\n');
|
|
||||||
text.append(tr::lng_premium_gifts_about_paid_below(
|
|
||||||
tr::now,
|
|
||||||
lt_count,
|
|
||||||
float64(count),
|
|
||||||
Ui::Text::RichLangValue));
|
|
||||||
return text;
|
|
||||||
}),
|
|
||||||
ComplexAboutLabel(
|
|
||||||
users,
|
|
||||||
tr::lng_premium_gifts_about_user1,
|
|
||||||
tr::lng_premium_gifts_about_user2,
|
|
||||||
tr::lng_premium_gifts_about_user3,
|
|
||||||
tr::lng_premium_gifts_about_user_more
|
|
||||||
) | rpl::map(BoostsForGiftText(users))
|
|
||||||
);
|
|
||||||
const auto label = box->addRow(
|
|
||||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
|
||||||
box,
|
|
||||||
Ui::CreateLabelWithCustomEmoji(
|
|
||||||
box,
|
|
||||||
std::move(text),
|
|
||||||
{ .session = session },
|
|
||||||
st::premiumPreviewAbout)),
|
|
||||||
padding)->entity();
|
|
||||||
label->setTextColorOverride(stTitle.textFg->c);
|
|
||||||
label->resizeToWidth(available);
|
|
||||||
}
|
|
||||||
|
|
||||||
// List.
|
|
||||||
const auto optionsContainer = buttonsParent->add(
|
|
||||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
|
||||||
buttonsParent,
|
|
||||||
object_ptr<Ui::VerticalLayout>(buttonsParent)));
|
|
||||||
const auto options = api->options(users.size());
|
|
||||||
const auto group = std::make_shared<Ui::RadiobuttonGroup>();
|
|
||||||
const auto groupValueChangedCallback = [=](int value) {
|
|
||||||
Expects(value < options.size() && value >= 0);
|
|
||||||
auto text = tr::lng_premium_gift_button(
|
|
||||||
tr::now,
|
|
||||||
lt_cost,
|
|
||||||
options[value].costTotal);
|
|
||||||
state->buttonText.fire(std::move(text));
|
|
||||||
};
|
|
||||||
group->setChangedCallback(groupValueChangedCallback);
|
|
||||||
Ui::Premium::AddGiftOptions(
|
|
||||||
optionsContainer->entity(),
|
|
||||||
group,
|
|
||||||
options,
|
|
||||||
st::premiumGiftOption);
|
|
||||||
optionsContainer->toggleOn(
|
|
||||||
state->isPaymentComplete.value() | rpl::map(!rpl::mappers::_1),
|
|
||||||
anim::type::instant);
|
|
||||||
|
|
||||||
// Summary.
|
|
||||||
{
|
|
||||||
{
|
|
||||||
// Will be hidden after payment.
|
|
||||||
const auto content = optionsContainer->entity();
|
|
||||||
Ui::AddSkip(content);
|
|
||||||
Ui::AddDivider(content);
|
|
||||||
Ui::AddSkip(content);
|
|
||||||
Ui::AddSubsectionTitle(
|
|
||||||
content,
|
|
||||||
tr::lng_premium_gifts_summary_subtitle());
|
|
||||||
}
|
|
||||||
const auto content = box->addRow(
|
|
||||||
object_ptr<Ui::VerticalLayout>(box),
|
|
||||||
{});
|
|
||||||
auto buttonCallback = [=](PremiumFeature section) {
|
|
||||||
stars->setPaused(true);
|
|
||||||
const auto previewBoxShown = [=](
|
|
||||||
not_null<Ui::BoxContent*> previewBox) {
|
|
||||||
previewBox->boxClosing(
|
|
||||||
) | rpl::start_with_next(crl::guard(box, [=] {
|
|
||||||
stars->setPaused(false);
|
|
||||||
}), previewBox->lifetime());
|
|
||||||
};
|
|
||||||
|
|
||||||
ShowPremiumPreviewBox(
|
|
||||||
controller->uiShow(),
|
|
||||||
section,
|
|
||||||
previewBoxShown,
|
|
||||||
true);
|
|
||||||
};
|
|
||||||
Settings::AddSummaryPremium(
|
|
||||||
content,
|
|
||||||
controller,
|
|
||||||
ref,
|
|
||||||
std::move(buttonCallback));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Footer.
|
|
||||||
{
|
|
||||||
box->addRow(
|
|
||||||
object_ptr<Ui::DividerLabel>(
|
|
||||||
box,
|
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
tr::lng_premium_gifts_terms(
|
|
||||||
lt_link,
|
|
||||||
tr::lng_payments_terms_link(
|
|
||||||
) | rpl::map([](const QString &t) {
|
|
||||||
using namespace Ui::Text;
|
|
||||||
return Link(t, u"https://telegram.org/tos"_q);
|
|
||||||
}),
|
|
||||||
lt_policy,
|
|
||||||
tr::lng_premium_gifts_terms_policy(
|
|
||||||
) | rpl::map([](const QString &t) {
|
|
||||||
using namespace Ui::Text;
|
|
||||||
return Link(t, u"https://telegram.org/privacy"_q);
|
|
||||||
}),
|
|
||||||
Ui::Text::RichLangValue),
|
|
||||||
st::premiumGiftTerms),
|
|
||||||
st::defaultBoxDividerLabelPadding),
|
|
||||||
{});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Button.
|
|
||||||
const auto &stButton = st::premiumGiftBox;
|
|
||||||
box->setStyle(stButton);
|
|
||||||
auto raw = Settings::CreateSubscribeButton({
|
|
||||||
controller,
|
|
||||||
box,
|
|
||||||
[=] { return ref; },
|
|
||||||
rpl::combine(
|
|
||||||
state->buttonText.events(),
|
|
||||||
state->confirmButtonBusy.value(),
|
|
||||||
state->isPaymentComplete.value()
|
|
||||||
) | rpl::map([](const QString &text, bool busy, bool paid) {
|
|
||||||
return busy
|
|
||||||
? QString()
|
|
||||||
: paid
|
|
||||||
? tr::lng_close(tr::now)
|
|
||||||
: text;
|
|
||||||
}),
|
|
||||||
Ui::Premium::GiftGradientStops(),
|
|
||||||
});
|
|
||||||
raw->setClickedCallback([=] {
|
|
||||||
if (state->confirmButtonBusy.current()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (state->isPaymentComplete.current()) {
|
|
||||||
return box->closeBox();
|
|
||||||
}
|
|
||||||
auto invoice = api->invoice(
|
|
||||||
users.size(),
|
|
||||||
api->monthsFromPreset(group->current()));
|
|
||||||
invoice.purpose = Payments::InvoicePremiumGiftCodeUsers{ users };
|
|
||||||
|
|
||||||
state->confirmButtonBusy = true;
|
|
||||||
const auto show = box->uiShow();
|
|
||||||
const auto weak = Ui::MakeWeak(box.get());
|
|
||||||
const auto done = [=](Payments::CheckoutResult result) {
|
|
||||||
if (const auto strong = weak.data()) {
|
|
||||||
strong->window()->setFocus();
|
|
||||||
state->confirmButtonBusy = false;
|
|
||||||
if (result == Payments::CheckoutResult::Paid) {
|
|
||||||
state->isPaymentComplete = true;
|
|
||||||
Ui::StartFireworks(box->parentWidget());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Payments::CheckoutProcess::Start(std::move(invoice), done);
|
|
||||||
});
|
|
||||||
{
|
|
||||||
using namespace Info::Statistics;
|
|
||||||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
|
||||||
raw,
|
|
||||||
raw->height() / 2);
|
|
||||||
AddChildToWidgetCenter(raw, loadingAnimation);
|
|
||||||
loadingAnimation->showOn(state->confirmButtonBusy.value());
|
|
||||||
}
|
|
||||||
auto button = object_ptr<Ui::GradientButton>::fromRaw(raw);
|
|
||||||
button->resizeToWidth(boxWidth - rect::m::sum::h(stButton.buttonPadding));
|
|
||||||
box->setShowFinishedCallback([raw = button.data()] {
|
|
||||||
raw->startGlareAnimation();
|
|
||||||
});
|
|
||||||
box->addButton(std::move(button));
|
|
||||||
|
|
||||||
groupValueChangedCallback(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] Data::GiftCodeLink MakeGiftCodeLink(
|
[[nodiscard]] Data::GiftCodeLink MakeGiftCodeLink(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &slug) {
|
const QString &slug) {
|
||||||
|
@ -996,180 +359,6 @@ void ShowAlreadyPremiumToast(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
GiftPremiumValidator::GiftPremiumValidator(
|
|
||||||
not_null<Window::SessionController*> controller)
|
|
||||||
: _controller(controller)
|
|
||||||
, _api(&_controller->session().mtp()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftPremiumValidator::cancel() {
|
|
||||||
_requestId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftPremiumValidator::showChoosePeerBox(const QString &ref) {
|
|
||||||
if (_manyGiftsLifetime) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using namespace Api;
|
|
||||||
const auto api = _manyGiftsLifetime.make_state<PremiumGiftCodeOptions>(
|
|
||||||
_controller->session().user());
|
|
||||||
const auto show = _controller->uiShow();
|
|
||||||
api->request(
|
|
||||||
) | rpl::start_with_error_done([=](const QString &error) {
|
|
||||||
show->showToast(error);
|
|
||||||
}, [=] {
|
|
||||||
const auto maxAmount = *ranges::max_element(api->availablePresets());
|
|
||||||
|
|
||||||
class Controller final : public ContactsBoxController {
|
|
||||||
public:
|
|
||||||
Controller(
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
Fn<bool(int)> checkErrorCallback)
|
|
||||||
: ContactsBoxController(session)
|
|
||||||
, _checkErrorCallback(std::move(checkErrorCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::unique_ptr<PeerListRow> createRow(
|
|
||||||
not_null<UserData*> user) override {
|
|
||||||
if (user->isSelf()
|
|
||||||
|| user->isBot()
|
|
||||||
|| user->isServiceUser()
|
|
||||||
|| user->isInaccessible()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return ContactsBoxController::createRow(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rowClicked(not_null<PeerListRow*> row) override {
|
|
||||||
const auto checked = !row->checked();
|
|
||||||
if (checked
|
|
||||||
&& _checkErrorCallback
|
|
||||||
&& _checkErrorCallback(
|
|
||||||
delegate()->peerListSelectedRowsCount())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
delegate()->peerListSetRowChecked(row, checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Fn<bool(int)> _checkErrorCallback;
|
|
||||||
|
|
||||||
};
|
|
||||||
auto initBox = [=](not_null<PeerListBox*> peersBox) {
|
|
||||||
const auto ignoreClose = peersBox->lifetime().make_state<bool>(0);
|
|
||||||
|
|
||||||
auto process = [=] {
|
|
||||||
const auto selected = peersBox->collectSelectedRows();
|
|
||||||
const auto users = ranges::views::all(
|
|
||||||
selected
|
|
||||||
) | ranges::views::transform([](not_null<PeerData*> p) {
|
|
||||||
return p->asUser();
|
|
||||||
}) | ranges::views::filter([](UserData *u) -> bool {
|
|
||||||
return u;
|
|
||||||
}) | ranges::to<std::vector<not_null<UserData*>>>();
|
|
||||||
if (users.empty()) {
|
|
||||||
show->showToast(
|
|
||||||
tr::lng_settings_gift_premium_choose(tr::now));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto giftBox = show->show(
|
|
||||||
Box(GiftsBox, _controller, users, api, ref));
|
|
||||||
giftBox->boxClosing(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
_manyGiftsLifetime.destroy();
|
|
||||||
}, giftBox->lifetime());
|
|
||||||
(*ignoreClose) = true;
|
|
||||||
peersBox->closeBox();
|
|
||||||
};
|
|
||||||
|
|
||||||
peersBox->setTitle(tr::lng_premium_gift_title());
|
|
||||||
peersBox->addButton(
|
|
||||||
tr::lng_settings_gift_premium_users_confirm(),
|
|
||||||
std::move(process));
|
|
||||||
peersBox->addButton(tr::lng_cancel(), [=] {
|
|
||||||
peersBox->closeBox();
|
|
||||||
});
|
|
||||||
peersBox->boxClosing(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
if (!(*ignoreClose)) {
|
|
||||||
_manyGiftsLifetime.destroy();
|
|
||||||
}
|
|
||||||
}, peersBox->lifetime());
|
|
||||||
};
|
|
||||||
|
|
||||||
auto listController = std::make_unique<Controller>(
|
|
||||||
&_controller->session(),
|
|
||||||
[=](int count) {
|
|
||||||
if (count <= maxAmount) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
show->showToast(tr::lng_settings_gift_premium_users_error(
|
|
||||||
tr::now,
|
|
||||||
lt_count,
|
|
||||||
maxAmount));
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
show->showBox(
|
|
||||||
Box<PeerListBox>(
|
|
||||||
std::move(listController),
|
|
||||||
std::move(initBox)),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
|
|
||||||
}, _manyGiftsLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftPremiumValidator::showChosenPeerBox(
|
|
||||||
not_null<UserData*> user,
|
|
||||||
const QString &ref) {
|
|
||||||
if (_manyGiftsLifetime) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using namespace Api;
|
|
||||||
const auto api = _manyGiftsLifetime.make_state<PremiumGiftCodeOptions>(
|
|
||||||
_controller->session().user());
|
|
||||||
const auto show = _controller->uiShow();
|
|
||||||
api->request(
|
|
||||||
) | rpl::start_with_error_done([=](const QString &error) {
|
|
||||||
show->showToast(error);
|
|
||||||
}, [=] {
|
|
||||||
const auto users = std::vector<not_null<UserData*>>{ user };
|
|
||||||
const auto giftBox = show->show(
|
|
||||||
Box(GiftsBox, _controller, users, api, ref));
|
|
||||||
giftBox->boxClosing(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
_manyGiftsLifetime.destroy();
|
|
||||||
}, giftBox->lifetime());
|
|
||||||
}, _manyGiftsLifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GiftPremiumValidator::showBox(not_null<UserData*> user) {
|
|
||||||
if (_requestId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_requestId = _api.request(MTPusers_GetFullUser(
|
|
||||||
user->inputUser
|
|
||||||
)).done([=](const MTPusers_UserFull &result) {
|
|
||||||
if (!_requestId) {
|
|
||||||
// Canceled.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_requestId = 0;
|
|
||||||
// _controller->api().processFullPeer(peer, result);
|
|
||||||
_controller->session().data().processUsers(result.data().vusers());
|
|
||||||
_controller->session().data().processChats(result.data().vchats());
|
|
||||||
|
|
||||||
const auto &fullUser = result.data().vfull_user().data();
|
|
||||||
auto options = GiftOptionFromTL(fullUser);
|
|
||||||
if (!options.empty()) {
|
|
||||||
_controller->show(
|
|
||||||
Box(GiftBox, _controller, user, std::move(options)));
|
|
||||||
}
|
|
||||||
}).fail([=] {
|
|
||||||
_requestId = 0;
|
|
||||||
}).send();
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<QString> GiftDurationValue(int months) {
|
rpl::producer<QString> GiftDurationValue(int months) {
|
||||||
return GiftDurationPhrase(months)(
|
return GiftDurationPhrase(months)(
|
||||||
lt_count,
|
lt_count,
|
||||||
|
|
|
@ -9,8 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
class UserData;
|
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct GiftCode;
|
struct GiftCode;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
@ -29,29 +27,9 @@ class VerticalLayout;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionController;
|
|
||||||
class SessionNavigation;
|
class SessionNavigation;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
class GiftPremiumValidator final {
|
|
||||||
public:
|
|
||||||
GiftPremiumValidator(not_null<Window::SessionController*> controller);
|
|
||||||
|
|
||||||
void showBox(not_null<UserData*> user);
|
|
||||||
void showChoosePeerBox(const QString &ref);
|
|
||||||
void showChosenPeerBox(not_null<UserData*> user, const QString &ref);
|
|
||||||
void cancel();
|
|
||||||
|
|
||||||
private:
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
|
||||||
MTP::Sender _api;
|
|
||||||
|
|
||||||
mtpRequestId _requestId = 0;
|
|
||||||
|
|
||||||
rpl::lifetime _manyGiftsLifetime;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<QString> GiftDurationValue(int months);
|
[[nodiscard]] rpl::producer<QString> GiftDurationValue(int months);
|
||||||
[[nodiscard]] QString GiftDuration(int months);
|
[[nodiscard]] QString GiftDuration(int months);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
|
||||||
For license and copyright information please follow this link:
|
For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/gift_credits_box.h"
|
#include "boxes/star_gift_box.h"
|
||||||
|
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
|
@ -1254,7 +1254,7 @@ void GiftBox(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ShowGiftCreditsBox(
|
void ChooseStarGiftRecipient(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
Fn<void()> gifted) {
|
Fn<void()> gifted) {
|
||||||
|
|
||||||
|
@ -1292,15 +1292,21 @@ void ShowGiftCreditsBox(
|
||||||
peersBox->addButton(tr::lng_cancel(), [=] { peersBox->closeBox(); });
|
peersBox->addButton(tr::lng_cancel(), [=] { peersBox->closeBox(); });
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto show = controller->uiShow();
|
|
||||||
auto listController = std::make_unique<Controller>(
|
auto listController = std::make_unique<Controller>(
|
||||||
&controller->session(),
|
&controller->session(),
|
||||||
[=](not_null<PeerData*> peer) {
|
[=](not_null<PeerData*> peer) {
|
||||||
show->showBox(Box(GiftBox, controller, peer, gifted));
|
ShowStarGiftBox(controller, peer, gifted);
|
||||||
});
|
});
|
||||||
show->showBox(
|
controller->show(
|
||||||
Box<PeerListBox>(std::move(listController), std::move(initBox)),
|
Box<PeerListBox>(std::move(listController), std::move(initBox)),
|
||||||
LayerOption::KeepOther);
|
LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowStarGiftBox(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
Fn<void()> gifted) {
|
||||||
|
controller->show(Box(GiftBox, controller, peer, gifted));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
|
@ -13,8 +13,13 @@ class SessionController;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
void ShowGiftCreditsBox(
|
void ChooseStarGiftRecipient(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
Fn<void()> gifted);
|
Fn<void()> gifted);
|
||||||
|
|
||||||
|
void ShowStarGiftBox(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
Fn<void()> gifted);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
|
@ -27,10 +27,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "payments/payments_non_panel_process.h"
|
#include "payments/payments_non_panel_process.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
#include "boxes/connection_box.h"
|
#include "boxes/connection_box.h"
|
||||||
|
#include "boxes/gift_premium_box.h"
|
||||||
#include "boxes/edit_privacy_box.h"
|
#include "boxes/edit_privacy_box.h"
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
#include "boxes/sessions_box.h"
|
#include "boxes/sessions_box.h"
|
||||||
|
#include "boxes/star_gift_box.h"
|
||||||
#include "boxes/language_box.h"
|
#include "boxes/language_box.h"
|
||||||
#include "passport/passport_form_controller.h"
|
#include "passport/passport_form_controller.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -1131,10 +1133,7 @@ bool ResolvePremiumMultigift(
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto params = url_parse_params(
|
Ui::ChooseStarGiftRecipient(controller, [] {});
|
||||||
match->captured(1).mid(1),
|
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
|
||||||
controller->showGiftPremiumsBox(params.value(u"ref"_q, u"gift_url"_q));
|
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "history/view/history_view_view_button.h"
|
#include "history/view/history_view_view_button.h"
|
||||||
|
|
||||||
|
#include "boxes/gift_premium_box.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peers/edit_contact_box.h"
|
#include "boxes/peers/edit_contact_box.h"
|
||||||
#include "boxes/report_messages_box.h"
|
#include "boxes/report_messages_box.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
|
#include "boxes/star_gift_box.h"
|
||||||
#include "boxes/translate_box.h"
|
#include "boxes/translate_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -705,7 +706,7 @@ base::options::toggle ShowPeerIdBelowAbout({
|
||||||
|
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
if (!button->isDisabled()) {
|
if (!button->isDisabled()) {
|
||||||
controller->showGiftPremiumsBox(user, u"birthday"_q);
|
Ui::ShowStarGiftBox(controller, user, [] {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_credits.h"
|
#include "settings/settings_credits.h"
|
||||||
|
|
||||||
#include "api/api_credits.h"
|
#include "api/api_credits.h"
|
||||||
#include "boxes/gift_credits_box.h"
|
#include "boxes/star_gift_box.h"
|
||||||
#include "boxes/gift_premium_box.h"
|
#include "boxes/gift_premium_box.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "data/components/credits.h"
|
#include "data/components/credits.h"
|
||||||
|
@ -69,7 +69,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupContent();
|
void setupContent();
|
||||||
void setupOptions(not_null<Ui::VerticalLayout*> container);
|
|
||||||
void setupHistory(not_null<Ui::VerticalLayout*> container);
|
void setupHistory(not_null<Ui::VerticalLayout*> container);
|
||||||
void setupSubscriptions(not_null<Ui::VerticalLayout*> container);
|
void setupSubscriptions(not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
|
@ -361,7 +360,7 @@ void Credits::setupContent() {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddDivider(content);
|
Ui::AddDivider(content);
|
||||||
giftButton->setClickedCallback([=] {
|
giftButton->setClickedCallback([=] {
|
||||||
Ui::ShowGiftCreditsBox(_controller, paid);
|
Ui::ChooseStarGiftRecipient(_controller, paid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/language_box.h"
|
#include "boxes/language_box.h"
|
||||||
#include "boxes/username_box.h"
|
#include "boxes/username_box.h"
|
||||||
#include "boxes/about_box.h"
|
#include "boxes/about_box.h"
|
||||||
#include "boxes/gift_credits_box.h"
|
#include "boxes/star_gift_box.h"
|
||||||
#include "ui/basic_click_handlers.h"
|
#include "ui/basic_click_handlers.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
@ -528,8 +528,7 @@ void SetupPremium(
|
||||||
{ .icon = &st::menuIconGiftPremium }
|
{ .icon = &st::menuIconGiftPremium }
|
||||||
);
|
);
|
||||||
button->addClickHandler([=] {
|
button->addClickHandler([=] {
|
||||||
Ui::ShowGiftCreditsBox(controller, [=] {
|
Ui::ChooseStarGiftRecipient(controller, [] {});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ui::AddSkip(container);
|
Ui::AddSkip(container);
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_report.h"
|
#include "api/api_report.h"
|
||||||
#include "menu/menu_check_item.h"
|
#include "menu/menu_check_item.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
|
#include "boxes/star_gift_box.h"
|
||||||
#include "chat_helpers/compose/compose_show.h"
|
#include "chat_helpers/compose/compose_show.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/share_message_phrase_factory.h"
|
#include "chat_helpers/share_message_phrase_factory.h"
|
||||||
|
@ -1239,7 +1240,7 @@ void Filler::addGiftPremium() {
|
||||||
|
|
||||||
const auto navigation = _controller;
|
const auto navigation = _controller;
|
||||||
_addAction(tr::lng_profile_gift_premium(tr::now), [=] {
|
_addAction(tr::lng_profile_gift_premium(tr::now), [=] {
|
||||||
navigation->showGiftPremiumBox(user);
|
Ui::ChooseStarGiftRecipient(navigation, [] {});
|
||||||
}, &st::menuIconGiftPremium);
|
}, &st::menuIconGiftPremium);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1245,8 +1245,7 @@ SessionController::SessionController(
|
||||||
, _activeChatsFilter(session->data().chatsFilters().defaultId())
|
, _activeChatsFilter(session->data().chatsFilters().defaultId())
|
||||||
, _openedFolder(window->id().folder())
|
, _openedFolder(window->id().folder())
|
||||||
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
||||||
, _chatStyle(std::make_unique<Ui::ChatStyle>(session->colorIndicesValue()))
|
, _chatStyle(std::make_unique<Ui::ChatStyle>(session->colorIndicesValue())) {
|
||||||
, _giftPremiumValidator(this) {
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
_chatStyleTheme = _defaultChatTheme;
|
_chatStyleTheme = _defaultChatTheme;
|
||||||
|
@ -1470,24 +1469,6 @@ void SessionController::showEditPeerBox(PeerData *peer) {
|
||||||
session().api().requestFullPeer(peer);
|
session().api().requestFullPeer(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::showGiftPremiumBox(UserData *user) {
|
|
||||||
if (user) {
|
|
||||||
_giftPremiumValidator.showBox(user);
|
|
||||||
} else {
|
|
||||||
_giftPremiumValidator.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionController::showGiftPremiumsBox(const QString &ref) {
|
|
||||||
_giftPremiumValidator.showChoosePeerBox(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionController::showGiftPremiumsBox(
|
|
||||||
not_null<UserData*> user,
|
|
||||||
const QString &ref) {
|
|
||||||
_giftPremiumValidator.showChosenPeerBox(user, ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionController::init() {
|
void SessionController::init() {
|
||||||
if (session().supportMode()) {
|
if (session().supportMode()) {
|
||||||
session().supportHelper().registerWindow(this);
|
session().supportHelper().registerWindow(this);
|
||||||
|
|
|
@ -8,11 +8,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "boxes/gift_premium_box.h" // GiftPremiumValidator.
|
|
||||||
#include "chat_helpers/compose/compose_show.h"
|
#include "chat_helpers/compose/compose_show.h"
|
||||||
#include "data/data_chat_participant_status.h"
|
#include "data/data_chat_participant_status.h"
|
||||||
#include "data/data_report.h"
|
#include "data/data_report.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
|
#include "mtproto/sender.h"
|
||||||
#include "settings/settings_type.h"
|
#include "settings/settings_type.h"
|
||||||
#include "window/window_adaptive.h"
|
#include "window/window_adaptive.h"
|
||||||
|
|
||||||
|
@ -407,11 +407,6 @@ public:
|
||||||
Dialogs::RowDescriptor from = {}) const;
|
Dialogs::RowDescriptor from = {}) const;
|
||||||
|
|
||||||
void showEditPeerBox(PeerData *peer);
|
void showEditPeerBox(PeerData *peer);
|
||||||
void showGiftPremiumBox(UserData *user);
|
|
||||||
void showGiftPremiumsBox(const QString &ref);
|
|
||||||
|
|
||||||
// Single user gift as if was selected in multiple recipients chooser.
|
|
||||||
void showGiftPremiumsBox(not_null<UserData*> user, const QString &ref);
|
|
||||||
|
|
||||||
void enableGifPauseReason(GifPauseReason reason);
|
void enableGifPauseReason(GifPauseReason reason);
|
||||||
void disableGifPauseReason(GifPauseReason reason);
|
void disableGifPauseReason(GifPauseReason reason);
|
||||||
|
@ -735,8 +730,6 @@ private:
|
||||||
|
|
||||||
base::has_weak_ptr _storyOpenGuard;
|
base::has_weak_ptr _storyOpenGuard;
|
||||||
|
|
||||||
GiftPremiumValidator _giftPremiumValidator;
|
|
||||||
|
|
||||||
QString _premiumRef;
|
QString _premiumRef;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
Loading…
Add table
Reference in a new issue