mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added complex description to top of gift box from settings.
This commit is contained in:
parent
ed9ecbd235
commit
bce310d5c8
2 changed files with 89 additions and 1 deletions
|
@ -2061,6 +2061,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_premium_gift_per" = "{cost} / month";
|
"lng_premium_gift_per" = "{cost} / month";
|
||||||
"lng_premium_gift_terms" = "You can review the list of features and terms of use for Telegram Premium {link}.";
|
"lng_premium_gift_terms" = "You can review the list of features and terms of use for Telegram Premium {link}.";
|
||||||
"lng_premium_gift_terms_link" = "here";
|
"lng_premium_gift_terms_link" = "here";
|
||||||
|
"lng_premium_gifts_about_user1" = "Give **{user}** access to exclusive features.";
|
||||||
|
"lng_premium_gifts_about_user2" = "Give **{user}** and **{second_user}** access to exclusive features.";
|
||||||
|
"lng_premium_gifts_about_user3" = "Give **{user}**, **{second_user}** and **{name}** access to exclusive features.";
|
||||||
|
"lng_premium_gifts_about_user_more#one" = "Give **{user}**, **{second_user}**, **{name}** and **{count}** more friend access to exclusive features.";
|
||||||
|
"lng_premium_gifts_about_user_more#other" = "Give **{user}**, **{second_user}**, **{name}** and **{count}** more friends access to exclusive features.";
|
||||||
|
"lng_premium_gifts_about_reward#one" = "You will receive {emoji}**{count}** boost.";
|
||||||
|
"lng_premium_gifts_about_reward#other" = "You will receive {emoji}**{count}** boosts.";
|
||||||
|
|
||||||
"lng_boost_channel_button" = "Boost Channel";
|
"lng_boost_channel_button" = "Boost Channel";
|
||||||
"lng_boost_again_button" = "Boost Again";
|
"lng_boost_again_button" = "Boost Again";
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "boxes/peer_list_controllers.h" // ContactsBoxController.
|
#include "boxes/peer_list_controllers.h" // ContactsBoxController.
|
||||||
#include "boxes/peers/prepare_short_info_box.h"
|
#include "boxes/peers/prepare_short_info_box.h"
|
||||||
|
#include "boxes/peers/replace_boost_box.h" // BoostsForGift.
|
||||||
#include "data/data_boosts.h"
|
#include "data/data_boosts.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
@ -56,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDiscountDivider = 5.;
|
constexpr auto kDiscountDivider = 5.;
|
||||||
|
constexpr auto kUserpicsMax = size_t(3);
|
||||||
|
|
||||||
using GiftOption = Data::SubscriptionOption;
|
using GiftOption = Data::SubscriptionOption;
|
||||||
using GiftOptions = Data::SubscriptionOptions;
|
using GiftOptions = Data::SubscriptionOptions;
|
||||||
|
@ -76,6 +78,65 @@ GiftOptions GiftOptionFromTL(const MTPDuserFull &data) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<TextWithEntities> ComplexAboutLabel(
|
||||||
|
const std::vector<not_null<UserData*>> &users) {
|
||||||
|
Expects(!users.empty());
|
||||||
|
|
||||||
|
const auto session = &users.front()->session();
|
||||||
|
const auto count = users.size();
|
||||||
|
const auto nameValue = [&](not_null<UserData*> user) {
|
||||||
|
return session->changes().peerFlagsValue(
|
||||||
|
user,
|
||||||
|
Data::PeerUpdate::Flag::Name
|
||||||
|
) | rpl::map([=] { return TextWithEntities{ user->firstName }; });
|
||||||
|
};
|
||||||
|
const auto addReward = [=](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,
|
||||||
|
TextWithEntities(),
|
||||||
|
Ui::Text::RichLangValue));
|
||||||
|
return text;
|
||||||
|
};
|
||||||
|
if (count == 1) {
|
||||||
|
return tr::lng_premium_gifts_about_user1(
|
||||||
|
lt_user,
|
||||||
|
nameValue(users.front()),
|
||||||
|
Ui::Text::RichLangValue) | rpl::map(addReward);
|
||||||
|
} else if (count == 2) {
|
||||||
|
return tr::lng_premium_gifts_about_user2(
|
||||||
|
lt_user,
|
||||||
|
nameValue(users.front()),
|
||||||
|
lt_second_user,
|
||||||
|
nameValue(users[1]),
|
||||||
|
Ui::Text::RichLangValue) | rpl::map(addReward);
|
||||||
|
} else if (count == 3) {
|
||||||
|
return tr::lng_premium_gifts_about_user3(
|
||||||
|
lt_user,
|
||||||
|
nameValue(users.front()),
|
||||||
|
lt_second_user,
|
||||||
|
nameValue(users[1]),
|
||||||
|
lt_name,
|
||||||
|
nameValue(users[2]),
|
||||||
|
Ui::Text::RichLangValue) | rpl::map(addReward);
|
||||||
|
} else {
|
||||||
|
return tr::lng_premium_gifts_about_user_more(
|
||||||
|
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) | rpl::map(addReward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] not_null<Ui::RpWidget*> CircleBadge(
|
[[nodiscard]] not_null<Ui::RpWidget*> CircleBadge(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const QString &text) {
|
const QString &text) {
|
||||||
|
@ -348,7 +409,6 @@ void GiftsBox(
|
||||||
top,
|
top,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
constexpr auto kUserpicsMax = size_t(3);
|
|
||||||
const auto maxWithUserpic = std::min(users.size(), kUserpicsMax);
|
const auto maxWithUserpic = std::min(users.size(), kUserpicsMax);
|
||||||
const auto userpics = UserpicsContainer(
|
const auto userpics = UserpicsContainer(
|
||||||
top,
|
top,
|
||||||
|
@ -397,6 +457,27 @@ void GiftsBox(
|
||||||
// Header.
|
// Header.
|
||||||
const auto &padding = st::premiumGiftAboutPadding;
|
const auto &padding = st::premiumGiftAboutPadding;
|
||||||
const auto available = boxWidth - padding.left() - padding.right();
|
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 = object_ptr<Ui::FlatLabel>(
|
||||||
|
box,
|
||||||
|
ComplexAboutLabel(users),
|
||||||
|
st::premiumPreviewAbout);
|
||||||
|
textLabel->setTextColorOverride(stTitle.textFg->c);
|
||||||
|
textLabel->resizeToWidth(available);
|
||||||
|
box->addRow(
|
||||||
|
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(box, std::move(textLabel)),
|
||||||
|
padding);
|
||||||
|
|
||||||
// List.
|
// List.
|
||||||
const auto options = api->options(users.size());
|
const auto options = api->options(users.size());
|
||||||
|
|
Loading…
Add table
Reference in a new issue