Improve accounts limit box.

This commit is contained in:
John Preston 2022-06-14 14:54:30 +04:00
parent 6d8012f13a
commit 4de71408a2
3 changed files with 37 additions and 7 deletions

View file

@ -977,13 +977,21 @@ void AccountsLimitBox(
BoxShowFinishes(box), BoxShowFinishes(box),
0, 0,
current, current,
(current > defaultLimit) ? current : (defaultLimit * 2), (!premiumPossible
? (current * 2)
: (current > defaultLimit)
? (current + 1)
: (defaultLimit * 2)),
premiumPossible, premiumPossible,
std::nullopt, std::nullopt,
&st::premiumIconAccounts); &st::premiumIconAccounts);
Settings::AddSkip(top, st::premiumLineTextSkip); Settings::AddSkip(top, st::premiumLineTextSkip);
if (premiumPossible) { if (premiumPossible) {
Ui::Premium::AddLimitRow(top, 0, std::nullopt, defaultLimit); Ui::Premium::AddLimitRow(
top,
(QString::number(std::max(current, defaultLimit) + 1)
+ ((current + 1 == premiumLimit) ? "" : "+")),
QString::number(defaultLimit));
Settings::AddSkip(top, st::premiumInfographicPadding.bottom()); Settings::AddSkip(top, st::premiumInfographicPadding.bottom());
} }
box->setTitle(tr::lng_accounts_limit_title()); box->setTitle(tr::lng_accounts_limit_title());

View file

@ -454,6 +454,7 @@ public:
int max, int max,
TextFactory textFactory, TextFactory textFactory,
int min); int min);
Line(not_null<Ui::RpWidget*> parent, QString max, QString min);
void setColorOverride(QBrush brush); void setColorOverride(QBrush brush);
@ -483,11 +484,18 @@ Line::Line(
int max, int max,
TextFactory textFactory, TextFactory textFactory,
int min) int min)
: Line(
parent,
max ? textFactory(max) : QString(),
min ? textFactory(min) : QString()) {
}
Line::Line(not_null<Ui::RpWidget*> parent, QString max, QString min)
: Ui::RpWidget(parent) : Ui::RpWidget(parent)
, _leftText(st::semiboldTextStyle, tr::lng_premium_free(tr::now)) , _leftText(st::semiboldTextStyle, tr::lng_premium_free(tr::now))
, _rightText(st::semiboldTextStyle, tr::lng_premium(tr::now)) , _rightText(st::semiboldTextStyle, tr::lng_premium(tr::now))
, _rightLabel(st::semiboldTextStyle, max ? textFactory(max) : QString()) , _rightLabel(st::semiboldTextStyle, max)
, _leftLabel(st::semiboldTextStyle, min ? textFactory(min) : QString()) { , _leftLabel(st::semiboldTextStyle, min) {
resize(width(), st::requestsAcceptButton.height); resize(width(), st::requestsAcceptButton.height);
sizeValue( sizeValue(
@ -626,14 +634,23 @@ void AddBubbleRow(
}, bubble->lifetime()); }, bubble->lifetime());
} }
void AddLimitRow(
not_null<Ui::VerticalLayout*> parent,
QString max,
QString min) {
parent->add(object_ptr<Line>(parent, max, min), st::boxRowPadding);
}
void AddLimitRow( void AddLimitRow(
not_null<Ui::VerticalLayout*> parent, not_null<Ui::VerticalLayout*> parent,
int max, int max,
std::optional<tr::phrase<lngtag_count>> phrase, std::optional<tr::phrase<lngtag_count>> phrase,
int min) { int min) {
parent->add( const auto factory = ProcessTextFactory(phrase);
object_ptr<Line>(parent, max, ProcessTextFactory(phrase), min), AddLimitRow(
st::boxRowPadding); parent,
max ? factory(max) : QString(),
min ? factory(min) : QString());
} }
void AddAccountsRow( void AddAccountsRow(

View file

@ -39,6 +39,11 @@ void AddBubbleRow(
std::optional<tr::phrase<lngtag_count>> phrase, std::optional<tr::phrase<lngtag_count>> phrase,
const style::icon *icon); const style::icon *icon);
void AddLimitRow(
not_null<Ui::VerticalLayout*> parent,
QString max,
QString min = {});
void AddLimitRow( void AddLimitRow(
not_null<Ui::VerticalLayout*> parent, not_null<Ui::VerticalLayout*> parent,
int max, int max,