From 5d2726036f7fcadf9faa9bb1c6c74865c08a4a38 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 21 Mar 2024 05:04:14 +0300 Subject: [PATCH] Slightly improved style of channel earn info section. --- .../earn/channel_earn.style | 1 + .../earn/info_earn_inner_widget.cpp | 141 +++++++++--------- 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style index f474c738c..1dea3e14c 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style +++ b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style @@ -10,6 +10,7 @@ using "boxes/boxes.style"; channelEarnLearnArrowMargins: margins(-2px, 5px, 0px, 0px); +channelEarnOverviewTitleSkip: 11px; channelEarnOverviewMajorLabel: FlatLabel(defaultFlatLabel) { maxHeight: 30px; style: TextStyle(defaultTextStyle) { diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp index ff1422e26..bb354144d 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp @@ -54,12 +54,14 @@ namespace { void AddHeader( not_null content, tr::phrase<> text) { + Ui::AddSkip(content); const auto header = content->add( - object_ptr(content), - st::statisticsLayerMargins + st::boostsChartHeaderPadding); + object_ptr( + content, + text(), + st::channelEarnSemiboldLabel), + st::boxRowPadding); header->resizeToWidth(header->width()); - header->setTitle(text(tr::now)); - header->setSubTitle({}); } void AddRecipient(not_null box, const TextWithEntities &t) { @@ -194,6 +196,69 @@ void InnerWidget::fill() { }; addAboutWithLearn(tr::lng_channel_earn_about); Ui::AddSkip(container); + { + AddHeader(container, tr::lng_channel_earn_overview_title); + Ui::AddSkip(container, st::channelEarnOverviewTitleSkip); + + 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( + line, + st::channelEarnOverviewMajorLabel); + AddEmojiToMajor(majorLabel, session, value); + const auto minorLabel = Ui::CreateChild( + line, + QString::number(value - int64(value)).mid(1), + st::channelEarnOverviewMinorLabel); + const auto secondMinorLabel = Ui::CreateChild( + line, + QString(kApproximately) + + 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::channelEarnOverviewSubMinorLabelPos.x(), + st::channelEarnOverviewSubMinorLabelPos.y()); + }, minorLabel->lifetime()); + + Ui::AddSkip(container); + const auto sub = container->add( + object_ptr( + 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); { const auto value = 54.12; // Debug. Ui::AddSkip(container); @@ -332,79 +397,15 @@ void InnerWidget::fill() { Ui::AddSkip(container); Ui::AddSkip(container); - } - addAboutWithLearn(tr::lng_channel_earn_balance_about); - Ui::AddSkip(container); - { - Ui::AddSkip(container); - AddHeader(container, tr::lng_channel_earn_overview_title); - Ui::AddSkip(container); - Ui::AddSkip(container); - - 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( - line, - st::channelEarnOverviewMajorLabel); - AddEmojiToMajor(majorLabel, session, value); - const auto minorLabel = Ui::CreateChild( - line, - QString::number(value - int64(value)).mid(1), - st::channelEarnOverviewMinorLabel); - const auto secondMinorLabel = Ui::CreateChild( - line, - QString(kApproximately) - + 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::channelEarnOverviewSubMinorLabelPos.x(), - st::channelEarnOverviewSubMinorLabelPos.y()); - }, minorLabel->lifetime()); - - Ui::AddSkip(container); - const auto sub = container->add( - object_ptr( - 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); + addAboutWithLearn(tr::lng_channel_earn_balance_about); Ui::AddSkip(container); } Ui::AddSkip(container); Ui::AddDivider(container); Ui::AddSkip(container); { - Ui::AddSkip(container); AddHeader(container, tr::lng_channel_earn_history_title); Ui::AddSkip(container); - Ui::AddSkip(container); struct HistoryEntry final { TimeId from = 0; @@ -690,7 +691,6 @@ void InnerWidget::fill() { Ui::AddSkip(inner); const auto line = inner->add(object_ptr(inner)); Ui::AddSkip(inner); - Ui::AddSkip(inner); const auto left = Ui::CreateChild( line, tr::lng_channel_earn_cpm_min(), @@ -779,6 +779,7 @@ void InnerWidget::fill() { wrap->toggle(toggled, anim::type::normal); }, container->lifetime()); + Ui::AddSkip(container); Ui::AddDividerText(container, tr::lng_channel_earn_off_about()); } Ui::AddSkip(container);