mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Simplify paid message button labeling.
This commit is contained in:
@@ -1280,3 +1280,26 @@ void SelectTextInFieldWithMargins(
|
||||
textCursor.setPosition(selection.to, QTextCursor::KeepAnchor);
|
||||
field->setTextCursor(textCursor);
|
||||
}
|
||||
|
||||
TextWithEntities PaidSendButtonText(tr::now_t, int stars) {
|
||||
return Ui::Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string);
|
||||
}
|
||||
|
||||
rpl::producer<TextWithEntities> PaidSendButtonText(
|
||||
rpl::producer<int> stars,
|
||||
rpl::producer<QString> fallback) {
|
||||
if (fallback) {
|
||||
return rpl::combine(
|
||||
std::move(fallback),
|
||||
std::move(stars)
|
||||
) | rpl::map([=](QString zero, int count) {
|
||||
return count
|
||||
? PaidSendButtonText(tr::now, count)
|
||||
: TextWithEntities{ zero };
|
||||
});
|
||||
}
|
||||
return std::move(stars) | rpl::map([=](int count) {
|
||||
return PaidSendButtonText(tr::now, count);
|
||||
});
|
||||
}
|
||||
|
@@ -19,6 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include <QtGui/QClipboard>
|
||||
|
||||
namespace tr {
|
||||
struct now_t;
|
||||
} // namespace tr
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
class SessionShow;
|
||||
@@ -169,3 +173,8 @@ private:
|
||||
void SelectTextInFieldWithMargins(
|
||||
not_null<Ui::InputField*> field,
|
||||
const TextSelection &selection);
|
||||
|
||||
[[nodiscard]] TextWithEntities PaidSendButtonText(tr::now_t, int stars);
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> PaidSendButtonText(
|
||||
rpl::producer<int> stars,
|
||||
rpl::producer<QString> fallback = nullptr);
|
||||
|
Reference in New Issue
Block a user