mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 02:07:24 +00:00
Show correct price in resale box.
This commit is contained in:
parent
23c0fcada6
commit
2a50d0856b
15
Telegram/Resources/icons/payments/ton_emoji.svg
Normal file
15
Telegram/Resources/icons/payments/ton_emoji.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg width="72px" height="72px" viewBox="0 0 72 72">
|
||||
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g transform="translate(9.000000, 14.000000)" stroke-width="7.2" stroke="rgb(255,255,255)">
|
||||
<path d="M2.96014341,0 L50.9898193,0 C51.9732032,-7.06402744e-15
|
||||
52.7703933,0.797190129 52.7703933,1.78057399 C52.7703933,2.08038611
|
||||
52.6946886,2.3753442 52.5502994,2.63809702 L29.699977,44.2200383
|
||||
C28.7527832,45.9436969 26.5876295,46.5731461 24.8639708,45.6259523
|
||||
C24.2556953,45.2916896 23.7583564,44.7869606 23.4331014,44.1738213
|
||||
L1.38718565,2.61498853 C0.926351231,1.74626794 1.25700829,0.668450654
|
||||
2.12572888,0.20761623 C2.38272962,0.0712838007 2.6692209,4.97530809e-16
|
||||
2.96014341,0 Z"></path>
|
||||
<line x1="27" y1="44.4532875" x2="27" y2="0"></line>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 835 B |
@ -567,6 +567,49 @@ not_null<FlatLabel*> SetButtonMarkedLabel(
|
||||
}), st, textFg);
|
||||
}
|
||||
|
||||
void SetButtonTwoLabels(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
rpl::producer<TextWithEntities> title,
|
||||
rpl::producer<TextWithEntities> subtitle,
|
||||
const style::FlatLabel &st,
|
||||
const style::FlatLabel &subst,
|
||||
const style::color *textFg) {
|
||||
const auto buttonTitle = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
std::move(title),
|
||||
st);
|
||||
const auto buttonSubtitle = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
std::move(subtitle),
|
||||
subst);
|
||||
buttonSubtitle->setOpacity(0.6);
|
||||
if (textFg) {
|
||||
buttonTitle->setTextColorOverride((*textFg)->c);
|
||||
buttonSubtitle->setTextColorOverride((*textFg)->c);
|
||||
style::PaletteChanged() | rpl::start_with_next([=] {
|
||||
buttonTitle->setTextColorOverride((*textFg)->c);
|
||||
buttonSubtitle->setTextColorOverride((*textFg)->c);
|
||||
}, buttonTitle->lifetime());
|
||||
}
|
||||
rpl::combine(
|
||||
button->sizeValue(),
|
||||
buttonTitle->sizeValue(),
|
||||
buttonSubtitle->sizeValue()
|
||||
) | rpl::start_with_next([=](QSize outer, QSize title, QSize subtitle) {
|
||||
const auto two = title.height() + subtitle.height();
|
||||
const auto titleTop = (outer.height() - two) / 2;
|
||||
const auto subtitleTop = titleTop + title.height();
|
||||
buttonTitle->moveToLeft(
|
||||
(outer.width() - title.width()) / 2,
|
||||
titleTop);
|
||||
buttonSubtitle->moveToLeft(
|
||||
(outer.width() - subtitle.width()) / 2,
|
||||
subtitleTop);
|
||||
}, buttonTitle->lifetime());
|
||||
buttonTitle->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
buttonSubtitle->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
void SendStarsForm(
|
||||
not_null<Main::Session*> session,
|
||||
std::shared_ptr<Payments::CreditsFormData> data,
|
||||
|
@ -52,6 +52,14 @@ not_null<FlatLabel*> SetButtonMarkedLabel(
|
||||
const style::FlatLabel &st,
|
||||
const style::color *textFg = nullptr);
|
||||
|
||||
void SetButtonTwoLabels(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
rpl::producer<TextWithEntities> title,
|
||||
rpl::producer<TextWithEntities> subtitle,
|
||||
const style::FlatLabel &st,
|
||||
const style::FlatLabel &subst,
|
||||
const style::color *textFg = nullptr);
|
||||
|
||||
void SendStarsForm(
|
||||
not_null<Main::Session*> session,
|
||||
std::shared_ptr<Payments::CreditsFormData> data,
|
||||
|
@ -3907,7 +3907,7 @@ void ShowStarGiftBox(
|
||||
void SetupResalePriceButton(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<QColor> background,
|
||||
rpl::producer<int> price,
|
||||
rpl::producer<CreditsAmount> price,
|
||||
Fn<void()> click) {
|
||||
const auto resale = Ui::CreateChild<
|
||||
Ui::FadeWrapScaled<Ui::AbstractButton>
|
||||
@ -3928,11 +3928,13 @@ void SetupResalePriceButton(
|
||||
}, button->lifetime());
|
||||
text->setTextColorOverride(QColor(255, 255, 255, 255));
|
||||
|
||||
std::move(price) | rpl::start_with_next([=](int value) {
|
||||
if (value > 0) {
|
||||
text->setMarkedText(
|
||||
Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
Lang::FormatCountDecimal(value)));
|
||||
std::move(price) | rpl::start_with_next([=](CreditsAmount value) {
|
||||
if (value) {
|
||||
text->setMarkedText(value.ton()
|
||||
? Ui::Text::IconEmoji(&st::tonIconEmoji).append(
|
||||
Lang::FormatCreditsAmountDecimal(value))
|
||||
: Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
Lang::FormatCountDecimal(value.whole())));
|
||||
resale->toggle(true, anim::type::normal);
|
||||
} else {
|
||||
resale->toggle(false, anim::type::normal);
|
||||
@ -3968,7 +3970,7 @@ void AddUniqueGiftCover(
|
||||
not_null<VerticalLayout*> container,
|
||||
rpl::producer<Data::UniqueGift> data,
|
||||
rpl::producer<QString> subtitleOverride,
|
||||
rpl::producer<int> resalePrice,
|
||||
rpl::producer<CreditsAmount> resalePrice,
|
||||
Fn<void()> resaleClick) {
|
||||
const auto cover = container->add(object_ptr<RpWidget>(container));
|
||||
|
||||
@ -4494,7 +4496,7 @@ void UpdateGiftSellPrice(
|
||||
std::shared_ptr<Data::UniqueGift> unique,
|
||||
Data::SavedStarGiftId savedId,
|
||||
CreditsAmount price) {
|
||||
const auto was = unique->starsForResale;
|
||||
const auto wasOnResale = (unique->starsForResale > 0);
|
||||
const auto session = &show->session();
|
||||
session->api().request(MTPpayments_UpdateStarGiftPrice(
|
||||
Api::InputSavedStarGiftId(savedId, unique),
|
||||
@ -4505,7 +4507,7 @@ void UpdateGiftSellPrice(
|
||||
session->api().applyUpdates(result);
|
||||
show->showToast((!price
|
||||
? tr::lng_gift_sell_removed
|
||||
: (was > 0)
|
||||
: wasOnResale
|
||||
? tr::lng_gift_sell_updated
|
||||
: tr::lng_gift_sell_toast)(
|
||||
tr::now,
|
||||
|
@ -59,7 +59,7 @@ void AddUniqueGiftCover(
|
||||
not_null<VerticalLayout*> container,
|
||||
rpl::producer<Data::UniqueGift> data,
|
||||
rpl::producer<QString> subtitleOverride = nullptr,
|
||||
rpl::producer<int> resalePrice = nullptr,
|
||||
rpl::producer<CreditsAmount> resalePrice = nullptr,
|
||||
Fn<void()> resaleClick = nullptr);
|
||||
void AddWearGiftCover(
|
||||
not_null<VerticalLayout*> container,
|
||||
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_session.h"
|
||||
#include "payments/payments_checkout_process.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/ton_common.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
@ -503,7 +504,7 @@ void BuyResaleGift(
|
||||
|
||||
using Flag = MTPDinputInvoiceStarGiftResale::Flag;
|
||||
const auto invoice = MTP_inputInvoiceStarGiftResale(
|
||||
MTP_flags(Flag()),
|
||||
MTP_flags(gift->onlyAcceptTon ? Flag::f_ton : Flag()),
|
||||
MTP_string(gift->slug),
|
||||
to->input);
|
||||
|
||||
@ -662,8 +663,15 @@ void ShowBuyResaleGiftBox(
|
||||
|
||||
auto transfer = tr::lng_gift_buy_resale_button(
|
||||
lt_cost,
|
||||
rpl::single(
|
||||
Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
rpl::single(gift->onlyAcceptTon
|
||||
? Ui::Text::IconEmoji(
|
||||
&st::tonIconEmoji
|
||||
).append(
|
||||
Lang::FormatCreditsAmountDecimal(CreditsAmount(
|
||||
gift->nanoTonForResale / Ui::kNanosInOne,
|
||||
gift->nanoTonForResale % Ui::kNanosInOne,
|
||||
CreditsType::Ton)))
|
||||
: Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
Lang::FormatCountDecimal(gift->starsForResale))),
|
||||
Ui::Text::WithEntities);
|
||||
|
||||
@ -698,19 +706,29 @@ void ShowBuyResaleGiftBox(
|
||||
lt_name,
|
||||
rpl::single(Ui::Text::Bold(UniqueGiftName(*gift))),
|
||||
lt_price,
|
||||
tr::lng_action_gift_for_stars(
|
||||
lt_count,
|
||||
rpl::single(gift->starsForResale * 1.),
|
||||
Ui::Text::Bold),
|
||||
(gift->onlyAcceptTon
|
||||
? tr::lng_action_gift_for_ton(
|
||||
lt_count,
|
||||
rpl::single(gift->nanoTonForResale / 1'000'000'000.),
|
||||
Ui::Text::Bold)
|
||||
: tr::lng_action_gift_for_stars(
|
||||
lt_count_decimal,
|
||||
rpl::single(gift->starsForResale * 1.),
|
||||
Ui::Text::Bold)),
|
||||
Ui::Text::WithEntities)
|
||||
: tr::lng_gift_buy_resale_confirm(
|
||||
lt_name,
|
||||
rpl::single(Ui::Text::Bold(UniqueGiftName(*gift))),
|
||||
lt_price,
|
||||
tr::lng_action_gift_for_stars(
|
||||
lt_count,
|
||||
rpl::single(gift->starsForResale * 1.),
|
||||
Ui::Text::Bold),
|
||||
(gift->onlyAcceptTon
|
||||
? tr::lng_action_gift_for_ton(
|
||||
lt_count,
|
||||
rpl::single(gift->nanoTonForResale / 1'000'000'000.),
|
||||
Ui::Text::Bold)
|
||||
: tr::lng_action_gift_for_stars(
|
||||
lt_count_decimal,
|
||||
rpl::single(gift->starsForResale * 1.),
|
||||
Ui::Text::Bold)),
|
||||
lt_user,
|
||||
rpl::single(Ui::Text::Bold(to->shortName())),
|
||||
Ui::Text::WithEntities),
|
||||
|
@ -1021,26 +1021,6 @@ uint64 CustomEmojiManager::coloredSetId() const {
|
||||
return _coloredSetId;
|
||||
}
|
||||
|
||||
TextWithEntities CustomEmojiManager::tonEmoji(QMargins padding) {
|
||||
return Ui::Text::SingleCustomEmoji(registerInternalEmoji(
|
||||
u"builtin:ton_emoji"_q,
|
||||
Ui::Earn::IconCurrencyColored(
|
||||
st::tonIconEmojiSize,
|
||||
st::currencyFg->c),
|
||||
st::tonIconEmojiPadding + padding,
|
||||
false));
|
||||
}
|
||||
|
||||
TextWithEntities CustomEmojiManager::monoTonEmoji(QMargins padding) {
|
||||
return Ui::Text::SingleCustomEmoji(registerInternalEmoji(
|
||||
u"builtin:monoton_emoji"_q,
|
||||
Ui::Earn::IconCurrencyColored(
|
||||
st::tonIconEmojiSize,
|
||||
st::currencyFg->c),
|
||||
st::tonIconEmojiPadding + padding,
|
||||
true));
|
||||
}
|
||||
|
||||
TextWithEntities CustomEmojiManager::creditsEmoji(QMargins padding) {
|
||||
return Ui::Text::SingleCustomEmoji(registerInternalEmoji(
|
||||
u"builtin:credits_emoji"_q,
|
||||
|
@ -100,8 +100,6 @@ public:
|
||||
|
||||
[[nodiscard]] uint64 coloredSetId() const;
|
||||
|
||||
[[nodiscard]] TextWithEntities tonEmoji(QMargins padding = {});
|
||||
[[nodiscard]] TextWithEntities monoTonEmoji(QMargins padding = {});
|
||||
[[nodiscard]] TextWithEntities creditsEmoji(QMargins padding = {});
|
||||
[[nodiscard]] TextWithEntities ministarEmoji(QMargins padding = {});
|
||||
|
||||
|
@ -742,7 +742,7 @@ TextWithEntities Delegate::monostar() {
|
||||
}
|
||||
|
||||
TextWithEntities Delegate::monoton() {
|
||||
return _session->data().customEmojiManager().monoTonEmoji();
|
||||
return Ui::Text::IconEmoji(&st::tonIconEmoji);
|
||||
}
|
||||
|
||||
TextWithEntities Delegate::ministar() {
|
||||
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/gift_premium_box.h"
|
||||
#include "boxes/share_box.h"
|
||||
#include "boxes/send_credits_box.h" // SetButtonTwoLabels
|
||||
#include "boxes/star_gift_box.h"
|
||||
#include "boxes/transfer_gift_box.h"
|
||||
#include "chat_helpers/stickers_gift_box_pack.h"
|
||||
@ -62,6 +63,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_credits.h"
|
||||
#include "statistics/widgets/chart_header_widget.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/ton_common.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/dynamic_image.h"
|
||||
#include "ui/dynamic_thumbnails.h"
|
||||
@ -1067,8 +1069,8 @@ void FillUniqueGiftMenu(
|
||||
}
|
||||
}
|
||||
if (CanResellGift(&show->session(), e)) {
|
||||
const auto resalePrice = unique->starsForResale;
|
||||
const auto editPrice = (resalePrice > 0
|
||||
const auto inResale = (unique->starsForResale > 0);
|
||||
const auto editPrice = (inResale
|
||||
? tr::lng_gift_transfer_update
|
||||
: tr::lng_gift_transfer_sell)(tr::now);
|
||||
menu->addAction(editPrice, [=] {
|
||||
@ -1077,7 +1079,7 @@ void FillUniqueGiftMenu(
|
||||
: GiftWearBoxStyleOverride();
|
||||
ShowUniqueGiftSellBox(show, unique, savedId, style);
|
||||
}, st.resell ? st.resell : &st::menuIconTagSell);
|
||||
if (resalePrice > 0) {
|
||||
if (inResale) {
|
||||
menu->addAction(tr::lng_gift_transfer_unlist(tr::now), [=] {
|
||||
const auto name = UniqueGiftName(*unique);
|
||||
const auto confirm = [=](Fn<void()> close) {
|
||||
@ -1240,7 +1242,12 @@ void GenericCreditsEntryBox(
|
||||
return (update.action == Data::GiftUpdate::Action::ResaleChange)
|
||||
&& (update.slug == slug);
|
||||
}) | rpl::to_empty) | rpl::map([unique = e.uniqueGift] {
|
||||
return unique->starsForResale;
|
||||
return unique->onlyAcceptTon
|
||||
? CreditsAmount(
|
||||
unique->nanoTonForResale / Ui::kNanosInOne,
|
||||
unique->nanoTonForResale % Ui::kNanosInOne,
|
||||
CreditsType::Ton)
|
||||
: CreditsAmount(unique->starsForResale);
|
||||
});
|
||||
auto change = [=] {
|
||||
const auto style = st.giftWearBox
|
||||
@ -2100,12 +2107,36 @@ void GenericCreditsEntryBox(
|
||||
}
|
||||
});
|
||||
if (canBuyResold) {
|
||||
button->setText(tr::lng_gift_buy_resale_button(
|
||||
lt_cost,
|
||||
rpl::single(
|
||||
Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
if (uniqueGift->onlyAcceptTon) {
|
||||
button->setText(rpl::single(QString()));
|
||||
Ui::SetButtonTwoLabels(
|
||||
button,
|
||||
tr::lng_gift_buy_resale_button(
|
||||
lt_cost,
|
||||
rpl::single(Ui::Text::IconEmoji(
|
||||
&st::tonIconEmoji
|
||||
).append(
|
||||
Lang::FormatCreditsAmountDecimal(CreditsAmount(
|
||||
uniqueGift->nanoTonForResale / Ui::kNanosInOne,
|
||||
uniqueGift->nanoTonForResale % Ui::kNanosInOne,
|
||||
CreditsType::Ton)))),
|
||||
Ui::Text::WithEntities),
|
||||
tr::lng_gift_buy_resale_equals(
|
||||
lt_cost,
|
||||
rpl::single(Ui::Text::IconEmoji(
|
||||
&st::starIconEmojiSmall
|
||||
).append(Lang::FormatCountDecimal(
|
||||
uniqueGift->starsForResale))),
|
||||
Ui::Text::WithEntities),
|
||||
st::giftResaleButtonTitle,
|
||||
st::giftResaleButtonSubtitle);
|
||||
} else {
|
||||
button->setText(tr::lng_gift_buy_resale_button(
|
||||
lt_cost,
|
||||
rpl::single(Ui::Text::IconEmoji(&st::starIconEmoji).append(
|
||||
Lang::FormatCountDecimal(uniqueGift->starsForResale))),
|
||||
Ui::Text::WithEntities));
|
||||
Ui::Text::WithEntities));
|
||||
}
|
||||
}
|
||||
{
|
||||
using namespace Info::Statistics;
|
||||
|
@ -81,8 +81,11 @@ starIconEmojiSmall: IconEmoji {
|
||||
icon: icon{{ "chat/mini_stars", creditsBg1 }};
|
||||
padding: margins(0px, 4px, 0px, 0px);
|
||||
}
|
||||
tonIconEmoji: IconEmoji {
|
||||
icon: icon{{ "payments/ton_emoji-18x18", currencyFg }};
|
||||
padding: margins(0px, 1px, 0px, 0px);
|
||||
}
|
||||
tonIconEmojiSize: 18px;
|
||||
tonIconEmojiPadding: margins(0px, 2px, 0px, 0px);
|
||||
|
||||
creditsHistoryEntryTypeAds: icon {{ "folders/folders_channels", premiumButtonFg }};
|
||||
|
||||
@ -320,3 +323,13 @@ creditsHistoryRowRightMinorTop: 18px;
|
||||
creditsHistoryRowRightStyle: TextStyle(defaultTextStyle) {
|
||||
font: font(fsize);
|
||||
}
|
||||
giftResaleButtonTitle: FlatLabel(defaultFlatLabel) {
|
||||
style: semiboldTextStyle;
|
||||
textFg: activeButtonFg;
|
||||
}
|
||||
giftResaleButtonSubtitle: FlatLabel(defaultFlatLabel) {
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
font: font(12px semibold);
|
||||
}
|
||||
textFg: activeButtonFg;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user