mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Slightly improved style of channel earn info section.
This commit is contained in:
parent
f28f498467
commit
393d9e9f1f
5 changed files with 47 additions and 75 deletions
|
@ -4967,7 +4967,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_channel_earn_history_title" = "Transaction history";
|
"lng_channel_earn_history_title" = "Transaction history";
|
||||||
"lng_channel_earn_history_in" = "Proceeds from ads";
|
"lng_channel_earn_history_in" = "Proceeds from ads";
|
||||||
"lng_channel_earn_history_in_about" = "Proceeds from ads displayed in";
|
"lng_channel_earn_history_in_about" = "Proceeds from ads displayed in";
|
||||||
"lng_channel_earn_history_out" = "Balance withdrawal to";
|
"lng_channel_earn_history_out" = "Withdrawal";
|
||||||
|
"lng_channel_earn_history_out_failed" = "Not Completed";
|
||||||
|
"lng_channel_earn_history_out_about_failed" = "Withdrawal failed";
|
||||||
|
"lng_channel_earn_history_return" = "Refund";
|
||||||
|
"lng_channel_earn_history_return_about" = "Refunded back";
|
||||||
|
"lng_channel_earn_history_pending" = "Pending";
|
||||||
"lng_channel_earn_off" = "Switch Off Ads";
|
"lng_channel_earn_off" = "Switch Off Ads";
|
||||||
"lng_channel_earn_off_about" = "You will not be eligible for any rewards if you switch off ads.";
|
"lng_channel_earn_off_about" = "You will not be eligible for any rewards if you switch off ads.";
|
||||||
"lng_channel_earn_cpm_min" = "No Ads";
|
"lng_channel_earn_cpm_min" = "No Ads";
|
||||||
|
|
|
@ -819,9 +819,13 @@ void EarnStatistics::requestBoosts(
|
||||||
: d.is_failed()
|
: d.is_failed()
|
||||||
? Data::EarnHistoryEntry::Status::Failed
|
? Data::EarnHistoryEntry::Status::Failed
|
||||||
: Data::EarnHistoryEntry::Status::Success,
|
: Data::EarnHistoryEntry::Status::Success,
|
||||||
.amount = d.vamount().v,
|
.amount = d.is_failed()
|
||||||
|
? (std::numeric_limits<Data::EarnInt>::max()
|
||||||
|
- d.vamount().v
|
||||||
|
+ 1)
|
||||||
|
: d.vamount().v,
|
||||||
.date = base::unixtime::parse(d.vdate().v),
|
.date = base::unixtime::parse(d.vdate().v),
|
||||||
.provider = qs(d.vprovider()),
|
// .provider = qs(d.vprovider()),
|
||||||
.successDate = d.vtransaction_date()
|
.successDate = d.vtransaction_date()
|
||||||
? base::unixtime::parse(d.vtransaction_date()->v)
|
? base::unixtime::parse(d.vtransaction_date()->v)
|
||||||
: QDateTime(),
|
: QDateTime(),
|
||||||
|
@ -834,7 +838,7 @@ void EarnStatistics::requestBoosts(
|
||||||
.type = Data::EarnHistoryEntry::Type::Return,
|
.type = Data::EarnHistoryEntry::Type::Return,
|
||||||
.amount = d.vamount().v,
|
.amount = d.vamount().v,
|
||||||
.date = base::unixtime::parse(d.vdate().v),
|
.date = base::unixtime::parse(d.vdate().v),
|
||||||
.provider = qs(d.vprovider()),
|
// .provider = qs(d.vprovider()),
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,8 @@ struct PublicForwardsSlice final {
|
||||||
OffsetToken token;
|
OffsetToken token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using EarnInt = uint64;
|
||||||
|
|
||||||
struct EarnHistoryEntry final {
|
struct EarnHistoryEntry final {
|
||||||
enum class Type {
|
enum class Type {
|
||||||
In,
|
In,
|
||||||
|
@ -171,7 +173,7 @@ struct EarnHistoryEntry final {
|
||||||
Type type;
|
Type type;
|
||||||
Status status;
|
Status status;
|
||||||
|
|
||||||
uint64 amount = 0;
|
EarnInt amount = 0;
|
||||||
QDateTime date;
|
QDateTime date;
|
||||||
QDateTime dateTo;
|
QDateTime dateTo;
|
||||||
|
|
||||||
|
@ -196,9 +198,9 @@ struct EarnStatistics final {
|
||||||
}
|
}
|
||||||
Data::StatisticalGraph topHoursGraph;
|
Data::StatisticalGraph topHoursGraph;
|
||||||
Data::StatisticalGraph revenueGraph;
|
Data::StatisticalGraph revenueGraph;
|
||||||
uint64 currentBalance = 0;
|
EarnInt currentBalance = 0;
|
||||||
uint64 availableBalance = 0;
|
EarnInt availableBalance = 0;
|
||||||
uint64 overallRevenue = 0;
|
EarnInt overallRevenue = 0;
|
||||||
float64 usdRate = 0.;
|
float64 usdRate = 0.;
|
||||||
|
|
||||||
EarnHistorySlice firstHistorySlice;
|
EarnHistorySlice firstHistorySlice;
|
||||||
|
|
|
@ -48,7 +48,7 @@ channelEarnHistoryRecipientLabel: FlatLabel(channelEarnOverviewSubMinorLabel) {
|
||||||
}
|
}
|
||||||
channelEarnHistoryMajorLabel: FlatLabel(channelEarnOverviewMajorLabel) {
|
channelEarnHistoryMajorLabel: FlatLabel(channelEarnOverviewMajorLabel) {
|
||||||
style: TextStyle(defaultTextStyle) {
|
style: TextStyle(defaultTextStyle) {
|
||||||
font: font(13px semibold);
|
font: font(14px semibold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channelEarnHistoryMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) {
|
channelEarnHistoryMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) {
|
||||||
|
@ -56,7 +56,7 @@ channelEarnHistoryMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) {
|
||||||
font: font(12px semibold);
|
font: font(12px semibold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channelEarnHistoryMinorLabelSkip: 1px;
|
channelEarnHistoryMinorLabelSkip: 2px;
|
||||||
channelEarnHistoryOuter: margins(0px, 6px, 0px, 6px);
|
channelEarnHistoryOuter: margins(0px, 6px, 0px, 6px);
|
||||||
channelEarnHistoryTwoSkip: 5px;
|
channelEarnHistoryTwoSkip: 5px;
|
||||||
channelEarnHistoryThreeSkip: 3px;
|
channelEarnHistoryThreeSkip: 3px;
|
||||||
|
|
|
@ -46,18 +46,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Info::ChannelEarn {
|
namespace Info::ChannelEarn {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using EarnInt = Data::EarnInt;
|
||||||
|
|
||||||
constexpr auto kMinorPartLength = 9;
|
constexpr auto kMinorPartLength = 9;
|
||||||
constexpr auto kZero = QChar('0');
|
constexpr auto kZero = QChar('0');
|
||||||
constexpr auto kDot = QChar('.');
|
constexpr auto kDot = QChar('.');
|
||||||
|
|
||||||
[[nodiscard]] QString MajorPart(uint64 value) {
|
[[nodiscard]] QString MajorPart(EarnInt value) {
|
||||||
const auto string = QString::number(value);
|
const auto string = QString::number(value);
|
||||||
return (string.size() < kMinorPartLength)
|
return (string.size() < kMinorPartLength)
|
||||||
? QString(kZero)
|
? QString(kZero)
|
||||||
: string.mid(0, kMinorPartLength);
|
: string.mid(0, kMinorPartLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString MinorPart(uint64 value) {
|
[[nodiscard]] QString MinorPart(EarnInt value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return QString(kDot) + kZero;
|
return QString(kDot) + kZero;
|
||||||
}
|
}
|
||||||
|
@ -81,10 +83,10 @@ constexpr auto kDot = QChar('.');
|
||||||
return result.chopped(zeroCount);
|
return result.chopped(zeroCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString ToUsd(uint64 value, float64 rate) {
|
[[nodiscard]] QString ToUsd(EarnInt value, float64 rate) {
|
||||||
constexpr auto kApproximately = QChar(0x2248);
|
constexpr auto kApproximately = QChar(0x2248);
|
||||||
constexpr auto kMultiplier = uint64(1000000000);
|
constexpr auto kMultiplier = EarnInt(1000000000);
|
||||||
const auto multiplier = uint64(rate * kMultiplier);
|
const auto multiplier = EarnInt(rate * kMultiplier);
|
||||||
const auto result = (value * multiplier) / kMultiplier;
|
const auto result = (value * multiplier) / kMultiplier;
|
||||||
return QString(kApproximately)
|
return QString(kApproximately)
|
||||||
+ QChar('$')
|
+ QChar('$')
|
||||||
|
@ -214,7 +216,7 @@ void InnerWidget::fill() {
|
||||||
};
|
};
|
||||||
const auto addEmojiToMajor = [=](
|
const auto addEmojiToMajor = [=](
|
||||||
not_null<Ui::FlatLabel*> label,
|
not_null<Ui::FlatLabel*> label,
|
||||||
uint64 value) {
|
EarnInt value) {
|
||||||
auto emoji = EmojiCurrency(session);
|
auto emoji = EmojiCurrency(session);
|
||||||
label->setMarkedText(
|
label->setMarkedText(
|
||||||
emoji.append(' ').append(MajorPart(value)),
|
emoji.append(' ').append(MajorPart(value)),
|
||||||
|
@ -402,7 +404,7 @@ void InnerWidget::fill() {
|
||||||
Ui::AddSkip(container, st::channelEarnOverviewTitleSkip);
|
Ui::AddSkip(container, st::channelEarnOverviewTitleSkip);
|
||||||
|
|
||||||
const auto addOverview = [&](
|
const auto addOverview = [&](
|
||||||
uint64 value,
|
EarnInt value,
|
||||||
const tr::phrase<> &text) {
|
const tr::phrase<> &text) {
|
||||||
const auto line = container->add(
|
const auto line = container->add(
|
||||||
Ui::CreateSkipWidget(container, 0),
|
Ui::CreateSkipWidget(container, 0),
|
||||||
|
@ -506,20 +508,6 @@ void InnerWidget::fill() {
|
||||||
|
|
||||||
Ui::AddSkip(container);
|
Ui::AddSkip(container);
|
||||||
|
|
||||||
const auto input = container->add(
|
|
||||||
object_ptr<Ui::InputField>(
|
|
||||||
container,
|
|
||||||
st::defaultComposeFiles.caption,
|
|
||||||
Ui::InputField::Mode::MultiLine,
|
|
||||||
tr::lng_channel_earn_balance_placeholder()),
|
|
||||||
st::boxRowPadding);
|
|
||||||
_focusRequested.events(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
input->setFocusFast();
|
|
||||||
}, input->lifetime());
|
|
||||||
|
|
||||||
Ui::AddSkip(container);
|
|
||||||
|
|
||||||
const auto &stButton = st::defaultActiveButton;
|
const auto &stButton = st::defaultActiveButton;
|
||||||
const auto button = container->add(
|
const auto button = container->add(
|
||||||
object_ptr<Ui::RoundButton>(
|
object_ptr<Ui::RoundButton>(
|
||||||
|
@ -552,49 +540,9 @@ void InnerWidget::fill() {
|
||||||
stButton.textFg->c,
|
stButton.textFg->c,
|
||||||
anim::interpolateF(.5, 1., value)));
|
anim::interpolateF(.5, 1., value)));
|
||||||
};
|
};
|
||||||
colorText(0);
|
colorText(1.);
|
||||||
|
|
||||||
rpl::single(
|
|
||||||
rpl::empty_value()
|
|
||||||
) | rpl::then(
|
|
||||||
input->changes()
|
|
||||||
) | rpl::map([=, end = (u".ton"_q)] {
|
|
||||||
const auto text = input->getLastText();
|
|
||||||
return (text.size() == 48)
|
|
||||||
|| text.endsWith(end, Qt::CaseInsensitive);
|
|
||||||
}) | rpl::distinct_until_changed(
|
|
||||||
) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
fadeAnimation->stop();
|
|
||||||
const auto from = enabled ? 0. : 1.;
|
|
||||||
const auto to = enabled ? 1. : 0.;
|
|
||||||
fadeAnimation->start(colorText, from, to, st::slideWrapDuration);
|
|
||||||
|
|
||||||
button->setAttribute(Qt::WA_TransparentForMouseEvents, !enabled);
|
|
||||||
}, button->lifetime());
|
|
||||||
|
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
_show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
|
||||||
box->setTitle(tr::lng_channel_earn_balance_button());
|
|
||||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
tr::lng_channel_earn_transfer_sure_about1(tr::now),
|
|
||||||
st::boxLabel));
|
|
||||||
Ui::AddSkip(box->verticalLayout());
|
|
||||||
AddRecipient(
|
|
||||||
box,
|
|
||||||
Ui::Text::Wrapped(
|
|
||||||
{ input->getLastText() },
|
|
||||||
EntityType::Code));
|
|
||||||
Ui::AddSkip(box->verticalLayout());
|
|
||||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
|
||||||
box,
|
|
||||||
tr::lng_channel_earn_transfer_sure_about2(tr::now),
|
|
||||||
st::boxLabel));
|
|
||||||
box->addButton(
|
|
||||||
tr::lng_send_button(),
|
|
||||||
[=] { box->closeBox(); });
|
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
Ui::ToggleChildrenVisibility(button, true);
|
Ui::ToggleChildrenVisibility(button, true);
|
||||||
|
|
||||||
|
@ -642,17 +590,28 @@ void InnerWidget::fill() {
|
||||||
Ui::AddSkip(inner, st::channelEarnHistoryTwoSkip);
|
Ui::AddSkip(inner, st::channelEarnHistoryTwoSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto dateText = !entry.dateTo.isNull()
|
const auto isFailed = entry.status
|
||||||
|
== Data::EarnHistoryEntry::Status::Failed;
|
||||||
|
const auto isPending = entry.status
|
||||||
|
== Data::EarnHistoryEntry::Status::Pending;
|
||||||
|
const auto dateText = (!entry.dateTo.isNull() || isFailed)
|
||||||
? (FormatDate(entry.date)
|
? (FormatDate(entry.date)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ QChar(8212)
|
+ QChar(8212)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ FormatDate(entry.dateTo))
|
+ (isFailed
|
||||||
|
? tr::lng_channel_earn_history_out_failed(tr::now)
|
||||||
|
: FormatDate(entry.dateTo)))
|
||||||
|
: isPending
|
||||||
|
? tr::lng_channel_earn_history_pending(tr::now)
|
||||||
: FormatDate(entry.date);
|
: FormatDate(entry.date);
|
||||||
inner->add(object_ptr<Ui::FlatLabel>(
|
inner->add(object_ptr<Ui::FlatLabel>(
|
||||||
inner,
|
inner,
|
||||||
dateText,
|
dateText,
|
||||||
st::channelEarnHistorySubLabel));
|
st::channelEarnHistorySubLabel)
|
||||||
|
)->setTextColorOverride(isFailed
|
||||||
|
? std::make_optional<QColor>(st::menuIconAttentionColor->c)
|
||||||
|
: std::nullopt);
|
||||||
|
|
||||||
const auto color = (isIn
|
const auto color = (isIn
|
||||||
? st::boxTextFgGood
|
? st::boxTextFgGood
|
||||||
|
@ -826,6 +785,8 @@ void InnerWidget::fill() {
|
||||||
entry,
|
entry,
|
||||||
(entry.type == Data::EarnHistoryEntry::Type::In)
|
(entry.type == Data::EarnHistoryEntry::Type::In)
|
||||||
? tr::lng_channel_earn_history_in
|
? tr::lng_channel_earn_history_in
|
||||||
|
: (entry.type == Data::EarnHistoryEntry::Type::Return)
|
||||||
|
? tr::lng_channel_earn_history_return
|
||||||
: tr::lng_channel_earn_history_out);
|
: tr::lng_channel_earn_history_out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue