From 7037268a362eb17ef1b46f13a38cd4722aef247b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 24 May 2022 12:24:39 +0300 Subject: [PATCH] Slightly improved margins in premium settings. --- Telegram/SourceFiles/settings/settings.style | 4 +- .../SourceFiles/settings/settings_premium.cpp | 53 +++++++++++-------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index d9467e4b8e..0c7216a0a2 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -421,7 +421,6 @@ notifyPreviewTextPosition: point(64px, 30px); notifyPreviewChecksSkip: 12px; notifyPreviewBottomSkip: 9px; -settingsPremiumDescriptionSkip: 3px; settingsPremiumButtonPadding: margins(11px, 11px, 11px, 3px); settingsPremiumTopBarBackIcon: icon {{ "info/info_back", premiumButtonFg }}; settingsPremiumTopBarBackIconOver: icon {{ "info/info_back", premiumButtonFg }}; @@ -448,4 +447,5 @@ settingsPremiumTopBarClose: IconButton(infoTopBarClose) { color: shadowFg; } } -settingsPremiumLabelDescriptionRightSkip: 46px; +settingsPremiumRowTitlePadding: margins(60px, 5px, 46px, 3px); +settingsPremiumRowAboutPadding: margins(60px, 0px, 46px, 6px); diff --git a/Telegram/SourceFiles/settings/settings_premium.cpp b/Telegram/SourceFiles/settings/settings_premium.cpp index e0c300325e..8d87457d46 100644 --- a/Telegram/SourceFiles/settings/settings_premium.cpp +++ b/Telegram/SourceFiles/settings/settings_premium.cpp @@ -55,6 +55,23 @@ struct Entry { rpl::producer description; }; +using Order = std::vector; + +[[nodiscard]] Order FallbackOrder() { + return Order{ + QString("double_limits"), + QString("more_upload"), + QString("faster_download"), + QString("voice_to_text"), + QString("no_ads"), + QString("unique_reactions"), + QString("premium_stickers"), + QString("advanced_chat_management"), + QString("profile_badge"), + QString("animated_userpics"), + }; +} + [[nodiscard]] base::flat_map EntryMap() { return base::flat_map{ { @@ -381,21 +398,18 @@ void Premium::setStepDataReference(std::any &data) { void Premium::setupContent() { const auto content = Ui::CreateChild(this); - const auto &st = st::settingsButton; + const auto &stDefault = st::settingsButton; const auto &stLabel = st::defaultFlatLabel; const auto iconSize = st::settingsPremiumIconDouble.size(); + const auto &titlePadding = st::settingsPremiumRowTitlePadding; + const auto &descriptionPadding = st::settingsPremiumRowAboutPadding; - AddSkip(content, st.padding.top()); + AddSkip(content, stDefault.padding.top() + titlePadding.top()); auto entryMap = EntryMap(); auto iconContainers = std::vector(); iconContainers.reserve(int(entryMap.size())); - auto titlePadding = st.padding; - titlePadding.setBottom(0); - auto descriptionPadding = st.padding; - descriptionPadding.setTop(0); - descriptionPadding.setRight(st::settingsPremiumLabelDescriptionRightSkip); const auto addRow = [&]( rpl::producer &&title, rpl::producer &&text) { @@ -407,7 +421,6 @@ void Premium::setupContent() { std::move(title) | rpl::map(Ui::Text::Bold), stLabel), titlePadding); - AddSkip(content, st::settingsPremiumDescriptionSkip); content->add( object_ptr( content, @@ -434,28 +447,21 @@ void Premium::setupContent() { auto icons = std::vector(); icons.reserve(int(entryMap.size())); { - using Order = std::vector; const auto &account = _controller->session().account(); const auto mtpOrder = account.appConfig().get( "premium_promo_order", - Order()); + FallbackOrder()); const auto processEntry = [&](Entry &entry) { icons.push_back(entry.icon); addRow(base::take(entry.title), base::take(entry.description)); }; - if (!mtpOrder.empty()) { - for (const auto &key : mtpOrder) { - auto it = entryMap.find(key); - if (it == end(entryMap)) { - continue; - } - processEntry(it->second); - } - } else { - for (auto &entry : ranges::views::values(entryMap)) { - processEntry(entry); + for (const auto &key : mtpOrder) { + auto it = entryMap.find(key); + if (it == end(entryMap)) { + continue; } + processEntry(it->second); } SendScreenShow(_controller, mtpOrder, _ref); @@ -494,10 +500,11 @@ void Premium::setupContent() { const auto brush = QBrush(resultGradient); AddButtonIcon( iconContainer, - st, + stDefault, { .icon = icons[i], .backgroundBrush = brush }); } + AddSkip(content, descriptionPadding.bottom()); AddSkip(content); AddDivider(content); AddSkip(content); @@ -515,7 +522,7 @@ void Premium::setupContent() { tr::lng_premium_summary_bottom_about(Ui::Text::RichLangValue), st::aboutLabel), st::boxRowPadding); - AddSkip(content, st.padding.top() + st.padding.bottom()); + AddSkip(content, stDefault.padding.top() + stDefault.padding.bottom()); Ui::ResizeFitChild(this, content);