mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added initial overview subsection to channel earn info section.
This commit is contained in:
parent
a45a9e6515
commit
588624e7a9
2 changed files with 129 additions and 0 deletions
|
@ -9,3 +9,24 @@ using "ui/basic.style";
|
||||||
using "boxes/boxes.style";
|
using "boxes/boxes.style";
|
||||||
|
|
||||||
channelEarnLearnArrowMargins: margins(-2px, 5px, 0px, 0px);
|
channelEarnLearnArrowMargins: margins(-2px, 5px, 0px, 0px);
|
||||||
|
|
||||||
|
channelEarnOverviewMajorLabel: FlatLabel(defaultFlatLabel) {
|
||||||
|
maxHeight: 30px;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(15px semibold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
channelEarnOverviewMinorLabel: FlatLabel(channelEarnOverviewMajorLabel) {
|
||||||
|
maxHeight: 30px;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(12px semibold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
channelEarnOverviewMinorLabelSkip: 3px;
|
||||||
|
channelEarnOverviewSubMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) {
|
||||||
|
textFg: windowSubTextFg;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(13px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
channelEarnOverviewSubMinorLabelSkip: 4px;
|
||||||
|
|
|
@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/channel_statistics/earn/info_earn_inner_widget.h"
|
#include "info/channel_statistics/earn/info_earn_inner_widget.h"
|
||||||
|
|
||||||
|
#include "base/random.h"
|
||||||
|
#include "chat_helpers/stickers_emoji_pack.h"
|
||||||
#include "core/ui_integration.h" // Core::MarkedTextContext.
|
#include "core/ui_integration.h" // Core::MarkedTextContext.
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -15,15 +17,52 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "statistics/widgets/chart_header_widget.h"
|
||||||
|
#include "ui/rect.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/vertical_list.h"
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "styles/style_channel_earn.h"
|
#include "styles/style_channel_earn.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_statistics.h"
|
||||||
|
|
||||||
namespace Info::ChannelEarn {
|
namespace Info::ChannelEarn {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
void AddHeader(
|
||||||
|
not_null<Ui::VerticalLayout*> content,
|
||||||
|
tr::phrase<> text) {
|
||||||
|
const auto header = content->add(
|
||||||
|
object_ptr<Statistic::Header>(content),
|
||||||
|
st::statisticsLayerMargins + st::boostsChartHeaderPadding);
|
||||||
|
header->resizeToWidth(header->width());
|
||||||
|
header->setTitle(text(tr::now));
|
||||||
|
header->setSubTitle({});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddEmojiToMajor(
|
||||||
|
not_null<Ui::FlatLabel*> label,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
float64 value) {
|
||||||
|
auto emoji = TextWithEntities{
|
||||||
|
.text = (QString(QChar(0xD83D)) + QChar(0xDC8E)),
|
||||||
|
};
|
||||||
|
if (const auto e = Ui::Emoji::Find(emoji.text)) {
|
||||||
|
const auto sticker = session->emojiStickersPack().stickerForEmoji(e);
|
||||||
|
if (sticker.document) {
|
||||||
|
emoji = Data::SingleCustomEmoji(sticker.document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label->setMarkedText(
|
||||||
|
emoji.append(' ').append(QString::number(int64(value))),
|
||||||
|
Core::MarkedTextContext{
|
||||||
|
.session = session,
|
||||||
|
.customEmojiRepaint = [label] { label->update(); },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
InnerWidget::InnerWidget(
|
InnerWidget::InnerWidget(
|
||||||
|
@ -76,6 +115,75 @@ void InnerWidget::fill() {
|
||||||
st::defaultBoxDividerLabelPadding,
|
st::defaultBoxDividerLabelPadding,
|
||||||
RectPart::Top | RectPart::Bottom));
|
RectPart::Top | RectPart::Bottom));
|
||||||
}
|
}
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
Ui::AddDivider(container);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
{
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
AddHeader(container, tr::lng_channel_earn_overview_title);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
|
||||||
|
const auto multiplier = 3.8; // Debug.
|
||||||
|
const auto addOverviewEntry = [&](
|
||||||
|
float64 value,
|
||||||
|
const tr::phrase<> &text) {
|
||||||
|
value = base::RandomIndex(1000000) / 1000.; // Debug.
|
||||||
|
const auto line = container->add(
|
||||||
|
Ui::CreateSkipWidget(container, 0),
|
||||||
|
st::boxRowPadding);
|
||||||
|
const auto majorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
line,
|
||||||
|
st::channelEarnOverviewMajorLabel);
|
||||||
|
AddEmojiToMajor(majorLabel, session, value);
|
||||||
|
const auto minorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
line,
|
||||||
|
QString::number(value - int64(value)).mid(1),
|
||||||
|
st::channelEarnOverviewMinorLabel);
|
||||||
|
const auto secondMinorLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
line,
|
||||||
|
QString(QChar(0x2248))
|
||||||
|
+ QChar('$')
|
||||||
|
+ QString::number(value * multiplier),
|
||||||
|
st::channelEarnOverviewSubMinorLabel);
|
||||||
|
rpl::combine(
|
||||||
|
line->widthValue(),
|
||||||
|
majorLabel->sizeValue()
|
||||||
|
) | rpl::start_with_next([=](int available, const QSize &size) {
|
||||||
|
line->resize(line->width(), size.height());
|
||||||
|
minorLabel->moveToLeft(
|
||||||
|
size.width(),
|
||||||
|
st::channelEarnOverviewMinorLabelSkip);
|
||||||
|
secondMinorLabel->resizeToWidth(available
|
||||||
|
- size.width()
|
||||||
|
- minorLabel->width());
|
||||||
|
secondMinorLabel->moveToLeft(
|
||||||
|
rect::right(minorLabel)
|
||||||
|
+ st::channelEarnOverviewSubMinorLabelSkip,
|
||||||
|
st::channelEarnOverviewSubMinorLabelSkip);
|
||||||
|
}, minorLabel->lifetime());
|
||||||
|
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
const auto sub = container->add(
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
container,
|
||||||
|
text(),
|
||||||
|
st::channelEarnOverviewSubMinorLabel),
|
||||||
|
st::boxRowPadding);
|
||||||
|
sub->setTextColorOverride(st::windowSubTextFg->c);
|
||||||
|
};
|
||||||
|
addOverviewEntry(0, tr::lng_channel_earn_available);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
addOverviewEntry(0, tr::lng_channel_earn_reward);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
addOverviewEntry(0, tr::lng_channel_earn_total);
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
}
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
Ui::AddDivider(container);
|
||||||
|
Ui::AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::saveState(not_null<Memento*> memento) {
|
void InnerWidget::saveState(not_null<Memento*> memento) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue