mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Simplify paid message button labeling.
This commit is contained in:
parent
97b021efaf
commit
8ea7bd4913
7 changed files with 48 additions and 41 deletions
Telegram/SourceFiles
boxes
chat_helpers
ui/controls
window
|
@ -1230,16 +1230,9 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
const auto submit = addButton(
|
||||
tr::lng_polls_create_button(),
|
||||
[=] { isNormal ? send({}) : schedule(); });
|
||||
submit->setText(_starsRequired.value() | rpl::map([=](int stars) {
|
||||
using namespace Ui;
|
||||
if (!stars) {
|
||||
return (isNormal
|
||||
? tr::lng_polls_create_button
|
||||
: tr::lng_schedule_button)(tr::now, Text::WithEntities);
|
||||
}
|
||||
return Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string);
|
||||
}));
|
||||
submit->setText(PaidSendButtonText(_starsRequired.value(), isNormal
|
||||
? tr::lng_polls_create_button()
|
||||
: tr::lng_schedule_button()));
|
||||
const auto sendMenuDetails = [=] {
|
||||
collectError();
|
||||
return (*error) ? SendMenu::Details() : _sendMenuDetails();
|
||||
|
|
|
@ -740,12 +740,8 @@ void SendFilesBox::refreshButtons() {
|
|||
? _captionToPeer->starsPerMessageChecked()
|
||||
: 0;
|
||||
if (perMessage > 0) {
|
||||
_send->setText(_messagesCount.value(
|
||||
) | rpl::map([=](int count) {
|
||||
const auto stars = count * perMessage;
|
||||
return Ui::Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string);
|
||||
}));
|
||||
_send->setText(PaidSendButtonText(_messagesCount.value(
|
||||
) | rpl::map(rpl::mappers::_1 * perMessage)));
|
||||
}
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
|
|
|
@ -620,13 +620,9 @@ void ShareBox::createButtons() {
|
|||
showMenu(send);
|
||||
}
|
||||
}, send->lifetime());
|
||||
send->setText(_starsToSend.value() | rpl::map([=](int stars) {
|
||||
using namespace Ui;
|
||||
return stars
|
||||
? Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string)
|
||||
: tr::lng_share_confirm(tr::now, Text::WithEntities);
|
||||
}));
|
||||
send->setText(PaidSendButtonText(
|
||||
_starsToSend.value(),
|
||||
tr::lng_share_confirm()));
|
||||
} else if (_descriptor.copyCallback) {
|
||||
addButton(_copyLinkText.value(), [=] { copyLink(); });
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -12,8 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_credits.h" // starIconEmoji
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
@ -54,7 +54,7 @@ void SendButton::setState(State state) {
|
|||
|| _state.starsToSend != state.starsToSend) {
|
||||
_starsToSendText.setMarkedText(
|
||||
_st.stars.style,
|
||||
Text::IconEmoji(&st::starIconEmoji).append(
|
||||
Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(state.starsToSend).string),
|
||||
kMarkupTextOptions);
|
||||
}
|
||||
|
|
|
@ -2174,14 +2174,9 @@ object_ptr<Ui::BoxContent> PrepareChooseRecipientBox(
|
|||
onstack({});
|
||||
}
|
||||
});
|
||||
send->setText(state->starsToSend.value(
|
||||
) | rpl::map([=](int stars) {
|
||||
using namespace Ui;
|
||||
return stars
|
||||
? Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string)
|
||||
: tr::lng_send_button(tr::now, Text::WithEntities);
|
||||
}));
|
||||
send->setText(PaidSendButtonText(
|
||||
state->starsToSend.value(),
|
||||
tr::lng_send_button()));
|
||||
}
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
box->closeBox();
|
||||
|
@ -2729,14 +2724,9 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
|||
showMenu(send);
|
||||
}
|
||||
}, send->lifetime());
|
||||
send->setText(state->starsToSend.value(
|
||||
) | rpl::map([=](int stars) {
|
||||
using namespace Ui;
|
||||
return stars
|
||||
? Text::IconEmoji(&st::boxStarIconEmoji).append(
|
||||
Lang::FormatCountToShort(stars).string)
|
||||
: tr::lng_send_button(tr::now, Text::WithEntities);
|
||||
}));
|
||||
send->setText(PaidSendButtonText(
|
||||
state->starsToSend.value(),
|
||||
tr::lng_send_button()));
|
||||
}
|
||||
state->box->addButton(tr::lng_cancel(), [=] {
|
||||
state->box->closeBox();
|
||||
|
|
Loading…
Add table
Reference in a new issue