mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 10:17:10 +00:00
Make big Upgrade button for gifts.
This commit is contained in:
parent
ee85bb9a1b
commit
77cec0e338
@ -3611,8 +3611,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_gift_hidden_hint_channel" = "This gift is hidden from visitors of your channel.";
|
||||
"lng_gift_visible_hint_channel" = "This gift is visible in your channel's Gifts.";
|
||||
"lng_gift_in_blockchain" = "This gift is in TON blockchain. {link}";
|
||||
"lng_gift_in_blockchain_link" = "View >";
|
||||
"lng_gift_visible_hide" = "Hide >";
|
||||
"lng_gift_in_blockchain_link_arrow" = "View {arrow}";
|
||||
"lng_gift_visible_hide_arrow" = "Hide {arrow}";
|
||||
"lng_gift_visible_show_arrow" = "Show {arrow}";
|
||||
"lng_gift_show_on_page" = "Display on my Page";
|
||||
"lng_gift_show_on_channel" = "Display in channel's Gifts";
|
||||
"lng_gift_availability" = "Availability";
|
||||
@ -3631,7 +3632,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_gift_unique_address_copied" = "Address copied to clipboard.";
|
||||
"lng_gift_unique_status" = "Status";
|
||||
"lng_gift_unique_status_non" = "Non-Unique";
|
||||
"lng_gift_unique_status_upgrade" = "upgrade";
|
||||
"lng_gift_unique_upgrade" = "Upgrade";
|
||||
"lng_gift_unique_number" = "Collectible #{index}";
|
||||
"lng_gift_unique_number_by" = "Collectible #{index} by {name}";
|
||||
"lng_gift_unique_model" = "Model";
|
||||
|
@ -466,8 +466,7 @@ void AddTableRow(
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> MakeNonUniqueStatusTableValue(
|
||||
not_null<Ui::TableLayout*> table,
|
||||
Fn<void()> startUpgrade) {
|
||||
not_null<Ui::TableLayout*> table) {
|
||||
auto result = object_ptr<Ui::RpWidget>(table);
|
||||
const auto raw = result.data();
|
||||
|
||||
@ -477,34 +476,10 @@ void AddTableRow(
|
||||
table->st().defaultValue,
|
||||
st::defaultPopupMenu);
|
||||
|
||||
const auto upgrade = startUpgrade
|
||||
? Ui::CreateChild<Ui::RoundButton>(
|
||||
raw,
|
||||
tr::lng_gift_unique_status_upgrade(),
|
||||
table->st().smallButton)
|
||||
: (Ui::RoundButton*)(nullptr);
|
||||
if (upgrade) {
|
||||
using namespace Ui;
|
||||
upgrade->setTextTransform(RoundButton::TextTransform::NoTransform);
|
||||
upgrade->setClickedCallback(startUpgrade);
|
||||
}
|
||||
|
||||
rpl::combine(
|
||||
raw->widthValue(),
|
||||
upgrade ? upgrade->widthValue() : rpl::single(0)
|
||||
) | rpl::start_with_next([=](int width, int toggleWidth) {
|
||||
const auto toggleSkip = toggleWidth
|
||||
? (st::normalFont->spacew + toggleWidth)
|
||||
: 0;
|
||||
label->resizeToNaturalWidth(width - toggleSkip);
|
||||
raw->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
label->resizeToNaturalWidth(width);
|
||||
label->moveToLeft(0, 0, width);
|
||||
if (upgrade) {
|
||||
upgrade->moveToLeft(
|
||||
label->width() + st::normalFont->spacew,
|
||||
(table->st().defaultValue.style.font->ascent
|
||||
- table->st().smallButton.style.font->ascent),
|
||||
width);
|
||||
}
|
||||
}, label->lifetime());
|
||||
|
||||
label->heightValue() | rpl::start_with_next([=](int height) {
|
||||
@ -1525,7 +1500,7 @@ void AddStarGiftTable(
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_gift_unique_status(),
|
||||
MakeNonUniqueStatusTableValue(table, std::move(startUpgrade)),
|
||||
MakeNonUniqueStatusTableValue(table),
|
||||
marginWithButton);
|
||||
}
|
||||
if (unique) {
|
||||
|
@ -4967,8 +4967,9 @@ void UpgradeBox(
|
||||
(cost
|
||||
? tr::lng_gift_upgrade_button(
|
||||
lt_price,
|
||||
rpl::single(star.append(
|
||||
' ' + Lang::FormatCreditsAmountDecimal(
|
||||
rpl::single(Ui::Text::IconEmoji(
|
||||
&st::starIconEmoji
|
||||
).append(' ').append(Lang::FormatCreditsAmountDecimal(
|
||||
CreditsAmount{ cost }))),
|
||||
Ui::Text::WithEntities)
|
||||
: tr::lng_gift_upgrade_confirm(Ui::Text::WithEntities)),
|
||||
|
@ -1884,14 +1884,29 @@ void GenericCreditsEntryBox(
|
||||
const auto visiblePhrase = giftToChannelCanManage
|
||||
? tr::lng_gift_visible_hint_channel
|
||||
: tr::lng_gift_visible_hint;
|
||||
auto withHide = rpl::combine(
|
||||
visiblePhrase(),
|
||||
tr::lng_gift_visible_hide()
|
||||
) | rpl::map([](QString &&hint, QString &&hide) {
|
||||
auto withShow = rpl::combine(
|
||||
hiddenPhrase(),
|
||||
tr::lng_gift_visible_show_arrow(
|
||||
lt_arrow,
|
||||
rpl::single(arrow),
|
||||
Ui::Text::WithEntities)
|
||||
) | rpl::map([=](QString &&hint, const TextWithEntities &hide) {
|
||||
return TextWithEntities{ std::move(hint) }.append(' ').append(
|
||||
Ui::Text::Link(std::move(hide)));
|
||||
});
|
||||
auto text = !e.savedToProfile
|
||||
auto withHide = rpl::combine(
|
||||
visiblePhrase(),
|
||||
tr::lng_gift_visible_hide_arrow(
|
||||
lt_arrow,
|
||||
rpl::single(arrow),
|
||||
Ui::Text::WithEntities)
|
||||
) | rpl::map([](QString &&hint, const TextWithEntities &hide) {
|
||||
return TextWithEntities{ std::move(hint) }.append(' ').append(
|
||||
Ui::Text::Link(std::move(hide)));
|
||||
});
|
||||
auto text = (!e.savedToProfile && canToggle && canUpgrade)
|
||||
? std::move(withShow)
|
||||
: !e.savedToProfile
|
||||
? hiddenPhrase(Ui::Text::WithEntities)
|
||||
: canToggle
|
||||
? std::move(withHide)
|
||||
@ -1921,7 +1936,11 @@ void GenericCreditsEntryBox(
|
||||
box,
|
||||
tr::lng_gift_in_blockchain(
|
||||
lt_link,
|
||||
tr::lng_gift_in_blockchain_link() | Ui::Text::ToLink(),
|
||||
tr::lng_gift_in_blockchain_link_arrow(
|
||||
lt_arrow,
|
||||
rpl::single(arrow),
|
||||
Ui::Text::WithEntities
|
||||
) | Ui::Text::ToLink(),
|
||||
Ui::Text::WithEntities),
|
||||
st::creditsBoxAboutDivider));
|
||||
label->setClickHandlerFilter([=](const auto &...) {
|
||||
@ -2005,6 +2024,8 @@ void GenericCreditsEntryBox(
|
||||
? tr::lng_credits_subscription_off_rejoin_button()
|
||||
: canUpgradeFree
|
||||
? tr::lng_gift_upgrade_free()
|
||||
: canUpgrade
|
||||
? tr::lng_gift_unique_upgrade()
|
||||
: (canToggle && !e.savedToProfile)
|
||||
? (e.giftChannelSavedId
|
||||
? tr::lng_gift_show_on_channel
|
||||
@ -2074,7 +2095,7 @@ void GenericCreditsEntryBox(
|
||||
e.giftResaleForceTon,
|
||||
to,
|
||||
crl::guard(box, [=] { box->closeBox(); }));
|
||||
} else if (canUpgradeFree) {
|
||||
} else if (canUpgrade) {
|
||||
upgrade();
|
||||
} else if (canToggle && !e.savedToProfile) {
|
||||
toggleVisibility(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user