mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added support of minimal amount of credits to withdrawal button.
This commit is contained in:
parent
712c06756e
commit
d0a030ab58
3 changed files with 42 additions and 3 deletions
|
@ -5203,6 +5203,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_bot_earn_out_ph" = "Enter amount to withdraw";
|
"lng_bot_earn_out_ph" = "Enter amount to withdraw";
|
||||||
"lng_bot_earn_balance_password_title" = "Two-step verification";
|
"lng_bot_earn_balance_password_title" = "Two-step verification";
|
||||||
"lng_bot_earn_balance_password_description" = "Please enter your password to collect.";
|
"lng_bot_earn_balance_password_description" = "Please enter your password to collect.";
|
||||||
|
"lng_bot_earn_credits_out_minimal" = "You cannot withdraw less then {link}.";
|
||||||
|
"lng_bot_earn_credits_out_minimal_link#one" = "{count} star";
|
||||||
|
"lng_bot_earn_credits_out_minimal_link#other" = "{count} stars";
|
||||||
|
|
||||||
"lng_contact_add" = "Add";
|
"lng_contact_add" = "Add";
|
||||||
"lng_contact_send_message" = "message";
|
"lng_contact_send_message" = "message";
|
||||||
|
|
|
@ -55,6 +55,9 @@ void HandleWithdrawalButton(
|
||||||
if (state->loading) {
|
if (state->loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (peer && !receiver.creditsAmount()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
state->loading = true;
|
state->loading = true;
|
||||||
state->lifetime = session->api().cloudPassword().state(
|
state->lifetime = session->api().cloudPassword().state(
|
||||||
) | rpl::take(
|
) | rpl::take(
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "data/data_channel_earn.h"
|
#include "data/data_channel_earn.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
|
@ -23,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/statistics/info_statistics_inner_widget.h" // FillLoading.
|
#include "info/statistics/info_statistics_inner_widget.h" // FillLoading.
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_app_config.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "statistics/chart_widget.h"
|
#include "statistics/chart_widget.h"
|
||||||
#include "ui/effects/credits_graphics.h"
|
#include "ui/effects/credits_graphics.h"
|
||||||
|
@ -43,6 +45,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Info::BotEarn {
|
namespace Info::BotEarn {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
[[nodiscard]] int WithdrawalMin(not_null<Main::Session*> session) {
|
||||||
|
const auto key = u"stars_revenue_withdrawal_min"_q;
|
||||||
|
return session->appConfig().get<int>(key, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
void AddHeader(
|
void AddHeader(
|
||||||
not_null<Ui::VerticalLayout*> content,
|
not_null<Ui::VerticalLayout*> content,
|
||||||
tr::phrase<> text) {
|
tr::phrase<> text) {
|
||||||
|
@ -344,7 +351,7 @@ void InnerWidget::fill() {
|
||||||
button,
|
button,
|
||||||
tr::lng_channel_earn_balance_button(tr::now),
|
tr::lng_channel_earn_balance_button(tr::now),
|
||||||
st::channelEarnSemiboldLabel);
|
st::channelEarnSemiboldLabel);
|
||||||
{
|
const auto processInputChange = [&] {
|
||||||
const auto buttonEmoji = Ui::Text::SingleCustomEmoji(
|
const auto buttonEmoji = Ui::Text::SingleCustomEmoji(
|
||||||
session->data().customEmojiManager().registerInternalEmoji(
|
session->data().customEmojiManager().registerInternalEmoji(
|
||||||
st::settingsPremiumIconStar,
|
st::settingsPremiumIconStar,
|
||||||
|
@ -373,7 +380,8 @@ void InnerWidget::fill() {
|
||||||
};
|
};
|
||||||
QObject::connect(input, &Ui::MaskedInputField::changed, process);
|
QObject::connect(input, &Ui::MaskedInputField::changed, process);
|
||||||
process();
|
process();
|
||||||
}
|
return process;
|
||||||
|
}();
|
||||||
label->setTextColorOverride(stButton.textFg->c);
|
label->setTextColorOverride(stButton.textFg->c);
|
||||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
@ -470,7 +478,32 @@ void InnerWidget::fill() {
|
||||||
Api::HandleWithdrawalButton(
|
Api::HandleWithdrawalButton(
|
||||||
Api::RewardReceiver{
|
Api::RewardReceiver{
|
||||||
.creditsReceiver = _peer,
|
.creditsReceiver = _peer,
|
||||||
.creditsAmount = [=] { return input->getLastText().toInt(); },
|
.creditsAmount = [=, show = _controller->uiShow()] {
|
||||||
|
const auto amount = input->getLastText().toULongLong();
|
||||||
|
const auto min = float64(WithdrawalMin(session));
|
||||||
|
if (amount <= min) {
|
||||||
|
auto text = tr::lng_bot_earn_credits_out_minimal(
|
||||||
|
tr::now,
|
||||||
|
lt_link,
|
||||||
|
Ui::Text::Link(
|
||||||
|
tr::lng_bot_earn_credits_out_minimal_link(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
min),
|
||||||
|
u"internal:"_q),
|
||||||
|
Ui::Text::RichLangValue);
|
||||||
|
show->showToast(Ui::Toast::Config{
|
||||||
|
.text = std::move(text),
|
||||||
|
.filter = [=](const auto ...) {
|
||||||
|
input->setText(QString::number(min));
|
||||||
|
processInputChange();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return 0ULL;
|
||||||
|
}
|
||||||
|
return amount;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
button,
|
button,
|
||||||
_controller->uiShow());
|
_controller->uiShow());
|
||||||
|
|
Loading…
Add table
Reference in a new issue