Improved style of boosts info.

This commit is contained in:
23rd 2023-10-21 00:20:59 +03:00 committed by John Preston
parent d3aa0664a7
commit daf76c1bc2
8 changed files with 76 additions and 33 deletions

View file

@ -32,7 +32,7 @@ void AddHeader(
tr::phrase<> text) {
const auto header = content->add(
object_ptr<Statistic::Header>(content),
st::statisticsLayerMargins + st::statisticsChartHeaderPadding);
st::statisticsLayerMargins + st::boostsChartHeaderPadding);
header->resizeToWidth(header->width());
header->setTitle(text(tr::now));
header->setSubTitle({});
@ -43,7 +43,7 @@ void FillOverview(
const Data::BoostStatus &status) {
const auto &stats = status.overview;
::Settings::AddSkip(content, st::statisticsLayerOverviewMargins.top());
::Settings::AddSkip(content, st::boostsLayerOverviewMargins.top());
AddHeader(content, tr::lng_stats_overview_title);
::Settings::AddSkip(content);
@ -125,7 +125,7 @@ void FillOverview(
) | rpl::start_with_next([=](const QSize &s) {
const auto halfWidth = s.width() / 2;
{
const auto &p = st::statisticsOverviewValuePadding;
const auto &p = st::boostsOverviewValuePadding;
topLeftLabel->moveToLeft(p.left(), p.top());
}
topRightLabel->moveToLeft(
@ -138,7 +138,7 @@ void FillOverview(
topRightLabel->x(),
bottomLeftLabel->y());
}, container->lifetime());
::Settings::AddSkip(content, st::statisticsLayerOverviewMargins.bottom());
::Settings::AddSkip(content, st::boostsLayerOverviewMargins.bottom());
}
void FillShareLink(
@ -161,7 +161,7 @@ void FillShareLink(
nullptr);
content->add(
label->take(),
st::inviteLinkFieldPadding);
st::boostsLinkFieldPadding);
label->clicks(
) | rpl::start_with_next(copyLink, label->lifetime());
@ -169,7 +169,7 @@ void FillShareLink(
object_ptr<Ui::VerticalLayout>(content));
Ui::AddCopyShareLinkButtons(copyShareWrap, copyLink, shareLink);
copyShareWrap->widgetAt(0)->showChildren();
::Settings::AddSkip(content, st::inviteLinkFieldPadding.bottom());
::Settings::AddSkip(content, st::boostsLinkFieldPadding.bottom());
}
} // namespace
@ -210,7 +210,8 @@ InnerWidget::InnerWidget(
= status.overview.nextLevelBoostCount,
.mine = status.overview.isBoosted,
}
});
},
st::statisticsLimitsLinePadding);
inner->add(object_ptr<Ui::DividerLabel>(
inner,
std::move(dividerContent),
@ -228,7 +229,8 @@ InnerWidget::InnerWidget(
using PeerPtr = not_null<PeerData*>;
const auto header = inner->add(
object_ptr<Statistic::Header>(inner),
st::statisticsLayerMargins);
st::statisticsLayerMargins
+ st::boostsChartHeaderPadding);
header->resizeToWidth(header->width());
header->setTitle(tr::lng_boosts_list_title(
tr::now,
@ -250,6 +252,7 @@ InnerWidget::InnerWidget(
::Settings::AddSkip(inner);
AddHeader(inner, tr::lng_boosts_link_title);
::Settings::AddSkip(inner, st::boostsLinkSkip);
FillShareLink(inner, _show, status.link, peer);
::Settings::AddSkip(inner);
::Settings::AddDividerText(inner, tr::lng_boosts_link_subtext());

View file

@ -355,6 +355,7 @@ BoostsController::BoostsController(BoostsDescriptor d)
, _showPeerInfo(std::move(d.showPeerInfo))
, _api(d.peer)
, _firstSlice(std::move(d.firstSlice)) {
PeerListController::setStyleOverrides(&st::boostsListBox);
}
Main::Session &BoostsController::session() const {

View file

@ -109,13 +109,35 @@ statisticsShowMoreButton: SettingsButton(defaultSettingsButton) {
textFg: lightButtonFg;
textFgOver: lightButtonFgOver;
padding: margins(73px, 10px, 22px, 8px);
padding: margins(70px, 10px, 22px, 8px);
}
statisticsShowMoreButtonArrowPosition: point(29px, 13px);
statisticsShowMoreButtonArrowSize: 7px;
statisticsLimitsDividerPadding: margins(22px, -26px, 22px, 16px);
statisticsLimitsDividerPadding: margins(22px, -26px, 22px, 22px);
statisticsLimitsLinePadding: margins(0px, -2px, 0px, 0px);
boostsLayerOverviewMargins: margins(0px, 12px, 0px, 4px);
boostsOverviewValuePadding: margins(2px, 0px, 0px, 0px);
boostsChartHeaderPadding: margins(2px, 1px, 0px, 1px);
boostsListBox: PeerList(defaultPeerList) {
padding: margins(
0px,
7px,
0px,
7px);
item: PeerListItem(defaultPeerListItem) {
height: 52px;
photoPosition: point(18px, 4px);
namePosition: point(70px, 6px);
statusPosition: point(70px, 26px);
photoSize: 42px;
}
}
boostsLinkSkip: 5px;
boostsLinkFieldPadding: margins(22px, 7px, 22px, 12px);
boostsButton: SettingsButton(defaultSettingsButton) {
textFg: lightButtonFg;
textFgOver: lightButtonFgOver;

View file

@ -60,7 +60,8 @@ void BoostBox(
BoxShowFinishes(box),
state->you.value(),
box->verticalLayout(),
data);
data,
st::boxRowPadding);
box->addTopButton(st::boxTitleClose, [=] { box->closeBox(); });
@ -176,7 +177,8 @@ void FillBoostLimit(
rpl::producer<> showFinished,
rpl::producer<bool> you,
not_null<VerticalLayout*> container,
BoostBoxData data) {
BoostBoxData data,
style::margins limitLinePadding) {
const auto full = !data.boost.nextLevelBoosts;
if (data.boost.mine && data.boost.boosts > 0) {
@ -265,7 +267,8 @@ void FillBoostLimit(
max,
true,
nullptr,
&st::premiumIconBoost);
&st::premiumIconBoost,
limitLinePadding);
addSkip(st::premiumLineTextSkip);
const auto level = [](int level) {
@ -284,7 +287,8 @@ void FillBoostLimit(
.rightLabel = level(data.boost.level + 1),
.dynamic = true,
},
std::move(ratioValue));
std::move(ratioValue),
limitLinePadding);
}
} // namespace Ui

View file

@ -34,6 +34,7 @@ void FillBoostLimit(
rpl::producer<> showFinished,
rpl::producer<bool> you,
not_null<VerticalLayout*> container,
BoostBoxData data);
BoostBoxData data,
style::margins limitLinePadding);
} // namespace Ui

View file

@ -95,6 +95,7 @@ defaultPremiumBubble: PremiumBubble {
tailSize: size(21px, 7px);
font: font(19px);
}
premiumLineRadius: 5px;
premiumLineTextSkip: 11px;
premiumInfographicPadding: margins(0px, 10px, 0px, 15px);

View file

@ -20,11 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/painter.h"
#include "styles/style_premium.h"
#include "styles/style_boxes.h"
#include "styles/style_settings.h"
#include "styles/style_layers.h"
#include "styles/style_widgets.h"
#include "styles/style_premium.h"
#include "styles/style_settings.h"
#include "styles/style_window.h"
#include <QtGui/QBrush>
@ -393,7 +392,8 @@ public:
int maxCounter,
bool premiumPossible,
rpl::producer<> showFinishes,
const style::icon *icon);
const style::icon *icon,
const style::margins &outerPadding);
protected:
void paintEvent(QPaintEvent *e) override;
@ -418,6 +418,7 @@ private:
Bubble _bubble;
const int _maxBubbleWidth;
const bool _premiumPossible;
const style::margins _outerPadding;
Ui::Animations::Simple _appearanceAnimation;
QSize _spaceForDeflection;
@ -441,7 +442,8 @@ BubbleWidget::BubbleWidget(
int maxCounter,
bool premiumPossible,
rpl::producer<> showFinishes,
const style::icon *icon)
const style::icon *icon,
const style::margins &outerPadding)
: RpWidget(parent)
, _st(st)
, _state(std::move(state))
@ -454,6 +456,7 @@ BubbleWidget::BubbleWidget(
premiumPossible)
, _maxBubbleWidth(_bubble.countMaxWidth(_maxCounter))
, _premiumPossible(premiumPossible)
, _outerPadding(outerPadding)
, _deflection(kDeflection)
, _stepBeforeDeflection(kStepBeforeDeflection)
, _stepAfterDeflection(kStepAfterDeflection) {
@ -484,10 +487,9 @@ BubbleWidget::BubbleWidget(
void BubbleWidget::animateTo(BubbleRowState state) {
const auto parent = parentWidget();
const auto computeLeft = [=](float64 pointRatio, float64 animProgress) {
const auto &padding = st::boxRowPadding;
const auto halfWidth = (_maxBubbleWidth / 2);
const auto left = padding.left();
const auto right = padding.right();
const auto left = _outerPadding.left();
const auto right = _outerPadding.right();
const auto available = parent->width() - left - right;
const auto delta = (pointRatio - _animatingFromResultRatio);
const auto center = available
@ -497,7 +499,7 @@ void BubbleWidget::animateTo(BubbleRowState state) {
const auto moveEndPoint = state.ratio;
const auto computeEdge = [=] {
return parent->width()
- st::boxRowPadding.right()
- _outerPadding.right()
- _maxBubbleWidth;
};
struct LeftEdge final {
@ -506,7 +508,7 @@ void BubbleWidget::animateTo(BubbleRowState state) {
};
const auto leftEdge = [&]() -> LeftEdge {
const auto finish = computeLeft(moveEndPoint, 1.);
const auto &padding = st::boxRowPadding;
const auto &padding = _outerPadding;
if (finish <= padding.left()) {
const auto halfWidth = (_maxBubbleWidth / 2);
const auto goodPointRatio = float64(halfWidth)
@ -834,7 +836,10 @@ void Line::recache(const QSize &s) {
const auto pathRound = [&](int width) {
auto result = QPainterPath();
result.addRoundedRect(r(width), st::buttonRadius, st::buttonRadius);
result.addRoundedRect(
r(width),
st::premiumLineRadius,
st::premiumLineRadius);
return result;
};
const auto width = s.width();
@ -904,7 +909,8 @@ void AddBubbleRow(
max,
premiumPossible,
ProcessTextFactory(phrase),
icon);
icon,
st::boxRowPadding);
}
void AddBubbleRow(
@ -915,7 +921,8 @@ void AddBubbleRow(
int max,
bool premiumPossible,
Fn<QString(int)> text,
const style::icon *icon) {
const style::icon *icon,
const style::margins &outerPadding) {
const auto container = parent->add(
object_ptr<Ui::FixedHeightWidget>(parent, 0));
const auto bubble = Ui::CreateChild<BubbleWidget>(
@ -926,7 +933,8 @@ void AddBubbleRow(
max,
premiumPossible,
std::move(showFinishes),
icon);
icon,
outerPadding);
rpl::combine(
container->sizeValue(),
bubble->sizeValue()
@ -967,10 +975,11 @@ void AddLimitRow(
not_null<Ui::VerticalLayout*> parent,
const style::PremiumLimits &st,
LimitRowLabels labels,
rpl::producer<float64> ratio) {
rpl::producer<float64> ratio,
const style::margins &padding) {
parent->add(
object_ptr<Line>(parent, st, std::move(labels), std::move(ratio)),
st::boxRowPadding);
padding);
}
void AddAccountsRow(

View file

@ -65,7 +65,8 @@ void AddBubbleRow(
int max,
bool premiumPossible,
Fn<QString(int)> text,
const style::icon *icon);
const style::icon *icon,
const style::margins &outerPadding);
void AddLimitRow(
not_null<Ui::VerticalLayout*> parent,
@ -93,7 +94,8 @@ void AddLimitRow(
not_null<Ui::VerticalLayout*> parent,
const style::PremiumLimits &st,
LimitRowLabels labels,
rpl::producer<float64> ratio);
rpl::producer<float64> ratio,
const style::margins &padding);
struct AccountsRowArgs final {
std::shared_ptr<Ui::RadiobuttonGroup> group;