diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 9f604970d4..799f951759 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3969,10 +3969,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_offer_duration" = "Offer Duration"; "lng_gift_offer_duration_about" = "Choose how long {user} can accept your offer. When the time expires, the amount will be refunded."; "lng_gift_offer_cost_button" = "Offer {cost}"; -"lng_gift_offer_confirm_reject" = "Do you want to reject the offer?"; +"lng_gift_offer_reject_title" = "Reject Offer"; +"lng_gift_offer_confirm_reject" = "Are you sure you want to reject the offer from {user}?"; "lng_gift_offer_confirm_accept" = "Do you want to sell {name} to {user} for {cost}?"; "lng_gift_offer_you_get" = "You will receive {cost} after fees."; -"lng_gift_offer_value_higher" = "{percent} higher"; +"lng_gift_offer_higher" = "The price you are offered is {percent} higher than the average price for {name}."; +"lng_gift_offer_lower" = "The price you are offered is {percent} lower than the average price for {name}."; "lng_gift_offer_sell_for" = "Sell for {price}"; "lng_gift_offer_confirm_title" = "Confirm Offer"; "lng_gift_offer_confirm_text" = "Do you want to offer {cost} to {user} for {name}?"; diff --git a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp index f5cbf61b0e..963d9bc0c4 100644 --- a/Telegram/SourceFiles/boxes/transfer_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/transfer_gift_box.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/controls/sub_tabs.h" #include "ui/controls/ton_common.h" #include "ui/layers/generic_box.h" +#include "ui/text/format_values.h" #include "ui/text/text_utilities.h" #include "ui/toast/toast.h" #include "ui/basic_click_handlers.h" @@ -794,7 +795,46 @@ void ShowGiftSaleAcceptBox( }); const auto show = controller->uiShow(); + auto taken = base::take(gift->value); AddTransferGiftTable(show, box->verticalLayout(), gift); + gift->value = std::move(taken); + + if (const auto raw = gift->value.get()) { + const auto appConfig = &show->session().appConfig(); + const auto rule = Ui::LookupCurrencyRule(u"USD"_q); + const auto value = (gift->value->valuePriceUsd > 0 ? 1 : -1) + * std::abs(gift->value->valuePriceUsd) + / std::pow(10., rule.exponent); + if (std::abs(value) >= 0.01) { + const auto rate = price.ton() + ? appConfig->currencyWithdrawRate() + : (appConfig->starsWithdrawRate() / 100.); + const auto offered = receive * rate; + const auto diff = offered - value; + const auto percent = std::abs(diff / value * 100.); + if (percent >= 1) { + const auto higher = (diff > 0.); + const auto good = higher || (percent < 10); + const auto number = int(base::SafeRound(percent)); + const auto percentText = QString::number(number) + '%'; + box->addRow( + object_ptr( + box, + (higher + ? tr::lng_gift_offer_higher + : tr::lng_gift_offer_lower)( + lt_percent, + rpl::single(tr::bold(percentText)), + lt_name, + rpl::single(tr::marked( + UniqueGiftName(*gift))), + tr::marked), + (good ? st::offerValueGood : st::offerValueBad)), + st::boxRowPadding + st::offerValuePadding + )->setTryMakeSimilarLines(true); + } + } + } })); } @@ -821,9 +861,14 @@ void ShowGiftSaleRejectBox( }); }; controller->show(Ui::MakeConfirmBox({ - .text = tr::lng_gift_offer_confirm_reject(), + .text = tr::lng_gift_offer_confirm_reject( + lt_user, + rpl::single(tr::bold(item->history()->peer->shortName())), + tr::marked), .confirmed = std::move(callback), .confirmText = tr::lng_action_gift_offer_decline(), + .confirmStyle = &st::attentionBoxButton, + .title = tr::lng_gift_offer_reject_title(), })); } diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index b6ee310706..21e25eeeb7 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -441,6 +441,19 @@ resaleConfirmTonOnly: FlatLabel(boxLabel) { } resaleConfirmTonOnlyMargin: margins(0px, 12px, 0px, 12px); +offerValuePadding: margins(0px, 8px, 0px, 0px); +offerValueGood: FlatLabel(boxLabel) { + minWidth: 120px; + textFg: windowSubTextFg; + align: align(top); + style: TextStyle(defaultTextStyle) { + font: font(12px); + } +} +offerValueBad: FlatLabel(offerValueGood) { + textFg: attentionButtonFg; +} + uniqueGiftValuePrice: FlatLabel(defaultFlatLabel) { style: TextStyle(defaultTextStyle) { font: font(20px semibold);