Moved out some constant color indices to separated style file.

This commit is contained in:
23rd 2024-11-20 07:44:36 +03:00
parent c04f68f25c
commit 2dfa58aae2
6 changed files with 28 additions and 15 deletions

View file

@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/ui_utility.h"
#include "styles/style_color_indices.h"
#include "styles/style_credits.h"
#include "styles/style_giveaway.h"
#include "styles/style_info.h"
@ -59,7 +60,6 @@ namespace {
constexpr auto kDoneTooltipDuration = 5 * crl::time(1000);
constexpr auto kAdditionalPrizeLengthMax = 128;
constexpr auto kColorIndexCredits = int(1);
[[nodiscard]] QDateTime ThreeDaysAfterToday() {
auto dateNow = QDateTime::currentDateTime();
@ -370,7 +370,7 @@ void CreateGiveawayBox(
prepaid->credits
? GiveawayType::PrepaidCredits
: GiveawayType::Prepaid,
prepaid->credits ? kColorIndexCredits : prepaid->id,
prepaid->credits ? st::colorIndexOrange : prepaid->id,
tr::lng_boosts_prepaid_giveaway_single(),
prepaid->credits
? tr::lng_boosts_prepaid_giveaway_credits_status(
@ -508,7 +508,7 @@ void CreateGiveawayBox(
object_ptr<Giveaway::GiveawayTypeRow>(
box,
GiveawayType::Credits,
kColorIndexCredits,
st::colorIndexOrange,
tr::lng_credits_summary_title(),
tr::lng_giveaway_create_subtitle(),
std::move(badge)));

View file

@ -16,14 +16,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h"
#include "styles/style_boxes.h"
#include "styles/style_chat.h"
#include "styles/style_color_indices.h"
#include "styles/style_giveaway.h"
#include "styles/style_statistics.h"
namespace Giveaway {
constexpr auto kColorIndexSpecific = int(4);
constexpr auto kColorIndexRandom = int(2);
GiveawayTypeRow::GiveawayTypeRow(
not_null<Ui::RpWidget*> parent,
Type type,
@ -32,7 +30,7 @@ GiveawayTypeRow::GiveawayTypeRow(
: GiveawayTypeRow(
parent,
type,
(type == Type::SpecificUsers) ? kColorIndexSpecific : kColorIndexRandom,
(type == Type::SpecificUsers) ? st::colorIndexBlue : st::colorIndexGreen,
(type == Type::SpecificUsers)
? tr::lng_giveaway_award_option()
: (type == Type::Random)

View file

@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/slider_natural_width.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/ui_utility.h"
#include "styles/style_color_indices.h"
#include "styles/style_dialogs.h" // dialogsSearchTabs
#include "styles/style_giveaway.h"
#include "styles/style_info.h"
@ -339,7 +340,6 @@ void InnerWidget::fill() {
Ui::AddSkip(inner);
if (!status.prepaidGiveaway.empty()) {
constexpr auto kColorIndexCredits = int(1);
const auto multiplier = Api::PremiumGiftCodeOptions(_peer)
.giveawayBoostsPerPremium();
Ui::AddSkip(inner);
@ -352,7 +352,7 @@ void InnerWidget::fill() {
g.credits
? GiveawayTypeRow::Type::PrepaidCredits
: GiveawayTypeRow::Type::Prepaid,
g.credits ? kColorIndexCredits : g.id,
g.credits ? st::colorIndexOrange : g.id,
g.credits
? tr::lng_boosts_prepaid_giveaway_single()
: tr::lng_boosts_prepaid_giveaway_quantity(

View file

@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/wrap/vertical_layout.h"
#include "styles/style_boxes.h"
#include "styles/style_color_indices.h"
#include "styles/style_credits.h"
#include "styles/style_dialogs.h" // dialogsStoriesFull.
#include "styles/style_layers.h" // boxRowPadding.
@ -47,9 +48,6 @@ namespace Info::Statistics {
namespace {
using BoostCallback = Fn<void(const Data::Boost &)>;
constexpr auto kColorIndexCredits = int(1);
constexpr auto kColorIndexUnclaimed = int(3);
constexpr auto kColorIndexPending = int(4);
[[nodiscard]] PeerListRowId UniqueRowIdFromEntry(
const Data::CreditsHistoryEntry &entry) {
@ -475,10 +473,10 @@ BoostRow::BoostRow(const Data::Boost &boost)
, _boost(boost)
, _userpic(
Ui::EmptyUserpic::UserpicColor(boost.credits
? kColorIndexCredits
? st::colorIndexOrange
: boost.isUnclaimed
? kColorIndexUnclaimed
: kColorIndexPending),
? st::colorIndexSea
: st::colorIndexBlue),
QString()) {
init();
}

View file

@ -0,0 +1,16 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
colorIndexRed: 0;
colorIndexOrange: 1;
colorIndexGreen: 2;
colorIndexSea: 3;
colorIndexBlue: 4;
colorIndexPurple: 5;
colorIndexPink: 6;
colorIndexYellow: 7;

View file

@ -18,6 +18,7 @@ set(style_files
ui/chat/chat.style
ui/effects/credits.style
ui/effects/premium.style
ui/color_indices.style
boxes/boxes.style
dialogs/dialogs.style
chat_helpers/chat_helpers.style