Add BaseTheme.h.
This commit is contained in:
parent
c9bf8475f3
commit
7b858d20f2
@ -330,6 +330,7 @@ set(TDLIB_SOURCE_PART1
|
||||
td/telegram/BackgroundInfo.cpp
|
||||
td/telegram/BackgroundManager.cpp
|
||||
td/telegram/BackgroundType.cpp
|
||||
td/telegram/BaseTheme.cpp
|
||||
td/telegram/Birthdate.cpp
|
||||
td/telegram/BoostManager.cpp
|
||||
td/telegram/BotCommand.cpp
|
||||
@ -606,6 +607,7 @@ set(TDLIB_SOURCE_PART2
|
||||
td/telegram/BackgroundInfo.h
|
||||
td/telegram/BackgroundManager.h
|
||||
td/telegram/BackgroundType.h
|
||||
td/telegram/BaseTheme.h
|
||||
td/telegram/Birthdate.h
|
||||
td/telegram/BlockListId.h
|
||||
td/telegram/BoostManager.h
|
||||
|
45
td/telegram/BaseTheme.cpp
Normal file
45
td/telegram/BaseTheme.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/telegram/BaseTheme.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
bool is_dark_base_theme(BaseTheme base_theme) {
|
||||
switch (base_theme) {
|
||||
case BaseTheme::Classic:
|
||||
case BaseTheme::Day:
|
||||
case BaseTheme::Arctic:
|
||||
return false;
|
||||
case BaseTheme::Night:
|
||||
case BaseTheme::Tinted:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
BaseTheme get_base_theme(const telegram_api::object_ptr<telegram_api::BaseTheme> &base_theme) {
|
||||
CHECK(base_theme != nullptr);
|
||||
switch (base_theme->get_id()) {
|
||||
case telegram_api::baseThemeClassic::ID:
|
||||
return BaseTheme::Classic;
|
||||
case telegram_api::baseThemeDay::ID:
|
||||
return BaseTheme::Day;
|
||||
case telegram_api::baseThemeNight::ID:
|
||||
return BaseTheme::Night;
|
||||
case telegram_api::baseThemeTinted::ID:
|
||||
return BaseTheme::Tinted;
|
||||
case telegram_api::baseThemeArctic::ID:
|
||||
return BaseTheme::Arctic;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return BaseTheme::Classic;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
22
td/telegram/BaseTheme.h
Normal file
22
td/telegram/BaseTheme.h
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
// append-only
|
||||
enum class BaseTheme : int32 { Classic, Day, Night, Tinted, Arctic };
|
||||
|
||||
bool is_dark_base_theme(BaseTheme base_theme);
|
||||
|
||||
BaseTheme get_base_theme(const telegram_api::object_ptr<telegram_api::BaseTheme> &base_theme);
|
||||
|
||||
} // namespace td
|
@ -495,21 +495,6 @@ ThemeManager::DialogBoostAvailableCounts ThemeManager::get_dialog_boost_availabl
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ThemeManager::is_dark_base_theme(BaseTheme base_theme) {
|
||||
switch (base_theme) {
|
||||
case BaseTheme::Classic:
|
||||
case BaseTheme::Day:
|
||||
case BaseTheme::Arctic:
|
||||
return false;
|
||||
case BaseTheme::Night:
|
||||
case BaseTheme::Tinted:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeManager::on_update_theme(telegram_api::object_ptr<telegram_api::theme> &&theme, Promise<Unit> &&promise) {
|
||||
CHECK(theme != nullptr);
|
||||
bool is_changed = false;
|
||||
@ -1053,26 +1038,6 @@ void ThemeManager::on_get_profile_accent_colors(
|
||||
}
|
||||
}
|
||||
|
||||
ThemeManager::BaseTheme ThemeManager::get_base_theme(
|
||||
const telegram_api::object_ptr<telegram_api::BaseTheme> &base_theme) {
|
||||
CHECK(base_theme != nullptr);
|
||||
switch (base_theme->get_id()) {
|
||||
case telegram_api::baseThemeClassic::ID:
|
||||
return BaseTheme::Classic;
|
||||
case telegram_api::baseThemeDay::ID:
|
||||
return BaseTheme::Day;
|
||||
case telegram_api::baseThemeNight::ID:
|
||||
return BaseTheme::Night;
|
||||
case telegram_api::baseThemeTinted::ID:
|
||||
return BaseTheme::Tinted;
|
||||
case telegram_api::baseThemeArctic::ID:
|
||||
return BaseTheme::Arctic;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return BaseTheme::Classic;
|
||||
}
|
||||
}
|
||||
|
||||
ThemeManager::ThemeSettings ThemeManager::get_chat_theme_settings(
|
||||
telegram_api::object_ptr<telegram_api::themeSettings> settings) {
|
||||
ThemeSettings result;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/AccentColorId.h"
|
||||
#include "td/telegram/BackgroundInfo.h"
|
||||
#include "td/telegram/BaseTheme.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
@ -54,9 +55,6 @@ class ThemeManager final : public Actor {
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
private:
|
||||
// append-only
|
||||
enum class BaseTheme : int32 { Classic, Day, Night, Tinted, Arctic };
|
||||
|
||||
struct ThemeSettings {
|
||||
int32 accent_color = 0;
|
||||
int32 message_accent_color = 0;
|
||||
@ -164,8 +162,6 @@ class ThemeManager final : public Actor {
|
||||
|
||||
void load_profile_accent_colors();
|
||||
|
||||
static bool is_dark_base_theme(BaseTheme base_theme);
|
||||
|
||||
void on_get_chat_themes(Result<telegram_api::object_ptr<telegram_api::account_Themes>> result);
|
||||
|
||||
bool on_update_accent_colors(FlatHashMap<AccentColorId, vector<int32>, AccentColorIdHash> light_colors,
|
||||
@ -205,8 +201,6 @@ class ThemeManager final : public Actor {
|
||||
|
||||
void send_update_chat_themes() const;
|
||||
|
||||
static BaseTheme get_base_theme(const telegram_api::object_ptr<telegram_api::BaseTheme> &base_theme);
|
||||
|
||||
ThemeSettings get_chat_theme_settings(telegram_api::object_ptr<telegram_api::themeSettings> settings);
|
||||
|
||||
td_api::object_ptr<td_api::updateAccentColors> get_update_accent_colors_object() const;
|
||||
|
Loading…
Reference in New Issue
Block a user