mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Rounded earn values from overview to two decimal digits.
This commit is contained in:
parent
68cc42047e
commit
46ab553fa5
6 changed files with 29 additions and 12 deletions
|
@ -116,6 +116,7 @@ void InnerWidget::fill() {
|
||||||
const auto container = this;
|
const auto container = this;
|
||||||
const auto &data = _state;
|
const auto &data = _state;
|
||||||
const auto multiplier = data.usdRate * Data::kEarnMultiplier;
|
const auto multiplier = data.usdRate * Data::kEarnMultiplier;
|
||||||
|
constexpr auto kMinorLength = 3;
|
||||||
|
|
||||||
auto availableBalanceValue = rpl::single(
|
auto availableBalanceValue = rpl::single(
|
||||||
data.availableBalance
|
data.availableBalance
|
||||||
|
@ -166,7 +167,7 @@ void InnerWidget::fill() {
|
||||||
std::move(
|
std::move(
|
||||||
value
|
value
|
||||||
) | rpl::map([=](uint64 v) {
|
) | rpl::map([=](uint64 v) {
|
||||||
return v ? ToUsd(v, multiplier) : QString();
|
return v ? ToUsd(v, multiplier, kMinorLength) : QString();
|
||||||
}),
|
}),
|
||||||
st::channelEarnOverviewSubMinorLabel);
|
st::channelEarnOverviewSubMinorLabel);
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
@ -243,7 +244,7 @@ void InnerWidget::fill() {
|
||||||
return !dt.isNull() || (!_state.isWithdrawalEnabled);
|
return !dt.isNull() || (!_state.isWithdrawalEnabled);
|
||||||
}),
|
}),
|
||||||
rpl::duplicate(availableBalanceValue) | rpl::map([=](uint64 v) {
|
rpl::duplicate(availableBalanceValue) | rpl::map([=](uint64 v) {
|
||||||
return v ? ToUsd(v, multiplier) : QString();
|
return v ? ToUsd(v, multiplier, kMinorLength) : QString();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,10 @@ QString MinorPart(EarnInt value) {
|
||||||
return result.chopped(zeroCount);
|
return result.chopped(zeroCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ToUsd(EarnInt value, float64 rate) {
|
QString ToUsd(
|
||||||
|
Data::EarnInt value,
|
||||||
|
float64 rate,
|
||||||
|
int afterFloat) {
|
||||||
constexpr auto kApproximately = QChar(0x2248);
|
constexpr auto kApproximately = QChar(0x2248);
|
||||||
|
|
||||||
const auto result = value
|
const auto result = value
|
||||||
|
@ -56,7 +59,9 @@ QString ToUsd(EarnInt value, float64 rate) {
|
||||||
return QString(kApproximately)
|
return QString(kApproximately)
|
||||||
+ QChar('$')
|
+ QChar('$')
|
||||||
+ MajorPart(result)
|
+ MajorPart(result)
|
||||||
+ MinorPart(result);
|
+ ((afterFloat > 0)
|
||||||
|
? MinorPart(result).left(afterFloat)
|
||||||
|
: MinorPart(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Info::ChannelEarn
|
} // namespace Info::ChannelEarn
|
||||||
|
|
|
@ -13,6 +13,9 @@ namespace Info::ChannelEarn {
|
||||||
|
|
||||||
[[nodiscard]] QString MajorPart(Data::EarnInt value);
|
[[nodiscard]] QString MajorPart(Data::EarnInt value);
|
||||||
[[nodiscard]] QString MinorPart(Data::EarnInt value);
|
[[nodiscard]] QString MinorPart(Data::EarnInt value);
|
||||||
[[nodiscard]] QString ToUsd(Data::EarnInt value, float64 rate);
|
[[nodiscard]] QString ToUsd(
|
||||||
|
Data::EarnInt value,
|
||||||
|
float64 rate,
|
||||||
|
int afterFloat);
|
||||||
|
|
||||||
} // namespace Info::ChannelEarn
|
} // namespace Info::ChannelEarn
|
||||||
|
|
|
@ -374,6 +374,7 @@ void InnerWidget::fill() {
|
||||||
) | rpl::map([this] { return _state.creditsEarn; })
|
) | rpl::map([this] { return _state.creditsEarn; })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
constexpr auto kMinorLength = 3;
|
||||||
constexpr auto kMinus = QChar(0x2212);
|
constexpr auto kMinus = QChar(0x2212);
|
||||||
//constexpr auto kApproximately = QChar(0x2248);
|
//constexpr auto kApproximately = QChar(0x2248);
|
||||||
const auto multiplier = data.usdRate;
|
const auto multiplier = data.usdRate;
|
||||||
|
@ -381,7 +382,7 @@ void InnerWidget::fill() {
|
||||||
const auto creditsToUsdMap = [=](EarnInt c) {
|
const auto creditsToUsdMap = [=](EarnInt c) {
|
||||||
const auto creditsMultiplier = _state.creditsEarn.usdRate
|
const auto creditsMultiplier = _state.creditsEarn.usdRate
|
||||||
* Data::kEarnMultiplier;
|
* Data::kEarnMultiplier;
|
||||||
return c ? ToUsd(c, creditsMultiplier) : QString();
|
return c ? ToUsd(c, creditsMultiplier, 0) : QString();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto session = &_peer->session();
|
const auto session = &_peer->session();
|
||||||
|
@ -715,14 +716,18 @@ void InnerWidget::fill() {
|
||||||
{});
|
{});
|
||||||
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
rpl::duplicate(currencyValue) | rpl::map(MinorPart),
|
rpl::duplicate(currencyValue) | rpl::map([=](EarnInt v) {
|
||||||
|
return MinorPart(v).left(kMinorLength);
|
||||||
|
}),
|
||||||
st::channelEarnOverviewMinorLabel);
|
st::channelEarnOverviewMinorLabel);
|
||||||
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
std::move(
|
std::move(
|
||||||
currencyValue
|
currencyValue
|
||||||
) | rpl::map([=](EarnInt value) {
|
) | rpl::map([=](EarnInt value) {
|
||||||
return value ? ToUsd(value, multiplier) : QString();
|
return value
|
||||||
|
? ToUsd(value, multiplier, kMinorLength)
|
||||||
|
: QString();
|
||||||
}),
|
}),
|
||||||
st::channelEarnOverviewSubMinorLabel);
|
st::channelEarnOverviewSubMinorLabel);
|
||||||
|
|
||||||
|
@ -883,7 +888,7 @@ void InnerWidget::fill() {
|
||||||
container,
|
container,
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
container,
|
container,
|
||||||
ToUsd(value, multiplier),
|
ToUsd(value, multiplier, 0),
|
||||||
st::channelEarnOverviewSubMinorLabel)));
|
st::channelEarnOverviewSubMinorLabel)));
|
||||||
|
|
||||||
Ui::AddSkip(container);
|
Ui::AddSkip(container);
|
||||||
|
|
|
@ -43,7 +43,7 @@ void ChartRulersView::setChartData(
|
||||||
return FormatF(value / float64(Data::kEarnMultiplier));
|
return FormatF(value / float64(Data::kEarnMultiplier));
|
||||||
};
|
};
|
||||||
_rightCustomCaption = [=, rate = chartData.currencyRate](float64 v) {
|
_rightCustomCaption = [=, rate = chartData.currencyRate](float64 v) {
|
||||||
return Info::ChannelEarn::ToUsd(v, rate);
|
return Info::ChannelEarn::ToUsd(v, rate, 0);
|
||||||
};
|
};
|
||||||
_rightPen = QPen(st::windowSubTextFg);
|
_rightPen = QPen(st::windowSubTextFg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,10 @@ PointDetailsWidget::PointDetailsWidget(
|
||||||
QString::number(value / multiplier));
|
QString::number(value / multiplier));
|
||||||
const auto usdText = Ui::Text::String(
|
const auto usdText = Ui::Text::String(
|
||||||
_textStyle,
|
_textStyle,
|
||||||
Info::ChannelEarn::ToUsd(value, _chartData.currencyRate));
|
Info::ChannelEarn::ToUsd(
|
||||||
|
value,
|
||||||
|
_chartData.currencyRate,
|
||||||
|
0));
|
||||||
const auto width = std::max(
|
const auto width = std::max(
|
||||||
usdText.maxWidth(),
|
usdText.maxWidth(),
|
||||||
valueText.maxWidth());
|
valueText.maxWidth());
|
||||||
|
@ -351,7 +354,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
_textStyle,
|
_textStyle,
|
||||||
Info::ChannelEarn::ToUsd(
|
Info::ChannelEarn::ToUsd(
|
||||||
dataLine.y[xIndex],
|
dataLine.y[xIndex],
|
||||||
_chartData.currencyRate));
|
_chartData.currencyRate, 0));
|
||||||
}
|
}
|
||||||
_lines.push_back(std::move(textLine));
|
_lines.push_back(std::move(textLine));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue